Search code examples
javaspringspring-bootgradledependencies

Gradle "angular-1.8.3" is a duplicate but no duplicate handling strategy has been set


I have a Spring Boot 2.2.x Project and I'm getting the following error when executing gradlew build:

* What went wrong:
Execution failed for task ':myproject:bootWar'.
> Entry WEB-INF/lib/angular-1.8.3.jar is a duplicate but no duplicate handling strategy has been set. Please refer to https://docs.gradle.org/7.6/dsl/org.gradle.api.tasks.Copy.html#org.gradle.api.tasks.Copy:duplicatesStrategy for details.

Unfortunately this error occured after a big upgrade process (from Spring 1.5), so I cannot really track down a single change I made.

How can I find out where that duplicate comes from?

With the answers I found on Stackoverflow, everyone keeps suggesting to just handle duplicates by excluding the "second" duplicate. But I did not find a solution that works for all tasks - because if I set a handling strategy for the task bootWar I get the same error for every other task that somehow generates something (Jar, Tar, Zip, you name it).
Also I think the root cause of the problem is the duplicate angular jar file. And I'd like to fix that.

Answers I already found:
https://github.com/TheBoegl/gradle-launch4j/issues/117
How fix a build problem: Entry com/netflix/server/context/BiDirectional.class is a duplicate but no duplicate handling strategy has been set
Gradle "Entry .classpath is a duplicate but no duplicate handling strategy has been set"


Solution

  • Finally fixed it by altering the import statement to:

    implementation ('org.webjars.npm:github-com-daniel-nagy-fixed-table-header:0.2.1') {
        exclude group: 'org.webjars.npm'
    }
    

    Problem was that the dependency org.webjars.npm:angular:1.8.3 came with two different dependencies. This is the underlying problem. Applying a duplicate handling strategy is just dealing with it the wrong way I believe.

    See also this post: https://github.com/spring-projects/spring-boot/issues/33659