Take a look at the following sentence from the Gradle 2.12 release notes regarding the new compileOnly configuration (my emphasis):
Now you can declare dependencies that will only be used at compile time in conjunction with the Java plugin .
So, the Java Gradle plugin is a component that we need to consider when answering this question. We can find the compileOnly configuration declared in the Java Gradle plugin source code for new versions.
However, Android Gradle plugins do not redirect the Java Gradle plugin . In fact, I think Android plugins are a kind of "frankenplugin", with some features borrowed but not inherited from the Java plugin. The following pieces of source code support this idea.
From the base class of the Android plugin :
project.apply plugin: JavaBasePlugin
Android Gradle plugins therefore include functionality from the underlying Java Gradle plugin , rather than from the full Java Gradle plugin . In addition, there is an explicit check that the full Java Gradle plugin is not used with the Android Gradle plugin:
Based on this information, I assume that compileOnly just wasn't manually ported from the Java Gradle plugin to the Android Gradle plugin. It probably wonβt appear until we get the Android Gradle plugin with the minimum version of Gradle set to 2.12 or higher.
stkent
source share