Skip to content
This repository has been archived by the owner on Jan 17, 2020. It is now read-only.

Fix resolved artifacts over android-gradle-plugin 3.0 #89

Merged
merged 2 commits into from Jun 26, 2018

Conversation

litmon
Copy link
Contributor

@litmon litmon commented Jun 14, 2018

When I execute ./gradlew checkLicenses before some assemble tasks in my project, it failed.

13:47:45 :app:checkLicenses FAILED
13:47:45 
13:47:45 FAILURE: Build failed with an exception.
13:47:45 
13:47:45 * Where:
13:47:45 Build file /workspace/project/app/build.gradle' line: 560
13:47:45 
13:47:45 * What went wrong:
13:47:45 Execution failed for task ':app:checkLicenses'.
13:47:45 > Could not resolve all dependencies for configuration ':app:apiCopy'.
13:47:45    > Could not resolve com.jakewharton.timber:timber:4.6.1.
13:47:45      Required by:
13:47:45          project :app
13:47:45       > Could not resolve com.jakewharton.timber:timber:4.6.1.
13:47:45          > Could not get resource 'https://jcenter.bintray.com/com/jakewharton/timber/timber/4.6.1/timber-4.6.1.pom'.
13:47:45             > java.lang.reflect.UndeclaredThrowableException (no error message)

However It succeeded after assemble task.

I fixed the issue to use resolvedConfiguration.lenientConfiguration.artifacts instead of resolvedConfiguration.resolvedArtifacts.
Because resolvedArtifacts "probably" could be allowed access after artifacts resolved. (I could not understand why it run correctly...)
https://docs.gradle.org/current/javadoc/org/gradle/api/artifacts/ResolvedConfiguration.html

@litmon litmon self-assigned this Jun 14, 2018
@litmon
Copy link
Contributor Author

litmon commented Jun 14, 2018

test this please

@KazuCocoa
Copy link
Contributor

https://docs.gradle.org/current/javadoc/org/gradle/api/artifacts/LenientConfiguration.html#getArtifacts--
The method only gets artefacts can be resolved. If something fails, the method ignores them. So, only succeeded artefacts remain..

@litmon
Copy link
Contributor Author

litmon commented Jun 15, 2018

https://docs.gradle.org/current/javadoc/org/gradle/api/artifacts/LenientConfiguration.html#getUnresolvedModuleDependencies--
this method returns unresolved dependencies, so I will try to add the validation it is empty.

@litmon
Copy link
Contributor Author

litmon commented Jun 23, 2018

When I tried LenientConfiguration.unresolvedModuleDependencies(), the returned object contains sub module project.
Sub module dependencies already got so I will ignore unresolvedModuleDependencies.

And I noticed that workaround for android-gradle-plugin 3.0( #85 ) is not necessary after using LenientConfiguration.artifacts.
I also noticed current master revision causes that ./gradlew checkLicenses succeed but ./gradlew :example:checkLicenses fail because missing libraries in licenses.yml.
So I will revert PR #85

@litmon litmon force-pushed the fix/resolve_configuration branch from 1dea180 to 93c172f Compare June 23, 2018 21:19
@KazuCocoa
Copy link
Contributor

🆒
We'll no longer need the workaround.

@litmon litmon merged commit d79e54c into master Jun 26, 2018
@litmon litmon deleted the fix/resolve_configuration branch June 26, 2018 02:47
@ghost
Copy link

ghost commented Jun 26, 2018

:note:

We should avoid https://stackoverflow.com/questions/45679847/android-studio-3-0-compile-issue-cannot-choose-between-configurations workaround, setting default like implementation project(path: ':example-dep', configuration: 'default').

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants