Gradle “Entry .classpath is a duplicate but no duplicate handling strategy has been set”

We Are Going To Discuss About Gradle “Entry .classpath is a duplicate but no duplicate handling strategy has been set”. So lets Start this Java Article.

Gradle “Entry .classpath is a duplicate but no duplicate handling strategy has been set”

  1. Gradle “Entry .classpath is a duplicate but no duplicate handling strategy has been set”

    I faced same issue while building with kotlin and gradle 7. Resolve the issue adding the below code to your build.gradle.kts.
    tasks.withType<Jar> { duplicatesStrategy = DuplicatesStrategy.INHERIT }

  2. “Entry .classpath is a duplicate but no duplicate handling strategy has been set”

    I faced same issue while building with kotlin and gradle 7. Resolve the issue adding the below code to your build.gradle.kts.
    tasks.withType<Jar> { duplicatesStrategy = DuplicatesStrategy.INHERIT }

Solution 1

Similar to @korn answer, I solved mine using the EXCLUDE Strategy;

tasks.withType<Jar>() {

    duplicatesStrategy = DuplicatesStrategy.EXCLUDE

    manifest {
        attributes["Main-Class"] = "MainKt"
    }

    configurations["compileClasspath"].forEach { file: File ->
        from(zipTree(file.absoluteFile))
    }
}

Original Author Of This Content

Solution 2

jar {
duplicatesStrategy(DuplicatesStrategy.EXCLUDE)
…..

Original Author Of This Content

Solution 3

If you use Kotlin DSL and Gradle 7.0 it may be due to that bug KT-46165
It should be fixed in version 1.5.0.

Original Author Of This Content

Solution 4

I faced same issue while building with kotlin and gradle 7. Resolve the issue adding the below code to your build.gradle.kts.

tasks.withType<Jar> { duplicatesStrategy = DuplicatesStrategy.INHERIT }

Original Author Of This Content

Conclusion

So This is all About This Tutorial. Hope This Tutorial Helped You. Thank You.

Also Read,

Siddharth

I am an Information Technology Engineer. I have Completed my MCA And I have 4 Year Plus Experience, I am a web developer with knowledge of multiple back-end platforms Like PHP, Node.js, Python and frontend JavaScript frameworks Like Angular, React, and Vue.

Leave a Comment