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

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.

Make sure your custom implementation's dependencies are available to the code generator as a code generator dependency

Feedback

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

The jOOQ Logo