Code: Select all
tasks.named("jar") {
from(sourceSets.main.get().output) {
exclude("*")
}
}
< /code>
Ich habe auch versucht: < /p>
jar.from(freshTree, copySpec -> {
copySpec.eachFile(file -> {
System.out.println("[CUSTOM] adding: " + file.getRelativePath().getPathString());
});
});
jar.from(sourceSet.getOutput(), copySpec -> {
copySpec.exclude(details -> {
Set altClassNames = freshTree.get().getFiles().stream()
.map(file -> {
String relative = project.relativePath(file);
return relative.replace(File.separatorChar, '/');
})
.map(str -> {
String loc = "build/weaved-classes/java/" + sourceSetName + "/";
int idx = str.indexOf(loc);
return idx >= 0 ? str.substring(idx + loc.length()) : str;
})
.collect(Collectors.toSet());
String archivePath = details.getRelativePath().getPathString();
boolean shouldSkip = altClassNames.contains(archivePath);
System.out.println((shouldSkip ? "[SOURCESET] skipped: " : "[SOURCESET] included: ") + archivePath);
return true; // debug purposes, skip all files
});
copySpec.setDuplicatesStrategy(DuplicatesStrategy.EXCLUDE);
});
< /code>
Leider schlägt es fehl: < /p>
> Task :jar FAILED
[SOURCESET] included: com
[SOURCESET] included: main
[SOURCESET] included: com
[SOURCESET] included: integration
[SOURCESET] included: com
[SOURCESET] included: test
[CUSTOM] adding: some/package/MyClazz.class
...
> Entry some/package/MyClazz.class is a duplicate but no duplicate handling strategy has been set.