This message was deleted.
# community-support
s
This message was deleted.
k
I have a
shared-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:
Copy code
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)
The
shared-utils
module `build.gradle.kts`:
Copy code
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`:
Copy code
dependencies {
    implementation(project(path = ":shared-utils", configuration = "shadow"))
}
Gradle (from the project dependency) adds both the main sources, and the jar from libs.
Code written in
shared-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)
Any help would be greatly appreciated. The goal is just to have one module with shaded and relocated libraries be shaded in another module. i.e.: •
api
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.