I asked the corresponding question here JOOQ and gradle class generation
In this question, I am trying to find a better way to do multi-step assembly, including creating classes in the middle step. I took the βOption 2β approach and am now at a dead end.
I have the following build.gradle file
apply plugin: 'java' apply plugin: 'eclipse' sourceSets { bootstrap generated { compileClasspath += bootstrap.output } main { compileClasspath += bootstrap.output compileClasspath += generated.output } } buildscript { repositories { mavenCentral() } dependencies { classpath 'org.jooq:jooq-codegen:3.5.0' classpath 'postgresql:postgresql:9.1-901.jdbc4' classpath project(":") } } dependencies { compile 'org.jooq:jooq:3.5.0' compile 'org.jooq:jooq-codegen:3.5.0' compile 'org.apache.poi:poi:3.10.1' compile 'com.google.guava:guava:18.0' generatedCompile 'org.jooq:jooq:3.5.0' generatedCompile 'org.jooq:jooq-codegen:3.5.0' generatedCompile 'org.apache.poi:poi:3.10.1' generatedCompile 'com.google.guava:guava:18.0' bootstrapCompile 'org.jooq:jooq:3.5.0' bootstrapCompile 'org.jooq:jooq-codegen:3.5.0' bootstrapCompile 'org.apache.poi:poi:3.10.1' bootstrapCompile 'com.google.guava:guava:18.0' } task generate << {
The structure is that
- The bootstrap source set contains some of the core Java classes needed to generate the code, plus the sql file that will be used to unpack the database
- Generate task uses classes and sql file in boostrap to generate classes
- The generated set contains the outputs of the generation task and
- The original main set contains what can be called "normal" classes (that is, those that use the database described by the bootstrap and generated classes).
I have a couple of problems that I cannot unravel:
- I seem to have to duplicate dependencies for each source set
- When a jar file is created, it contains only classes created from the main source set
I should note that the build, as shown above, will successfully generate each of the source sets.
Any help would be greatly appreciated.
source share