googlesamples / unity-jar-resolver

Unity plugin which resolves Android & iOS dependencies and performs version management
Other
1.21k stars 336 forks source link

[Bug] How to resolve colission on kotlin_module file dependencies #673

Open vegaro opened 4 months ago

vegaro commented 4 months ago

[REQUIRED] Please fill in the following fields:

[REQUIRED] Please describe the issue here:

Our Unity plugin has a dependency on an android only library (com.revenuecat.purchases:purchases) that has a dependency on kotlinx-serialization-json. Which itself has a compile dependency on kotlinx-serialization-json-jvm. This is in the pom file of kotlinx-serialization-json.

<dependencies>
<dependency>
<groupId>org.jetbrains.kotlinx</groupId>
<artifactId>kotlinx-serialization-json-jvm</artifactId>
<version>1.4.1</version>
<scope>compile</scope>
</dependency>
</dependencies>

The thing is that it looks like both kotlinx-serialization-json-jvm and kotlinx-serialization-json share the same name for their kotlin_module. So when using the regular Android resolver (no mainTemplate.gradle), users of my plugin get this issue:

* What went wrong:
Execution failed for task ':unityLibrary:mergeDebugJavaResource'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.MergeJavaResWorkAction
   > 2 files found with path 'META-INF/kotlinx-serialization-json.kotlin_module' from inputs:

I see both files:

I was wondering if there's something built in the plugin to prevent this. From now I've recommended using mainTemplate.gradle resolution to use standard Maven dependencies or adding:

packagingOptions {
     resources.pickFirsts.add("META-INF/kotlinx-serialization-json.kotlin_module")
}

The fact that the dependency is <scope>compile</scope> in the pom also made me wonder if it is really necessary to download the .jar to compile the project. Isn't the kotlinx-serialization-json-1.4.1.jar already compiled code? Why do we need org.jetbrains.kotlinx.kotlinx-serialization-json-jvm-1.4.1.jar? This is probably me just misunderstanding how dependency resolution works in the context of Android development.

Thanks

google-oss-bot commented 4 months ago

This issue does not seem to follow the issue template. Make sure you provide all the required information.