KotlinGenerator
Applies to ✅ Open Source Edition ✅ Express Edition ✅ Professional Edition ✅ Enterprise Edition
jOOQ can generate Kotlin code instead of Java code, which allows for leveraging a few kotlin language features also in generated code.
In order to use the KotlinGenerator
, simply place the following class reference into your code generation configuration:
<configuration> <generator> <name>org.jooq.codegen.KotlinGenerator</name> </generator> </configuration>
See the configuration XSD, standalone code generation, and maven code generation for more details.
new org.jooq.meta.jaxb.Configuration() .withGenerator(new Generator() .withName("org.jooq.codegen.KotlinGenerator") )
See the configuration XSD and programmatic code generation for more details.
// The jOOQ-codegen-gradle plugin has been introduced in version 3.19 only.
// The jOOQ-codegen-gradle plugin has been introduced in version 3.19 only.
generationTool { generator { name = "org.jooq.codegen.KotlinGenerator" } }
See the configuration XSD and gradle code generation for more details.
Most of the code generation configuration remains the same for as long as it's independent of the generation language. But there are a few kotlin specific configuration flags, which are documented below:
<configuration> <generator> <generate> <!-- Generate POJOs as data classes, when using the KotlinGenerator. Default is true. --> <pojosAsKotlinDataClasses>true</pojosAsKotlinDataClasses> </generate> </generator> </configuration>
See the configuration XSD, standalone code generation, and maven code generation for more details.
new org.jooq.meta.jaxb.Configuration() .withGenerator( new Generate() // Generate POJOs as data classes, when using the KotlinGenerator. Default is true. .withPojosAsKotlinDataClasses(true) )
See the configuration XSD and programmatic code generation for more details.
// The jOOQ-codegen-gradle plugin has been introduced in version 3.19 only.
// The jOOQ-codegen-gradle plugin has been introduced in version 3.19 only.
generationTool { generator { generate { // Generate POJOs as data classes, when using the KotlinGenerator. Default is true. pojosAsKotlinDataClasses = true } } }
See the configuration XSD and gradle code generation for more details.
Feedback
Do you have any feedback about this page? We'd love to hear it!