Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small Gradle plugin QoL improvements #3930

Merged
merged 4 commits into from
Feb 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,27 +18,20 @@ import org.gradle.api.provider.Provider
import java.io.File
import javax.inject.Inject

@SqlDelightDsl
abstract class SqlDelightDatabase @Inject constructor(
val project: Project,
val name: String,
) {

init {
deriveSchemaFromMigrations.convention(false)
verifyMigrations.convention(false)
migrationOutputFileFormat.convention(".sql")
generateAsync.convention(false)
treatNullAsUnknownForEquality.convention(false)
}

abstract val packageName: Property<String>
abstract val schemaOutputDirectory: DirectoryProperty
abstract val srcDirs: ConfigurableFileCollection
abstract val deriveSchemaFromMigrations: Property<Boolean>
abstract val verifyMigrations: Property<Boolean>
val deriveSchemaFromMigrations: Property<Boolean> = project.objects.property(Boolean::class.java).convention(false)
val verifyMigrations: Property<Boolean> = project.objects.property(Boolean::class.java).convention(false)
abstract val migrationOutputDirectory: DirectoryProperty
abstract val migrationOutputFileFormat: Property<String>
abstract val generateAsync: Property<Boolean>
val migrationOutputFileFormat: Property<String> = project.objects.property(String::class.java).convention(".sql")
val generateAsync: Property<Boolean> = project.objects.property(Boolean::class.java).convention(false)

internal val configuration = project.configurations.create("${name}DialectClasspath").apply {
isCanBeConsumed = false
Expand Down Expand Up @@ -98,7 +91,7 @@ abstract class SqlDelightDatabase @Inject constructor(
* @see <a href="https://github.com/cashapp/sqldelight/issues/1490">sqldelight#1490</a>
* @see <a href="https://en.wikipedia.org/wiki/Null_%28SQL%29#Null-specific_and_3VL-specific_comparison_predicates">Wikipedia entry on null specific comparisons in SQL</a>
*/
abstract val treatNullAsUnknownForEquality: Property<Boolean>
val treatNullAsUnknownForEquality: Property<Boolean> = project.objects.property(Boolean::class.java).convention(false)

private val generatedSourcesDirectory
get() = File(project.buildDir, "generated/sqldelight/code/$name")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ package app.cash.sqldelight.gradle
import org.gradle.api.NamedDomainObjectContainer
import org.gradle.api.provider.Property

@DslMarker
annotation class SqlDelightDsl

@SqlDelightDsl
interface SqlDelightExtension {
val databases: NamedDomainObjectContainer<SqlDelightDatabase>
val linkSqlite: Property<Boolean>
Expand Down