You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ShadowJar task supports re-embedding of contents of other jars using the shadowTask.from(jarToEmbed) API. However, duplicates encountered across the jars always get excluded, regardless of the duplicatesStrategy configuration. The only duplicates the ShadowJar recognizes are the duplicates among the copied files.
The expected behavior is that ShadowJar treats duplicates per duplicationStrategy regardless of whether they come from.
Related environent and versions
No response
Reproduction steps
Consider the following ShadowJar task configuration:
importcom.github.jengelman.gradle.plugins.shadow.tasks.ShadowJarimportjava.util.zip.ZipInputStream
plugins {
id("com.github.johnrengelman.shadow") version "8.1.1"
}
funmakeFoo(value:String): TaskProvider<*> = tasks.register(value) {
valout= layout.buildDirectory.file("${value}/foo")
outputs.file(out)
doLast {
out.get().asFile.writeText(value)
}
}
val foo1 = makeFoo("1")
val jar1 = tasks.register<Jar>("jar1") {
from(foo1)
archiveBaseName.set("jar1")
destinationDirectory.set(layout.buildDirectory.dir("jar1"))
}
val foo2 = makeFoo("2")
val jar2 = tasks.register<Jar>("jar2") {
from(foo2)
archiveBaseName.set("jar2")
destinationDirectory.set(layout.buildDirectory.dir("jar2"))
}
val foo3 = makeFoo("3")
val foo4 = makeFoo("4")
val shadow = tasks.register<ShadowJar>("shadow") {
// this does nothing in terms of duplicates across embedded jars
duplicatesStrategy =DuplicatesStrategy.FAIL
archiveBaseName.set("shadow")
from(
jar1,
jar2, // duplicate from this jar gets silently excluded
foo3, // this is also silently ignored
foo4, // but this duplicate is suddenly recognized as a duplicate
)
val output = layout.buildDirectory.dir("shadow")
destinationDirectory.set(output)
doLast {
println(
ZipInputStream(
output.get().asFile.resolve("shadow.jar").inputStream()
).use {
generateSequence { it.nextEntry }.first { it.name =="foo" }
it.readBytes().decodeToString()
}
)
}
}
Duplication among foo3 and foo4 is recognized, but the duplicate file foo between jar1, jar2 and foo3 for example is silently excluded.
Anything else?
No response
The text was updated successfully, but these errors were encountered:
Expected and Results
ShadowJar
task supports re-embedding of contents of other jars using theshadowTask.from(jarToEmbed)
API. However, duplicates encountered across the jars always get excluded, regardless of theduplicatesStrategy
configuration. The only duplicates theShadowJar
recognizes are the duplicates among the copied files.The expected behavior is that
ShadowJar
treats duplicates perduplicationStrategy
regardless of whether they come from.Related environent and versions
No response
Reproduction steps
Consider the following
ShadowJar
task configuration:Duplication among
foo3
andfoo4
is recognized, but the duplicate filefoo
betweenjar1
,jar2
andfoo3
for example is silently excluded.Anything else?
No response
The text was updated successfully, but these errors were encountered: