From efaac8715bc74cf95fecef5f7d84eaa29953b2c5 Mon Sep 17 00:00:00 2001 From: Urs Joss Date: Tue, 18 Jun 2024 23:12:37 +0200 Subject: [PATCH] feat: Configure javaTimeTypes --- src/main/kotlin/com/optravis/jooq/gradle/Config.kt | 1 + src/main/kotlin/com/optravis/jooq/gradle/Generator.kt | 1 + .../kotlin/com/optravis/jooq/gradle/JooqGeneratorPlugin.kt | 7 +++++++ 3 files changed, 9 insertions(+) diff --git a/src/main/kotlin/com/optravis/jooq/gradle/Config.kt b/src/main/kotlin/com/optravis/jooq/gradle/Config.kt index 28a705f..a83acba 100644 --- a/src/main/kotlin/com/optravis/jooq/gradle/Config.kt +++ b/src/main/kotlin/com/optravis/jooq/gradle/Config.kt @@ -18,6 +18,7 @@ internal data class JooqGeneratorConfig( val migrationDirectory: File, val target: JooqTargetConfig, val deprecateUnknownTypes: Boolean, + val javaTimeTypes: Boolean, ) @ExperimentalJooqGeneratorConfig diff --git a/src/main/kotlin/com/optravis/jooq/gradle/Generator.kt b/src/main/kotlin/com/optravis/jooq/gradle/Generator.kt index 724fa2f..ebcccba 100644 --- a/src/main/kotlin/com/optravis/jooq/gradle/Generator.kt +++ b/src/main/kotlin/com/optravis/jooq/gradle/Generator.kt @@ -70,6 +70,7 @@ private fun JooqGeneratorConfig.toConfiguration(jdbcUrl: String) = .withKotlinNotNullPojoAttributes(true) .withKotlinNotNullInterfaceAttributes(true) .withKotlinNotNullRecordAttributes(true) + .withJavaTimeTypes(javaTimeTypes) ) .withTarget( Target() diff --git a/src/main/kotlin/com/optravis/jooq/gradle/JooqGeneratorPlugin.kt b/src/main/kotlin/com/optravis/jooq/gradle/JooqGeneratorPlugin.kt index bad7945..197f3e5 100644 --- a/src/main/kotlin/com/optravis/jooq/gradle/JooqGeneratorPlugin.kt +++ b/src/main/kotlin/com/optravis/jooq/gradle/JooqGeneratorPlugin.kt @@ -26,6 +26,7 @@ public interface JooqGeneratorExtension { public val migrationDirectory: Property public val packageName: Property public val deprecateUnknownTypes: Property + public val javaTimeTypes: Property } private object Default { @@ -53,6 +54,7 @@ public class JooqGeneratorPlugin : Plugin { 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) } @@ -71,6 +73,7 @@ public class JooqGeneratorPlugin : Plugin { jooqDbConfig.convention(JooqDatabaseConfig.postgres) migrationDirectory.convention(File("${project.layout.projectDirectory}/src/main/resources/db/migration")) deprecateUnknownTypes.convention(true) + javaTimeTypes.convention(true) } } @@ -91,6 +94,9 @@ private abstract class JooqGenerateTask : DefaultTask() { @get:Input abstract val deprecateUnknownTypes: Property + @get:Input + abstract val javaTimeTypes: Property + @get:InputDirectory abstract val migrationDirectory: Property @@ -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,