Slackbot
02/02/2023, 2:55 PMMarkus Maier
02/02/2023, 3:16 PMINCLUDE flag works exactly as designed. I'd recommend not to set duplicatesStrategy at all but fix the configuration of the Jar task to not have errors. Painful as that might be, it's deterministic and will be guaranteed to be correct.
IMHO INCLUDE was only ever useful as a means of upgrading old builds that didn't need to care about duplicate files (e.g. when they were really identical) without having to fix all task configurations. If you consider ignoring such problems to be "useful"Jakub Chrzanowski
02/02/2023, 3:28 PMsetFrom and pass the directory with instrumented classes.
What would be the most reliable way to exclude existing duplicates of non-instrumented content?ephemient
02/02/2023, 7:04 PMVampire
02/02/2023, 7:10 PMephemient
02/02/2023, 7:11 PMJakub Chrzanowski
02/02/2023, 7:13 PM"jar" task as it's often extended by users to provide additional content to the final package. This task also collects every classes that are supposed to be bundled (I don't know if that's Java, Kotlin, or any other JVM-based language) so I'm attaching my instrumentation task to the source set with sourceSet.compiledBy(instrumentTaskProvider) and then passing its output to the Jar task.
And at this point, classes get duplicated and shadowed.
Basically, everything's fine but JRE reads first occurrences of the given classes (the shadowed one) instead of what we eventually see when reading jar archive (shadowing ones, instrumented content).Jakub Chrzanowski
02/02/2023, 7:15 PMjar task with exclude {} filter that'll somehow get rid of the shadowed classes to don't confuse JVM. Still keeping the INCLUDE strategy.Jakub Chrzanowski
02/02/2023, 7:17 PMdoLast approach which isn't configuration-cache-friendly
val classesDirs = sourceSet.output.classesDirs as ConfigurableFileCollection
doLast { classesDirs.setFrom(instrumentationTaskProvider) }Vampire
02/02/2023, 7:19 PMBasically, I'm running away from theapproach which isn't configuration-cache-friendlydoLast
doLast per se is not CC unfriendly 😄
But changing the configuration like that sounds pretty hacky and fragile even without CC 😄Jakub Chrzanowski
02/02/2023, 7:21 PM