Available in versions: Dev (3.20) | Latest (3.19) | 3.18 | 3.17 | 3.16 | 3.15 | 3.14 | 3.13 | 3.12 | 3.11 | 3.10

This documentation is for the unreleased development version of jOOQ. Click on the above version links to get this documentation for a supported version of jOOQ.

Custom code generation dependencies

Applies to ✅ Open Source Edition   ✅ Express Edition   ✅ Professional Edition   ✅ Enterprise Edition

Various code generation features allow for providing the code generator with a custom implementation of something, like:

Other use-cases require a classpath dependency to look up things like JPA entities.

Many of these custom implementation hooks come in two flavours:

  • Using Java in-memory compilation of the implementation.
  • Using a named reference to a previously compiled implementation.

Depending on the above approach, the following section explains how to set up your code generation dependencies. In both cases, any dependencies to the code generator need to be declared in your build:

Maven
Gradle (Kotlin)
Gradle (Groovy)
<plugin>
  <!-- Specify the maven code generator plugin -->
              <!-- Use org.jooq                for the Open Source Edition
                       org.jooq.pro            for commercial editions with Java 21 support,
                       org.jooq.pro-java-17    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 21 support,
                       org.jooq.trial-java-17  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.
                     Install the others locally using the provided scripts, or access them from here: https://repo.jooq.org
                     See the JDK version support matrix here: https://www.jooq.org/download/support-matrix-jdk -->

  <groupId>org.jooq</groupId>
  <artifactId>jooq-codegen-maven</artifactId>
  <version>3.20.0-SNAPSHOT</version>

  <executions>...</executions>
  <configuration>...</configuration>

  <dependencies>
    <dependency>...</dependency>
  </dependencies>
</plugin>

dependencies {
    jooqCodegen("...")
}
dependencies {
    jooqCodegen "..."
}

Using in-memory compilation

When using in-memory compilation, everything that is available to jOOQ's code generator is available to your in-memory compiled implementation of the extension point. You do not have to do anything else than declare those dependencies.

Using a named reference

A named reference of a custom implementation needs to be on the classpath of the code in a pre-compiled form (unlike the previously mentioned in-memory compiled form). In both Maven and Gradle, this is typically best done by setting up a multi modular project of this form:

                +-----------------------------------+
                | Your custom code generation logic |
                +-----------------------------------+
                             ^         ^
                  depends on |         | may or may not depend on
                             |         |
          +---------------------+   +---------------------+
          | jOOQ codegen plugin |   | Your application    |
          +---------------------+   +---------------------+
                             |         |
                   generates |         | depends on
                             v         v
                     +-------------------------+
                     | jOOQ generated classes  |
                     +-------------------------+

It is important to understand that your custom code generation logic has to be compiled (and packaged, etc.) before you use it in your code generation logic. Think of your custom code generation logic like any library provided by a third party, available from Maven Central or elsewhere. It's a dependency like any other.

Feedback

Do you have any feedback about this page? We'd love to hear it!

The jOOQ Logo