Reputation: 19
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.
Upvotes: 0
Views: 525
Reputation: 4371
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. E.g.:
jar {
duplicatesStrategy = DuplicatesStrategy.INCLUDE
}
See the documentation pointed to by the error for more information.
Based on your additional information... Why can't it be in a separate module? You should make three nested projects. Api, Api-Spigot, Api-Velocity. Api-Spigot and Api-Velocity will depend on Api.
See https://docs.gradle.org/current/userguide/declaring_dependencies_between_subprojects.html
Upvotes: 1