简体   繁体   中英

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. I cannot share the src bc its private, but i can share some img if needed of the project.

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. It seems you have more than one 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?

IF you can identify and eliminate the extra Api class then your problem should go away. If you can't solve that, as a workaround (not a proper solution), you can configure the duplicate handling for the Jar task. Eg:

jar {
  duplicatesStrategy = DuplicatesStrategy.INCLUDE
}

See the documentation pointed to by the error for more information.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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