gradle-launch4j
gradle-launch4j copied to clipboard
Entry <xxx> is a duplicate but no duplicate handling strategy has been set
It's not possible to set duplicatesStrategy for copying of dependencies into lib folder for createExe/launch4j task. Using gradle 7.x
could you please provide a simple working example that you expected to work
Hi, today I faced the same issue. My minimal build.gradle looks like this:
plugins {
id 'java'
id 'edu.sc.seis.launch4j' version '2.4.6'
}
dependencies {
implementation 'org.glassfish.jaxb:jaxb-runtime:3.0.2'
implementation 'com.sun.xml.bind:jaxb-xjc:3.0.2'
}
Both dependencies include a common dependency jaxb-core-3.0.2.jar.
The Error that is being displayed is:
Entry jaxb-core-3.0.2.jar is a duplicate but no duplicate handling strategy has been set.
Please refer to https://docs.gradle.org/7.1.1/dsl/org.gradle.api.tasks.Copy.html#org.gradle.api.tasks.Copy:duplicatesStrategy for details.
But when I try to add a duplication handling strategy it doesn't work:
plugins {
id 'java'
id 'edu.sc.seis.launch4j' version '2.4.6'
}
dependencies {
implementation 'org.glassfish.jaxb:jaxb-runtime:3.0.2'
implementation 'com.sun.xml.bind:jaxb-xjc:3.0.2'
}
launch4j {
duplicatesStrategy = DuplicatesStrategy.INCLUDE
}
This works inside the jar task.
If you could help me with some guidance where the error could be solved, I would like to work on this issue 😄
This seems to be related to the used copy tasks. You should be able to create a PR adding the strategy there and testing it with the reproducible code snippet you provided.
So I've created a test with my code snippet and it worked. It's because this repo is using Gradle 6.x and I was using Gradle 7.x. See also here: https://docs.gradle.org/current/userguide/upgrading_version_6.html#duplicates-strategy
Is it currently possible to let a test run with a different Gradle version than specified at the root project?
I thought, that maybe something like this would work:
launch4j{
mainClassName = 'com.test.app.Main'
copyConfigurable = copySpec {
duplicatesStrategy = DuplicatesStrategy.INCLUDE
}
}
But now I'm getting the error message:
Cannot fingerprint input property 'copyConfigurable': value 'org.gradle.api.internal.file.copy.DefaultCopySpec_Decorated@5fd1326f' cannot be serialized.
I was looking through the code and found the copyConfigurable, that to my understanding should also be settable to a CopySpec.
There are already some tests in this repo that run against different gradle versions.
I don't have access to my IDE now but you might be able to set the strategy on the distSpec
variable.
I've created a draft PR (#123) that fixes the issue. It just hardcodes it to exclude any duplicate entries. Maybe we should introduce a new property so the user can specify what DuplicatesStrategy should be used.
I think this issue can be closed, since the PR was already merged