Transitive runtime dependencies are part of compile configuration

(Nils Hendricks) #1

Gradle Version: 3.1
Operating System and JVM version: Windows 7
Is this a regression? If yes, which version of Gradle do you know it last worked for? No

If I declare a compile dependency (e.g. to io.reactivex:rxnetty:0.4.19) I see that gradle also puts all transitive runtime dependencies into the compile configuration (in this case for example io.reactivex:rxjava:1.0.17). Isnt this a bug? Can i configure gradle to be “scope-safe” and only put transitive compile dependencies into my compile scope?


apply plugin: 'java'

dependencies {
compile 'io.reactivex:rxnetty:0.4.19'

Here is the output of gradlew.bat dependencies --configuration compile


Root project

compile - Dependencies for source set 'main'.
\--- io.reactivex:rxnetty:0.4.19
     +--- io.reactivex:rxjava:1.0.17
     +--- io.netty:netty-codec-http:4.1.5.Final
     |    \--- io.netty:netty-codec:4.1.5.Final
     |         \--- io.netty:netty-transport:4.1.5.Final
     |              +--- io.netty:netty-buffer:4.1.5.Final
     |              |    \--- io.netty:netty-common:4.1.5.Final
     |              \--- io.netty:netty-resolver:4.1.5.Final
     |                   \--- io.netty:netty-common:4.1.5.Final
     +--- io.netty:netty-handler:4.1.5.Final
     |    +--- io.netty:netty-buffer:4.1.5.Final (*)
     |    +--- io.netty:netty-transport:4.1.5.Final (*)
     |    \--- io.netty:netty-codec:4.1.5.Final (*)
     +--- io.netty:netty-transport-native-epoll:4.1.5.Final
     |    +--- io.netty:netty-common:4.1.5.Final
     |    +--- io.netty:netty-buffer:4.1.5.Final (*)
     |    \--- io.netty:netty-transport:4.1.5.Final (*)
     \--- org.slf4j:slf4j-api:1.7.6

(*) - dependencies omitted (listed previously)


Total time: 4.225 secs

(Lance Java) #2

You could do this:

configurations {
   compileNonTrans { transitive = false } 
   compile.extendsFrom compileNonTrans

dependencies {
   compileNonTrans 'io.reactivex:rxnetty:0.4.19'

(davidmichaelkarr) #3

I noticed that the OP referred to getting unexpected RUNTIME dependencies, not compile dependencies. That would truly be annoying, if transitive runtime dependencies resulted in compile dependencies. However, I just checked the latest POM for that main artifact, and “rxjava” is clearly a “compile” dependency, not “runtime”. I am looking at the latest version of it, 0.5.2, not 0.4.19, so it’s possible it used to be “runtime”, but that seems unlikely.

(Nils Hendricks) #4


(davidmichaelkarr) #5

Guess I’ll shut up, then.

(Nils Hendricks) #6

I guess you agree then that this looks like a bug? If i have code which needs classes from io.reactivex:rxjava it compiles with gradle but the compile fails if i try to compile it with maven (which is what i expected) …