When I make a new KMP library (generated by Android Studio) and upload it to my private repo (using the maven-publish plugin), I am unable to use it in another KMP app because of an exception saying there are cyclic dependencies. I don't understand what's wrong because the library has zero dependencies.
When I publish a pure Java/JVM library then it works and I can use it in another Java app. So it seems to me the cause of this issue is in Kotlin Multiplatform? I've been stuck for ages so any help is appreciated.
The full exception:
Detecting cycle in external variants for : my.group.id:my-artifact:0.0.1: my.group.id.example:shared-module:1.0.0 Dependency resolution has ignored the cycle to produce a result. It is recommended to resolve the cycle by upgrading one or more dependencies.
CodePudding user response:
The problem was these lines:
publications.withType<MavenPublication> {
artifactId = "annotations-kmp"
}
Changing the artifactId in this way caused kotlinMultiplatform publications to overwrite each other. The IDE can then still resolve the dependency making it look like it works. When running a Gradle build the KMP plugin will however check if the consumed dependency has sourcesets for all the sourcesets in the consumer. Because publications where overwritten, this is not the case and the build fails. The given exception is thus misleading unfortunately.