Hi all,
I’m having a problem with Gradle detecting duplicate resources in my classpath when running the build
task. I’m hoping you can explain to me why, and what I can do to fix it.
Firstly, the project I’m dealing with can be found here: GitHub - Skater901/wc3connect-notification-bot: A bot for notifying when a game is hosted on w3cconnect
There are four problems that occur when running ./gradlew clean build
.
The first problem is:
* What went wrong:
Execution failed for task ':processResources'.
> Entry META-INF/services/ch.qos.logback.classic.spi.Configurator is a duplicate but no duplicate handling strategy has been set. Please refer to https://docs.gradle.org/8.5/dsl/org.gradle.api.tasks.Copy.html#org.gradle.api.tasks.Copy:duplicatesStrategy for details.
This can be fixed by commenting out the following line in the main build.gradle.kts
file: wc3connect-notification-bot/build.gradle.kts at main · Skater901/wc3connect-notification-bot · GitHub
resources { srcDir("src/main/resources") }
After commenting that line out, the second problem is:
* What went wrong:
Execution failed for task ':processTestResources'.
> Entry fixtures/wc3connect/games.json is a duplicate but no duplicate handling strategy has been set. Please refer to https://docs.gradle.org/8.5/dsl/org.gradle.api.tasks.Copy.html#org.gradle.api.tasks.Copy:duplicatesStrategy for details.
This can be fixed by commenting out the following line in the main build.gradle.kts
file: wc3connect-notification-bot/build.gradle.kts at main · Skater901/wc3connect-notification-bot · GitHub
resources { srcDir("src/test/resources") }
After commenting that line out, the third problem is:
* What went wrong:
Execution failed for task ':discord-module:processResources'.
> Entry META-INF/services/au.com.skater901.wc3connect.NotificationModule is a duplicate but no duplicate handling strategy has been set. Please refer to https://docs.gradle.org/8.5/dsl/org.gradle.api.tasks.Copy.html#org.gradle.api.tasks.Copy:duplicatesStrategy for details.
This can be fixed by commenting out the following line in the discord-module/build.gradle.kts
file: wc3connect-notification-bot/discord-module/build.gradle.kts at main · Skater901/wc3connect-notification-bot · GitHub
resources { srcDir("src/main/resources") }
Finally, after commenting out that line, the fourth problem is:
> Task :test
JdbiChannelNotificationDAOITCase > initializationError FAILED
liquibase.exception.CommandExecutionException at CommandScope.java:258
Caused by: liquibase.exception.ChangeLogParseException at XMLChangeLogSAXParser.java:128
Caused by: java.io.IOException at ResourceAccessor.java:255
It’s not really clear from the console output, but the error is Liquibase complaining that it detected two migrations.xml
files in the class path; one in build/resources/main
, and one in build/libs/wc3connect-notification-bot-1.0-SNAPSHOT.jar
. This can be fixed by commenting out the following line in the main build.gradle.kts
file: wc3connect-notification-bot/build.gradle.kts at main · Skater901/wc3connect-notification-bot · GitHub
runtimeOnly(project(":discord-module")) // TODO make run depend on compile
Now, the first three problems are just things I’m curious about; I can fix these problems simply by removing the mentioned lines from the Gradle build files. The fourth one is the real problem; I need the discord-module
to be a runtime dependency of the main project, but having it as a runtime dependency is stopping my database integration tests from running.
So my questions are:
1: Why does explicitly specifying the resources folder cause Gradle to detect my resource files multiple times?
2: Why does adding the discord-module
as a runtime dependency of the main project cause the migrations.xml
file to show up twice in the classpath?
Thanks!