Status Update
Comments
uc...@google.com <uc...@google.com> #2
Do you have a repro project that you could share with us?
There should be no need to excluding any dependencies: we automatically remove them from the test APK if they are in the main APK.
There should be no need to excluding any dependencies: we automatically remove them from the test APK if they are in the main APK.
sp...@google.com <sp...@google.com> #3
This seems to work in accordance with the meaning of "Compile only". Do resources load properly if you change dependency to "Implementation" or "Unit Test Implementation"?
2s...@gmail.com <2s...@gmail.com> #4
"compile" is indeed deprecated. I will replace it with "implementation". Thanks for the hint.
But reading Gradle docshttps://docs.gradle.org/current/userguide/java_library_plugin.html#sec:java_library_separation I didn't find anything that would explain why "compile" dependency classes are added to test runner classpath but "compile" dependency resources are not.
In fact Gradle adds "compile" resources to classpath when running tests. That's why `gradle check` finishes successfully.
I believe Android Studio test runner should do the same.
But reading Gradle docs
In fact Gradle adds "compile" resources to classpath when running tests. That's why `gradle check` finishes successfully.
I believe Android Studio test runner should do the same.
sp...@google.com <sp...@google.com> #5
"compile" in https://docs.gradle.org/current/userguide/userguide_single.html#sec:java_plugin_and_dependency_management has a somewhat ambiguous description - "Compile time dependencies". By contrast, the description of "compileOnly" is much more clear - "Compile time only dependencies, not used at runtime".
sp...@google.com <sp...@google.com> #6
"compile" is supported only for compatibility with Gradle 3. Projects using Gradle 4 should use one of the scopes selectable in File > Project Structure > Dependencies.
sp...@google.com <sp...@google.com> #7
Marking obsolete since the "Implementation" and "Unit Test Implementation" scopes behave as expected and the "Compile" scope should not be used with Gradle 4.
2s...@gmail.com <2s...@gmail.com> #8
This issue was reported for Gradle 3.3.
And since you provide compatibility with Gradle 3 the "compile" behavior should be fixed to work the same as in Gradle.
Moreover, as I've just figured out "compile" is only deprecated for Java library plugin (to control precisely which dependencies are "exported"). Java plugin still supports "compile" scope in Gradle 4. And it's not deprecated.
In my case "compile" dependency is in the Android application module (app). Not in the Java library module (icu4j).
"compile" and "compileOnly" are two different scopes. And while "compileOnly" indeed is not expected to be on the classpath at runtime, "compile" is. Check the diagram on the page you linked to.
"runtime" extends (includes) "compile" and "testRuntime" extends "runtime". Test task uses "testRuntime". Therefore "compile" dependencies are supposed to be on the classpath when running tests.
And since you provide compatibility with Gradle 3 the "compile" behavior should be fixed to work the same as in Gradle.
Moreover, as I've just figured out "compile" is only deprecated for Java library plugin (to control precisely which dependencies are "exported"). Java plugin still supports "compile" scope in Gradle 4. And it's not deprecated.
In my case "compile" dependency is in the Android application module (app). Not in the Java library module (icu4j).
"compile" and "compileOnly" are two different scopes. And while "compileOnly" indeed is not expected to be on the classpath at runtime, "compile" is. Check the diagram on the page you linked to.
"runtime" extends (includes) "compile" and "testRuntime" extends "runtime". Test task uses "testRuntime". Therefore "compile" dependencies are supposed to be on the classpath when running tests.
sp...@google.com <sp...@google.com>
sp...@google.com <sp...@google.com> #9
According to Tor, "Compile" should be treated the same as "API". If it is not, it is likely the problem with how Android model is set up. Giving to Alex to investigate.
al...@google.com <al...@google.com>
ls...@google.com <ls...@google.com> #10
Indeed resources from java libraries are not being added to the classpath.
I have a fix pending review.
I have a fix pending review.
Description
Build #AI-162.3764568, built on February 24, 2017
Version of Gradle Plugin: 162.2228.14
Version of Gradle: 3.3
JRE: 1.8.0_112-release-b06 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
OS: Windows 10 x64
Steps to Reproduce:
I have a project with two modules: 'app' with Android application and 'icu4j' with a Java library.
The 'app' module has a compile dependency on 'icu4j':
compile project(':icu4j')
When I run a unit test in the 'app' module only 'icu4j' classes are added to the classpath (icu4j/build/classes/main) but not resources (icu4j/build/resources/main).
And the test then fails when one of the library classes tries to load the library resource file:
MissingResourceException: Could not find the bundle com/ibm/icu/impl/data/icudt58b/translit/root
When I run `gradle check` all the tests run fine.