I tried to skin the cat another way. Instead of adding the base
and generated
source set outputs to the Jar directly, I added them as additional main
source set outputs, and declared them also as compileOnly
dependencies:
sourceSets {
base {
}
generator {
}
generated {
java {
srcDirs += [new File(generatorOutputDir, "java")]
}
resources {
srcDirs += [new File(generatorOutputDir, "resources")]
}
}
main {
output.dir(sourceSets.base.output)
output.dir(sourceSets.generated.output)
}
}
dependencies {
generatorImplementation sourceSets.base.output
generatedImplementation sourceSets.base.output
compileOnly sourceSets.base.output
compileOnly sourceSets.generated.output
}
This works ok at first, meaning that the A.A1 jar correctly contains all of base
, generated
, and main
classes. However, I’m getting another error from A.A2 which has A.A1 as both annotationProcessor
and implementation
dependency:
// A.A2
dependencies {
annotationProcessor project (":A:A1")
implementation project(":A:A1")
}
The (wrong) compilation command line I see looks like:
... -processorpath ...;A1.jar;... -classpath ...;$buildDir\classes\java\main;....
Why are the entries different?? I want the A1.jar dependency not the path to the main
source set output dir only.