简体   繁体   English

从 maven 迁移到 gradle 时出错

[英]Errors when migrating from maven to gradle

Hi I was trying to migrate from maven to gradle, but I have this error when compiling, and I'm pretty new to gradle so idk now how exactly to fix things and where to fix them.嗨,我试图从 maven 迁移到 gradle,但是编译时出现此错误,而且我对 gradle 还是很陌生,所以现在想知道如何修复它们以及在哪里修复它们。 I cannot share the src bc its private, but i can share some img if needed of the project.我不能分享 src bc 它的私有内容,但如果项目需要,我可以分享一些 img。

Execution failed for task ':jar'.
> Entry org/lydark/api/common/Api.class is a duplicate but no duplicate handling strategy has been set. Please refer to https://docs.gradle.org/7.2/dsl/org.gradle.api.tasks.Copy.html#org.gradle.api.tasks.Copy:duplicatesStrategy for details.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

在此处输入图像描述

The first step is to understand how your Jar task is configured.第一步是了解您的 Jar 任务是如何配置的。 It seems you have more than one org.lydark.api.common.Api class.看来您有不止一个org.lydark.api.common.Api class。 I think that is only possibly if you have multiple source sets, but without knowing your project structure I can't say exactly.我认为只有当你有多个源集时才有可能,但在不知道你的项目结构的情况下我不能准确地说。 You can't share the project but can you share just the build.gradle file?您不能共享项目,但您可以只共享build.gradle文件吗?

IF you can identify and eliminate the extra Api class then your problem should go away.如果您可以识别并消除额外的 Api class 那么您的问题应该 go 消失。 If you can't solve that, as a workaround (not a proper solution), you can configure the duplicate handling for the Jar task.如果您无法解决该问题,作为一种解决方法(不是正确的解决方案),您可以为 Jar 任务配置重复处理。 Eg:例如:

jar {
  duplicatesStrategy = DuplicatesStrategy.INCLUDE
}

See the documentation pointed to by the error for more information.有关更多信息,请参阅错误指向的文档。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM