I've asked a related question here JOOQ class generation and gradle
In that question I'm trying to find the best way to do a multi-stage build including generating classes in a middle step. I've gone down the Option Two approach, and now find myself an impasse.
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 << {
//Use JOOQ to generate classes, with the output going into the generated sourceSet
.withDirectory(file("src/generated/java").getAbsolutePath())
}
generatedClasses
{
dependsOn bootstrapClasses
dependsOn generate
}
jar
{
dependsOn generatedClasses
dependsOn bootstrapClasses
}
The structure is that
I have a couple of problems, which I can't untangle:
I should note that the build as it stands above will successfully generate each of the source-sets.
Any help would be greatly appreciated.
O.K. I think I have found the answer to this question. There were two parts....
The first problem, having to specify the same dependencies multiple times, was fixed by adding this:
configurations {
generatedCompile {
extendsFrom compile
}
bootstrapCompile {
extendsFrom compile
}
}
The second problem, the jar file not having all the build artefacts, was fixed by changing the jar task to
jar
{
from sourceSets.generated.output
from sourceSets.bootstrap.output
dependsOn bootstrapClasses
dependsOn generatedClasses
}
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