Available in versions: Dev (3.19) | Latest (3.18) | 3.17 | 3.16 | 3.15 | 3.14 | 3.13 | 3.12 | 3.11 | 3.10 | 3.9
Running the code generator with Maven
Applies to ✅ Open Source Edition ✅ Express Edition ✅ Professional Edition ✅ Enterprise Edition
There is no substantial difference between running the code generator with Maven or in standalone mode. Both modes use the exact same <configuration/>
element. The Maven plugin configuration adds some additional boilerplate around that:
<plugin> <!-- Specify the maven code generator plugin --> <!-- Use org.jooq for the Open Source Edition org.jooq.pro for commercial editions with Java 17 support, org.jooq.pro-java-11 for commercial editions with Java 11 support, org.jooq.pro-java-8 for commercial editions with Java 8 support, org.jooq.trial for the free trial edition with Java 17 support, org.jooq.trial-java-11 for the free trial edition with Java 11 support, org.jooq.trial-java-8 for the free trial edition with Java 8 support Note: Only the Open Source Edition is hosted on Maven Central. Import the others manually from your distribution --> <groupId>org.jooq</groupId> <artifactId>jooq-codegen-maven</artifactId> <version>3.16.19</version> <executions> <execution> <id>jooq-codegen</id> <phase>generate-sources</phase> <goals> <goal>generate</goal> </goals> </execution> </executions> <configuration> ... </configuration> </plugin>
Additional Maven-specific flags
There are, however, some additional, Maven-specific flags that can be specified with the jooq-codegen-maven
plugin only:
<plugin> <configuration> <!-- A boolean property (or constant) can be specified here to tell the plugin not to do anything --> <skip>${skip.jooq.generation}</skip> <!-- Instead of providing an inline configuration here, you can specify an external XML configuration file here --> <configurationFile>${externalfile}</configurationFile> <!-- Alternatively, you can provide several external configuration files. These will be merged by using Maven's combine.children="append" policy --> <configurationFiles> <configurationFile>${file1}</configurationFile> <configurationFile>${file2}</configurationFile> <configurationFile>...</configurationFile> </configurationFiles> </configuration> </plugin>
Maven plugin inheritance mechanism
As with any other Maven plugin configuration, you can profit from Maven's powerful plugin inheritance mechanism. This is particularly useful when you configure several code generation runs for jOOQ, e.g.
- Different configurations for different tenants
- Different configurations for different schemas
- Different configurations for different environments
One approach would be to use a <pluginManagement/>
configuration
<pluginManagement> <plugins> <plugin> <!-- Use org.jooq for the Open Source Edition org.jooq.pro for commercial editions with Java 17 support, org.jooq.pro-java-11 for commercial editions with Java 11 support, org.jooq.pro-java-8 for commercial editions with Java 8 support, org.jooq.trial for the free trial edition with Java 17 support, org.jooq.trial-java-11 for the free trial edition with Java 11 support, org.jooq.trial-java-8 for the free trial edition with Java 8 support Note: Only the Open Source Edition is hosted on Maven Central. Import the others manually from your distribution --> <groupId>org.jooq</groupId> <artifactId>jooq-codegen-maven</artifactId> <configuration> <!-- Log at WARN level by default --> <logging>WARN</logging> <generator> <generate> <!-- Never generate deprecated code --> <deprecated>false</deprecated> </generate> <database> <forcedTypes> <!-- Use BIGINT for all ID columns --> <forcedType> <name>BIGINT</name> <includeExpression>ID</includeExpression> </forcedType> </forcedTypes> </database> </generator> </configuration> </plugin> </plugins> </pluginManagement>
The above now applies to all of your jooq-codegen-maven
plugin configurations by default. Now, in some module or execution, you may want to enhance / override the above defaults:
<plugin> <groupId>org.jooq</groupId> <artifactId>jooq-codegen-maven</artifactId> <configuration> <!-- Log at INFO level by in this particular configuration --> <logging>INFO</logging> <generator> <database> <!-- Append additional forced type children to the default, rather than merging or replacing the default --> <forcedTypes combine.children="append"> <forcedType> <name>BIGINT</name> <includeExpression>.*_ID</includeExpression> </forcedType> </forcedTypes> </database> </generator> </configuration> </plugin>
Please refer to the Maven documentation for more details.
References to this page
- Configuration and setup of the generator
- Logging
- Error handling
- Jdbc
- Generator
- Database name and properties
- RegexFlags
- Includes and Excludes
- Include object types
- Record Version and Timestamp Fields
- Comments
- Synthetic readonly columns
- Synthetic readonly ROWIDs
- Synthetic identities
- Synthetic primary keys
- Synthetic unique keys
- Synthetic foreign keys
- Date as timestamp
- Ignore procedure return values (deprecated)
- Unsigned types
- Catalog and schema mapping
- Catalog and schema version providers
- Custom ordering of generated code
- Matching of forced types
- Data type rewriting
- Qualified converters
- Inline converters
- Lambda converters
- Enum converters
- Data type bindings
- Table valued functions
- Annotations
- Extended types
- Fluent setters
- Fully Qualified Types
- Global Artefacts
- Implicit JOIN paths
- Java Time Types
- Serial Version UID
- Sources
- Visibility Modifier
- Whitespace (newlines and indentation)
- Zero Scale Decimal Types
- Output target configuration
- Custom generator strategies
- Matcher strategies
- Generated Interfaces
- Generated DAOs
- Generated sequences
- Generated procedures
- Generated UDTs
- PostgreSQL
- Configuration
- Field replacement
- Embedded keys
- Embedded domains
- Mapping generated catalogs and schemas
- JPADatabase: Code generation from entities
- XMLDatabase: Code generation from XML files
- DDLDatabase: Code generation from SQL files
- LiquibaseDatabase: Code generation from Liquibase XML, YAML, JSON files
- XMLGenerator: Generating XML
- KotlinGenerator
- ScalaGenerator
- System properties governing code generation
- Oracle DATE data type
Feedback
Do you have any feedback about this page? We'd love to hear it!