Entry LICENSE.txt is a duplicate but no duplicate handling strategy has been set. Please refer to https://docs.gradle.org/7.0.2/dsl/org.gradle.api.tasks.Copy.html#org.gradle.api.tasks.Copy:duplicatesStrategy for details.
task dist(type: Jar) {
manifest {
attributes 'Main-Class': project.mainClassName
}
dependsOn configurations.runtimeClasspath
from {
configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
}
with jar
}
CodePudding user response:
The error says that there are at least two files named LICENSE.txt, that are copied into the same destination, which is not possible, because there must not be two files with the same name in a directory.
To fix it you could delete one of the LICENSE.txt files in your project (maybe merge them manually before deleting one).
Or you can add a duplicateStrategy like the link in the error message suggests:
task dist(type: Jar) {
manifest {
attributes 'Main-Class': project.mainClassName
}
dependsOn configurations.runtimeClasspath
from {
configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
}
// exclude duplicate files
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
with jar
}
The EXCLUDE
strategy will just ignore the duplicate.
From the documentation:
Do not allow duplicates by ignoring subsequent items to be created at the same path.
If an attempt is made to create a duplicate file/entry during an operation, ignore the item. This will leave the file/entry that was first copied/created in place.
You can also use any other duplicate strategy from this enum.