Kotlin: Getting "Copying or archiving duplicate paths..." deprecation warnings when building plugin
Answered
I'm writing my plugin in Kotlin, and using a build.gradle.kts file to setup the Gradle build.
While in general I don't find converting from Java to Kotlin difficult at all, the differences between build.gradle and build.gradle.kts files confuse me, and sample build.gradle.kts dealing with this issue aren't easy to find.
Here are the warnings:
> Task :prepareSandbox
Copying or archiving duplicate paths with the default duplicates strategy has been deprecated. This is scheduled to be removed in Gradle 7.0. Duplicate path: "Ligatures Limited/lib/kotlin-stdlib-1.3.72.jar". Explicitly set the duplicates strategy to 'DuplicatesStrategy.INCLUDE' if you want to allow duplicate paths.
Copying or archiving duplicate paths with the default duplicates strategy has been deprecated. This is scheduled to be removed in Gradle 7.0. Duplicate path: "Ligatures Limited/lib/annotations-13.0.jar". Explicitly set the duplicates strategy to 'DuplicatesStrategy.INCLUDE' if you want to allow duplicate paths.
Copying or archiving duplicate paths with the default duplicates strategy has been deprecated. This is scheduled to be removed in Gradle 7.0. Duplicate path: "Ligatures Limited/lib/kotlin-stdlib-common-1.3.72.jar". Explicitly set the duplicates strategy to 'DuplicatesStrategy.INCLUDE' if you want to allow duplicate paths.
I tried this as my best guess at a Kotlin version of a Java fix I found:
val jar by tasks.getting(Jar::class) {
duplicatesStrategy = DuplicatesStrategy.INCLUDE
}
This doesn't cause any problems, but it doesn't fix anything either. It doesn't help that I don't really know Gradle very well, I'm just trying to modify the Kotlin plugin template generated for me by IDEA.
What's the correct way to fix this problem?
Please sign in to leave a comment.
What about the following syntax:
tasks.withType<Jar> {duplicatesStrategy = DuplicatesStrategy.INCLUDE
}
You may find more details in the Configuring tasks section in the Gradle Docs.
It tried that once before, and instead of it helping, I get LOTS MORE of those warnings instead, at least on the first rebuild after changing the file. Does the position in the script matter? Here's the entire script:
I just noticed I put this in the wrong forum. I meant Plugin Developers, not Plugin Users.
I didn't get any errors when using exactly the same script:
Which Gradle Wrapper version do you use?
The errors aren't coming on the runIde task, by the way, but buildPlugin.
Nor runIde or buildPlugin makes any problems. I use Gradle Wrapper 6.5.1
I updated the Gradle wrapper version, but it didn't help. For a moment I thought the wrapper update fixed the problem, but to make sure I ran the clean task, ran the build again, and the errors were back.
These are just warning – the task has finished successfully.