Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid dependency resolution at configuration time + only depend on compileUnitTest tasks #52

Merged
merged 2 commits into from
Feb 1, 2019

Conversation

drewhannay
Copy link

No description provided.

Drew Hannay added 2 commits January 28, 2019 11:03
Previously, the "unmock" configuration was resolved and
the robolectric dependency was downloaded at Gradle
configuration time, which would happen for ANY Gradle
invocation rather than only when the unmock task was
being run.

With this change, the default robolectric jar is
specified using Gradle's default dependency API so
we don't need to manually check the size of the configuration
and add it. We also pass the configuration FileCollection
to the task instead of passing the resolved file, which
lets resolution happen at task execution time.

Using the FileCollection#getSingleFile() API also gives
a much nicer error message if the user tries to add
multiple dependencies to the "unmock" configuration.
Previously we said to do a clean build or clear Gradle
caches, which wouldn't have actually fixed the problem.
Now the error (which comes from Gradle) explicitly says
that there should only be one dependency added to the
"unmock" configuration.
Previously the unmock tasks were added to every "compile"
task, which meant it would run even when compiling non-test
source code. Now it will only depend on the tasks that
compile JVM unit test code, not production code or androidTest
code.

We could potentially do even better and depend on the specific
tasks that compile JVM unit tests by depending on AGP and getting
a reference to the tasks explicitly instead of with a regex.
Depending on AGP, however, is kind of painful for consumers though,
since we would need unmock to update AGP in a timely manner when
new versions are released.
@drewhannay drewhannay mentioned this pull request Jan 30, 2019
@bjoernQ bjoernQ merged commit 8c01a92 into bjoernQ:master Feb 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants