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 Gradle
Applies to ✅ Open Source Edition ✅ Express Edition ✅ Professional Edition ✅ Enterprise Edition
Run generation with the Gradle plugin
We recommend using the Gradle plugin by Etienne Studer (from Gradle Inc.). It provides a concise DSL that allows you to tune all configuration properties supported by each jOOQ version. Please direct any support questions or issues you may find directly to the third party plugin vendor.
Consider also the various examples provided there: https://github.com/etiennestuder/gradle-jooq-plugin/tree/master/example
Alternatively, programmatic configuration can be used
If you don't want to use the above third party plugin, there's also the possibility to use jOOQ's standalone code generator for simplicity. The following working example build.gradle script should work out of the box:
// Configure the Java plugin and the dependencies // ---------------------------------------------- apply plugin: 'java' repositories { mavenLocal() mavenCentral() } dependencies { /* 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 */ compile 'org.jooq:jooq:3.15.12' runtime 'com.h2database:h2:1.4.200' testCompile 'junit:junit:4.11' } buildscript { repositories { mavenLocal() mavenCentral() } dependencies { /* See above for the correct groupId */ classpath 'org.jooq:jooq-codegen:3.15.12' classpath 'com.h2database:h2:200' } } import org.jooq.codegen.GenerationTool import org.jooq.meta.jaxb.* GenerationTool.generate(new Configuration() .withJdbc(new Jdbc() .withDriver('org.h2.Driver') .withUrl('jdbc:h2:~/test-gradle') .withUser('sa') .withPassword('')) .withGenerator(new Generator() .withDatabase(new Database()) .withGenerate(new Generate() .withPojos(true) .withDaos(true)) .withTarget(new Target() .withPackageName('org.jooq.example.gradle.db') .withDirectory('src/main/java'))))
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 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
- 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
- MatcherRule
- Matching catalogs
- Matching schemas
- Matching tables
- Matching fields
- Matching routines
- Matching sequences
- Matching enums
- Matching embeddables
- Matcher examples
- 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!