unity-jar-resolver
unity-jar-resolver copied to clipboard
[Android] (Force) Resolve doesn't refresh the dependncies.
When (force) resolving the Android dependencies, the (global) gradle cache is being used and not refreshed.
I've come across this issue when we've rebuilt one of our own in-house android plugins and changed the dependency of this plugin, without bumping the version of this plugin.
I'm aware it's not a good practice, to not bump the version, but this can also occur in SNAPSHOT builds, which wouldn't change versions and actually serve the purpose of being (re)built many times over.
Gradle has support to refresh the dependencies when adding the argument --refresh-dependencies, perhaps this argument should be added when (force) resolving for android?
(I think this can be accomplished by changing https://github.com/googlesamples/unity-jar-resolver/blob/master/source/PlayServicesResolver/src/GradleResolver.cs#L498 and use "--refresh-dependencies" instead of null)
This issue does not seem to follow the issue template. Make sure you provide all the required information.
Hi @JSC-Sparkling could you confirm if this happens when trying to build another plugin? Also, please provide the steps how you encountered this issue. Thanks!
@paulinon this issue also occurs when building other plugins.
Steps to reproduce it are as following:
- Create an aar library with a dependency on another library (doesn't really matter which one, as long as it's declared in the pom file)
- Deploy this aar library (including its pom file) to a maven repository
- Add this library as a dependency to a unity project (using the jar resolver's XML format)
- Ensure the jar resolver settings are set to NOT patch/change the main gradle template
- Run jar resolver (you should get the library + its dependency added to the Plugins/Android folder)
- Go back to the library and change the dependency to a different library (still doesn't matter, as long as it's a different one than the one used in step 1)
- Build/Deploy the arr library (including its pom file) without changing its version (you can change/bump versionCode) to the same maven repository used in step 2
- Go back to Unity and (force) resolve again.
- Notice that the library itself has changed/updated as expected, but its dependency hasn't changed. The old/previous dependency (from step 1) is still being added/used in the project rather than the new dependency (from step 6)
This issue occurs because the dependency file (pom) is being cached by gradle. Thus it still assumes/uses the old pom file when resolving the dependencies of the library. To fix it, the --refresh-dependencies can/should be used (as I've explained in the original post)
@JSC-Sparkling your suggestion seems fine. Feel free to send us a pull request, you'll need to make sure that flag is only set when doing a "force resolve" though which looks like it will take a bit of plumbing since force resolve currently just deletes all libraries added to the project.