This message was deleted.
# community-support
s
This message was deleted.
c
I have a task that generated class files, and these files are then being ignored by the downstream libraries.
My debug logs confirm my suspicions, that my additional output dir is being ignored for some reason
Copy code
/java/main -XDuseUnsharedTable=true -classpath /Users/cwalker/git/simple-shadow-repack/sub-lib-1/build/classes/java/main /Users/cwalker/git/simple-shadow-repack/sub-lib-2/src/main/java/org/springframework/example2/Om1.java
We only see the java build classes dir marked as a classpath directory, not the additional repack dir
v
Maybe you need to add it to
classesDirs
instead?
c
It appears that classesDirs is immutable, presumably generated from some other list of inputs
Oh ok, the kotlin people cast classesDirs to ConfigurableFileCollection. Guess for the time being I’ll do the same.
Copy code
(output.classesDirs as? ConfigurableFileCollection)?.from(
            objenesisRepackClasses
        )
v
Actually, where is it not used if you use
dir
?
I just quickly tried
Copy code
val genClass by tasks.registering(JavaCompile::class) {
    source(file("foo/src/main/java"))
    destinationDirectory = layout.buildDirectory.dir("genClass")
    classpath = files()
}

val genRes by tasks.registering {
    val out = layout.buildDirectory.dir("genRes")
    outputs.dir(out)
    doLast {
        out.get().file("foo").asFile.writeText("FOO")
    }
}

sourceSets.main {
    output.dir(genClass.flatMap { it.destinationDirectory })
    output.dir(genRes)
}
and it seems to work just fine. If I execute the
jar
task, both tasks run and the result is packaged, if I execute the
run
task, both output dirs are added to the class path.
If it really does not work, you could also declare them as resource sources like
Copy code
sourceSets.main {
    resources.srcDir(genClass.flatMap { it.destinationDirectory })
    resources.srcDir(genRes)
}
works the same here, just that it is copied along to the resources output directory through the
processResources
task, and using
output.dir
seems a bit cleaner and more economic, as you do not need to copy files around where unnecessary.
c
So when I was testing this (I have what I believe to be a MRE) I had a sibling subproject that wasn’t receiving the correct compile classpath.
When using the module system it worked, but that’s because gradle placed the jar on the module-path (the jar had all the classes I wanted)
v
Hm, I can reproduce what you are saying. I'd tend to say this is a bug and you should report it.