在我的 libgdx 游戏中创建 .jar 时,通过 gradle dist 出现错误
when creating .jar in my libgdx game an error comes out via gradle dist
条目LICENSE.txt重复,但没有设置重复处理策略。详情请参考https://docs.gradle.org/7.0.2/dsl/org.gradle.api.tasks.Copy.html#org.gradle.api.tasks.Copy:duplicatesStrategy
task dist(type: Jar) {
manifest {
attributes 'Main-Class': project.mainClassName
}
dependsOn configurations.runtimeClasspath
from {
configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
}
with jar
}
错误说至少有两个名为 LICENSE.txt 的文件被复制到同一个目的地,这是不可能的,因为目录中不能有两个同名的文件。
要修复它,您可以删除项目中的 LICENSE.txt 个文件之一(也许在删除之前手动合并它们)。
或者你可以像错误消息中的 link 添加一个 duplicateStrategy 提示:
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
}
EXCLUDE
策略将忽略重复项。
来自文档:
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.
您还可以使用 this enum 中的任何其他重复策略。
条目LICENSE.txt重复,但没有设置重复处理策略。详情请参考https://docs.gradle.org/7.0.2/dsl/org.gradle.api.tasks.Copy.html#org.gradle.api.tasks.Copy:duplicatesStrategy
task dist(type: Jar) {
manifest {
attributes 'Main-Class': project.mainClassName
}
dependsOn configurations.runtimeClasspath
from {
configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
}
with jar
}
错误说至少有两个名为 LICENSE.txt 的文件被复制到同一个目的地,这是不可能的,因为目录中不能有两个同名的文件。
要修复它,您可以删除项目中的 LICENSE.txt 个文件之一(也许在删除之前手动合并它们)。
或者你可以像错误消息中的 link 添加一个 duplicateStrategy 提示:
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
}
EXCLUDE
策略将忽略重复项。
来自文档:
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.
您还可以使用 this enum 中的任何其他重复策略。