Available in versions: Dev (3.20) | Latest (3.19)

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.

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:

The above examples all allow for specifying inline code for in-memory compilation of the relevant object. For example, when defining a GeneratorStrategy:

XML (standalone and maven)
Programmatic
Gradle (Kotlin)
Gradle (Groovy)
Gradle (third party)
<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!

The jOOQ Logo