I'm migrating an older Android library from jcenter to mavenCentral in light of their deprecation. All of the actual library modules are written in Java, but several of them have tests written in Kotlin.
Until upgrading (to AS 4.1.3, Gradle 6.8.3), the generated POM(s) never included a compilation dependency on the kotlin-stdlib
. Now it appears that applying the kotlin-android
plugin causes the generated POM to add it, even though the dependency is included as testImplementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.4.31"
.
<dependencies>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib</artifactId>
<version>1.4.31</version>
<scope>compile</scope>
</dependency>
</dependencies>
The question: Was the previously-generated POM wrong in that it should have included kotlin as a compilation dependency, even though it's only used for testing?
Or, do I have to do something special to exclude that "dependency" in this specific case? If so, how could I exclude it if generating the POM when defining the publication like:
afterEvaluate {
publishing {
publications {
release(MavenPublication) {
from components.release
....
pom {
name = ...
licenses { }
developers { }
scm { }
}
}
}
}
}
Or, is that not really a good option and I should just rewrite the tests in Java?
It's worth noting that removing the kotlin-android
plugin also removes it as a compilation dependency from the POM(s). It seems to have no effect on generating the AAR; it just prevents the tests from running.