gradle-launch4j icon indicating copy to clipboard operation
gradle-launch4j copied to clipboard

Entry <xxx> is a duplicate but no duplicate handling strategy has been set

Open alesproch opened this issue 2 years ago • 1 comments

It's not possible to set duplicatesStrategy for copying of dependencies into lib folder for createExe/launch4j task. Using gradle 7.x

alesproch avatar Oct 21 '21 07:10 alesproch

could you please provide a simple working example that you expected to work

TheBoegl avatar Nov 03 '21 21:11 TheBoegl

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.

Shadow-Devil avatar Oct 18 '22 21:10 Shadow-Devil

If you could help me with some guidance where the error could be solved, I would like to work on this issue 😄

Shadow-Devil avatar Oct 18 '22 21:10 Shadow-Devil

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.

TheBoegl avatar Oct 19 '22 05:10 TheBoegl

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

Shadow-Devil avatar Oct 19 '22 11:10 Shadow-Devil

Is it currently possible to let a test run with a different Gradle version than specified at the root project?

Shadow-Devil avatar Oct 19 '22 11:10 Shadow-Devil

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.

Shadow-Devil avatar Oct 19 '22 12:10 Shadow-Devil

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.

TheBoegl avatar Oct 19 '22 20:10 TheBoegl

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.

Shadow-Devil avatar Oct 22 '22 23:10 Shadow-Devil

I think this issue can be closed, since the PR was already merged

Shadow-Devil avatar Nov 02 '22 08:11 Shadow-Devil