With jOOQ, I may want to combine using the jOOQ code generator with Maven and a custom generator strategy. It looks as though this can be done as such (leaving out irrelevant parts):
<plugin>
<groupId>org.jooq</groupId>
<artifactId>jooq-codegen-maven</artifactId>
<version>2.2.2</version>
<!-- The plugin should hook into the generate goal -->
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
<configuration>
<generator>
<name>org.jooq.util.DefaultGenerator</name>
<!-- But the custom strategy is not yet compiled -->
<strategy>
<name>com.example.MyStrategy</name>
</strategy>
</generator>
</configuration>
</plugin>
The above configuration depicts the problem. jOOQ's code generator hooks into the generate goal of the Maven lifecycle, which takes place before the compile goal of the lifecycle. For code generation, however, it needs a pre-compiled custom strategy class, or I will get a ClassNotFoundException
. How can this be resolved with Maven? Can I compile a single class before executing the generate
goal?
A much better solution is to split the project into two modules. One contains the strategy and the other the rest.
Using modules, you can compile the strategy in an independent step and then use that module in the plugin:
<plugin>
<groupId>org.jooq</groupId>
<artifactId>jooq-codegen-maven</artifactId>
<version>2.2.2</version>
...your config goes here...
<dependencies>
list your strategy module here
</dependencies>
</plugin>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With