Gradle 7 task ':distTar' is a duplicate but no duplicate handling strategy has been set

Viewed 3467

I have upgraded from gradle 5 to gradle 7 and now receive the following error. ':distTar' is a duplicate but no duplicate handling strategy has been set.

In the build.gradle file I originally was receiving the error : "Execution failed for task ':bootJar'. is a duplicate but no duplicate handling strategy has been set." To make this error go away I used the following in my build.gradle :

tasks.withType(Jar).all {
    duplicatesStrategy 'exclude'
}

This then gives me the following error that I am asking for help on. The task distTar for me I believe is coming from my plugin 'application', but I can't find a way to reference that task to add a duplicatesStrategy to resolve the issue.

Any help to solve this error is appreciated! Thanks!

2 Answers

Tried this seemed to work out fine.

tasks.withType<Tar> {
    duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}

tasks.withType<Zip>{
    duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}

You need to use regular parenthesis...

tasks.withType(Tar){
    duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}

tasks.withType(Zip){
    duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}
Related