Slackbot
08/31/2024, 11:13 PMKamikazeJAM
08/31/2024, 11:13 PMshared-utils module which has an implementation dependency for snakeyaml, and it relocates the snakeyaml package to avoid conflicts.
shared-utils is producing an uber-jar with snakeyaml relocated.
My other module shared-jar needs to use `shared-utils`so it has:
implementation(project(path = ":shared-utils", configuration = "shadow"))
This makes the relocated version of snakeyaml available in IntelliJ. (good)
However, shared-utils has a class (YamlUtil) that returns Yaml (a snakeyaml class), and when used in shared-jar it produces an IntelliJ error: Cannot access org. yaml. snakeyaml. Yaml
Gradle is still able to compile it, because at compile time YamlUtil comes from shadow, but it's disruptive to have that error.
I believe this is because the shadow plugin adds both the main sources, and the build/libs file to the IntelliJ project structure as indexed dependencies. (If the main sources were not there, it would be fine. However, gradle is always re-adding them because of the project dependency)KamikazeJAM
08/31/2024, 11:15 PMshared-utils module `build.gradle.kts`:
dependencies {
// Unique dependencies for this module
implementation("org.yaml:snakeyaml:2.2")
}
tasks {
publish.get().dependsOn(build.get())
build.get().dependsOn(shadowJar)
shadowJar {
relocate("org.yaml.snakeyaml", "my.snakeyaml")
}
}
The shared-jar module `build.gradle.kts`:
dependencies {
implementation(project(path = ":shared-utils", configuration = "shadow"))
}KamikazeJAM
08/31/2024, 11:17 PMKamikazeJAM
08/31/2024, 11:18 PMshared-jar that uses libraries from shared-utils is indexed from the main sources, not the shaded jar. Resulting in IntelliJ errors
(The only snakeyaml available in the IntelliJ classpath is the relocated one, from the shadow configuration)KamikazeJAM
08/31/2024, 11:24 PMapi shades snakeyaml (relocated) -> produces uber-jar containing: api files & snakeyaml
• jar shades api -> produces uber-jar containing: with api files, jar files, & libraries from api (snakeyaml)
I've tried a few strategies in the last 24 hours but can't see to figure it out.