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

feat: Configure javaTimeTypes #10

Merged
merged 1 commit into from
Jun 19, 2024
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
1 change: 1 addition & 0 deletions src/main/kotlin/com/optravis/jooq/gradle/Config.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ internal data class JooqGeneratorConfig(
val migrationDirectory: File,
val target: JooqTargetConfig,
val deprecateUnknownTypes: Boolean,
val javaTimeTypes: Boolean,
)

@ExperimentalJooqGeneratorConfig
Expand Down
1 change: 1 addition & 0 deletions src/main/kotlin/com/optravis/jooq/gradle/Generator.kt
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ private fun JooqGeneratorConfig.toConfiguration(jdbcUrl: String) =
.withKotlinNotNullPojoAttributes(true)
.withKotlinNotNullInterfaceAttributes(true)
.withKotlinNotNullRecordAttributes(true)
.withJavaTimeTypes(javaTimeTypes)
)
.withTarget(
Target()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public interface JooqGeneratorExtension {
public val migrationDirectory: Property<File>
public val packageName: Property<String>
public val deprecateUnknownTypes: Property<Boolean>
public val javaTimeTypes: Property<Boolean>
}

private object Default {
Expand Down Expand Up @@ -53,6 +54,7 @@ public class JooqGeneratorPlugin : Plugin<Project> {
jooqDbConfig.convention(ext.jooqDbConfig)
migrationDirectory.convention(ext.migrationDirectory)
deprecateUnknownTypes.convention(ext.deprecateUnknownTypes)
javaTimeTypes.convention(ext.javaTimeTypes)
packageName.convention(ext.packageName.orElse("${project.group}.jooq"))
}
"compileJava" { dependsOn(generateTask) }
Expand All @@ -71,6 +73,7 @@ public class JooqGeneratorPlugin : Plugin<Project> {
jooqDbConfig.convention(JooqDatabaseConfig.postgres)
migrationDirectory.convention(File("${project.layout.projectDirectory}/src/main/resources/db/migration"))
deprecateUnknownTypes.convention(true)
javaTimeTypes.convention(true)
}
}

Expand All @@ -91,6 +94,9 @@ private abstract class JooqGenerateTask : DefaultTask() {
@get:Input
abstract val deprecateUnknownTypes: Property<Boolean>

@get:Input
abstract val javaTimeTypes: Property<Boolean>

@get:InputDirectory
abstract val migrationDirectory: Property<File>

Expand All @@ -110,6 +116,7 @@ private abstract class JooqGenerateTask : DefaultTask() {
database = jooqDbConfig.get(),
migrationDirectory = migrationDirectory.get(),
deprecateUnknownTypes = deprecateUnknownTypes.get(),
javaTimeTypes = javaTimeTypes.get(),
target = JooqTargetConfig(
packageName = packageName.get(),
directory = outputDirectory,
Expand Down