In-memory compilation of programmatic configuration
Applies to ✅ Open Source Edition ✅ Express Edition ✅ Professional Edition ✅ Enterprise Edition
Various code generation configuration elements allow for programmatic configuration via external classes. This allows for more fine-grained control over the code generation behaviour. Examples include:
- Programmatic GeneratorStrategy implementations
- The Database instance, which provides meta data
- The Generator instance, which provides code generation logic
The above examples all allow for specifying inline code for in-memory compilation of the relevant object. For example, when defining a GeneratorStrategy:
<configuration> <generator> <strategy> <name>com.example.AsInDatabaseStrategy</name> <java>package com.example; import org.jooq.codegen.DefaultGeneratorStrategy; public class AsInDatabaseStrategy extends DefaultGeneratorStrategy { ... }</java> </strategy> </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() .withStrategy(new Strategy() .withName("com.example.AsInDatabaseStrategy") .withJava("""package com.example; import org.jooq.codegen.DefaultGeneratorStrategy; public class AsInDatabaseStrategy extends DefaultGeneratorStrategy { ... }""") ) )
See the configuration XSD and programmatic code generation for more details.
import org.jooq.meta.jaxb.* configuration { generator { strategy { name = "com.example.AsInDatabaseStrategy" java = """package com.example; import org.jooq.codegen.DefaultGeneratorStrategy; public class AsInDatabaseStrategy extends DefaultGeneratorStrategy { ... }""" } } }
See the configuration XSD and gradle code generation for more details.
configuration { generator { strategy { name = "com.example.AsInDatabaseStrategy" java = """package com.example; import org.jooq.codegen.DefaultGeneratorStrategy; public class AsInDatabaseStrategy extends DefaultGeneratorStrategy { ... }""" } } }
See the configuration XSD and gradle code generation for more details.
generationTool { generator { strategy { name = "com.example.AsInDatabaseStrategy" java = """package com.example; import org.jooq.codegen.DefaultGeneratorStrategy; public class AsInDatabaseStrategy extends DefaultGeneratorStrategy { ... }""" } } }
See the configuration XSD and gradle code generation for more details.
The name
must match the fully qualified class name of a GeneratorStrategy
.
The classpath of the GenerationTool
is inherited. When using Maven or Gradle, that would correspond to the plugin classpath.
Feedback
Do you have any feedback about this page? We'd love to hear it!