I've created custom source set in Gradle project to keep all generated code:
sourceSets {
generated {
java {
srcDir 'src/generated/java'
}
resources {
srcDir 'src/generated/resources'
}
}
}
I want to make the result of this source set's code compilation available at compile and run time for main
and test
source sets.
What's the right semantic way to do it in Gradle?
UPDATE:
As suggested here: How do I add a new sourceset to Gradle? doesn't work for me, I still get java.lang.ClassNotFoundException
when I launch my app (though compilation and unit tests run fine). Here is what I tried:
sourceSets {
main {
compileClasspath += sourceSets.generated.output
runtimeClasspath += sourceSets.generated.output
}
test {
compileClasspath += sourceSets.generated.output
runtimeClasspath += sourceSets.generated.output
}
}
ClassNotFoundException
when I launch my app. Please, see updated question. – Georgenegeorges*.class
files fromgenerated
source set to be included into resulting JAR? Or I should create a custom task that produces JAR forgenerated
source set (as here) and then add this JAR as dependency to the maincompile
configuration. – Georgenegeorgesjar { from sourceSets.generated.output }
. – Spirituous