gradle / gradle

Adaptable, fast automation for all
https://gradle.org
Apache License 2.0
16.67k stars 4.66k forks source link

"maven-publish" plugin writes wrong dependency to pom file for project using the "AGP-KMP" plugin #30112

Open scott-pollom opened 1 month ago

scott-pollom commented 1 month ago

Current Behavior

AGP has recently created a new "com.android.kotlin.multiplatform.library" plugin. I'll call it the "AGP-KMP" plugin for short here. The "AGP-KMP" plugin is designed to be used instead of the "com.android.library" plugin in KMP libraries with android targets.

In the attached project, there are three sub-projects, all of which are KMP projects (i.e., they all apply the "org.jetbrains.kotlin.multiplatform" plugin):

Running ./gradlew publish publishes all three sub-projects to the testRepo directory.

The pom file for the oldKmpLib android artifact lists the artifactId for the dependency on oldKmpDependency correctly: <artifactId>oldKmpDependency-android</artifactId>. The pom file is located here: testRepo/com/example/oldKmpLib-android/1.0/oldKmpLib-android-1.0.pom

The problem is that the pom file for the newKmpLib android artifact lists the artifactId for the dependency on oldKmpDependency incorrectly (it adds a "-debug" at the end): <artifactId>oldKmpDependency-android-debug</artifactId>. The pom file is located here: testRepo/com/example/newKmpLib-android/1.0/newKmpLib-android-1.0.pom

Expected Behavior

The pom file for the newKmpLib android artifact should list the artifactId for the dependency on oldKmpDependency correctly as <artifactId>oldKmpDependency-android</artifactId>.

Context (optional)

The AndroidX team hit this issue when migrating their KMP libraries to the "AGP-KMP" plugin.

Steps to Reproduce

Repro project attached.

Running ./gradlew publish publishes all three sub-projects to the testRepo directory.

Gradle version

8.9

Build scan URL (optional)

No response

Your Environment (optional)

AGP version: 8.7.0-alpha03 Kotlin version: 1.9.24

scott-pollom commented 1 month ago

Repro project attached here

cobexer commented 1 month ago

This issue needs a decision from the team responsible for that area. They have been informed. Response time may vary.

big-guy commented 1 month ago

We think this is happening on the KMP side, but we'll follow up with JetBrains/OP