Skip to content

Commit

Permalink
feat: Configure javaTimeTypes (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
ursjoss authored Jun 19, 2024
1 parent 1ceea59 commit 4a1e072
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
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

0 comments on commit 4a1e072

Please # to comment.