Project dependencies transitivity

Hi. I have a following project structure: A, B requires A to compile, and C requires B to compile. C is a webapp, where B is defined as a compile dependency. To my surprise, A is not on the runtime classpath for some reason. Why is that? I need to explicitly add a runtime dependency on on A. Are such dependencies not transitive? I.e., as C compile-depend on B, A must also be among its dependencies, if not compile, then runtime. What is strange, project A and all it depends on is on the testRuntime classpath, for example.

wujek

How exactly did you verify that A is not on C’s runtime class path? I’d be surprised if it wasn’t.

I issue gradle dependencies in the web project. Here is my output (for runtime :

runtime - Classpath for running the compiled main classes.
+--- social:api:0.0.1-SNAPSHOT [default]
|
  \--- org.codehaus.groovy:groovy:2.0.0 [default]
|
       +--- antlr:antlr:2.7.7 [compile,master,runtime]
|
       +--- org.ow2.asm:asm-tree:4.0 [compile,master,runtime]
|
       |
  \--- org.ow2.asm:asm:4.0 [compile,master,runtime]
|
       +--- org.ow2.asm:asm-commons:4.0 [compile,master,runtime]
|
       |
  \--- org.ow2.asm:asm-tree:4.0 [compile,master,runtime] (*)
|
       +--- org.ow2.asm:asm:4.0 [compile,master,runtime] (*)
|
       +--- org.ow2.asm:asm-util:4.0 [compile,master,runtime]
|
       |
  \--- org.ow2.asm:asm-tree:4.0 [compile,master,runtime] (*)
|
       \--- org.ow2.asm:asm-analysis:4.0 [compile,master,runtime]
|
            \--- org.ow2.asm:asm-tree:4.0 [compile,master,runtime] (*)
+--- social:wiring-guice:0.0.1-SNAPSHOT [default]
|
  \--- org.codehaus.groovy:groovy:2.0.0 [default] (*)
+--- org.apache.wicket:wicket:1.5.7 [default]
|
  +--- org.apache.wicket:wicket-core:1.5.7 [compile,master,runtime]
|
  |
  +--- org.slf4j:slf4j-api:1.6.1 [compile,master,runtime]
|
  |
  +--- org.apache.wicket:wicket-util:1.5.7 [compile,master,runtime]
|
  |
  |
  \--- org.slf4j:slf4j-api:1.6.1 [compile,master,runtime] (*)
|
  |
  \--- org.apache.wicket:wicket-request:1.5.7 [compile,master,runtime]
|
  |
       +--- org.slf4j:slf4j-api:1.6.1 [compile,master,runtime] (*)
|
  |
       \--- org.apache.wicket:wicket-util:1.5.7 [compile,master,runtime] (*)
|
  \--- org.slf4j:slf4j-api:1.6.1 [compile,master,runtime] (*)
+--- org.apache.wicket:wicket-guice:1.5.7 [default]
|
  +--- org.apache.wicket:wicket-core:1.5.7 [compile,master,runtime] (*)
|
  +--- org.slf4j:slf4j-api:1.6.1 [compile,master,runtime] (*)
|
  \--- org.apache.wicket:wicket-ioc:1.5.7 [compile,master,runtime]
|
       +--- org.apache.wicket:wicket-core:1.5.7 [compile,master,runtime] (*)
|
       \--- org.slf4j:slf4j-api:1.6.1 [compile,master,runtime] (*)
\--- org.codehaus.groovy:groovy:2.0.0 [default] (*)
    testRuntime - Classpath for running the compiled test classes.
+--- social:api:0.0.1-SNAPSHOT [default]
|
  \--- org.codehaus.groovy:groovy:2.0.0 [default]
|
       +--- antlr:antlr:2.7.7 [compile,master,runtime]
|
       +--- org.ow2.asm:asm-tree:4.0 [compile,master,runtime]
|
       |
  \--- org.ow2.asm:asm:4.0 [compile,master,runtime]
|
       +--- org.ow2.asm:asm-commons:4.0 [compile,master,runtime]
|
       |
  \--- org.ow2.asm:asm-tree:4.0 [compile,master,runtime] (*)
|
       +--- org.ow2.asm:asm:4.0 [compile,master,runtime] (*)
|
       +--- org.ow2.asm:asm-util:4.0 [compile,master,runtime]
|
       |
  \--- org.ow2.asm:asm-tree:4.0 [compile,master,runtime] (*)
|
       \--- org.ow2.asm:asm-analysis:4.0 [compile,master,runtime]
|
            \--- org.ow2.asm:asm-tree:4.0 [compile,master,runtime] (*)
+--- social:wiring-guice:0.0.1-SNAPSHOT [default]
|
  +--- social:api:0.0.1-SNAPSHOT [default] (*)
|
  +--- org.codehaus.groovy:groovy:2.0.0 [default] (*)
|
  +--- social:core-neo4j:0.0.1-SNAPSHOT [default]
|
  |
  +--- social:api:0.0.1-SNAPSHOT [default] (*)
|
  |
  +--- org.codehaus.groovy:groovy:2.0.0 [default] (*)
|
  |
  +--- org.neo4j:neo4j-kernel:1.8.M06 [default]
|
  |
  |
  \--- org.apache.geronimo.specs:geronimo-jta_1.1_spec:1.1.1 [compile,master,runtime]
|
  |
  +--- org.neo4j:neo4j-lucene-index:1.8.M06 [default]
|
  |
  |
  +--- org.neo4j:neo4j-kernel:1.8.M06 [compile,runtime,master] (*)
|
  |
  |
  \--- org.apache.lucene:lucene-core:3.5.0 [compile,master,runtime]
|
  |
  \--- com.google.guava:guava:12.0.1 [default]
|
  |
       \--- com.google.code.findbugs:jsr305:1.3.9 [compile,master,runtime]
|
  +--- com.google.inject:guice:3.0 [default]
|
  |
  +--- javax.inject:javax.inject:1 [compile,master,runtime]
|
  |
  \--- aopalliance:aopalliance:1.0 [compile,master,runtime]
|
  +--- com.google.inject.extensions:guice-multibindings:3.0 [default]
|
  |
  \--- com.google.inject:guice:3.0 [compile,runtime,master] (*)
|
  \--- cglib:cglib:2.2.2 [default]
+--- org.apache.wicket:wicket:1.5.7 [default]
|
  +--- org.apache.wicket:wicket-core:1.5.7 [compile,master,runtime]
|
  |
  +--- org.slf4j:slf4j-api:1.6.1 [compile,master,runtime]
|
  |
  +--- org.apache.wicket:wicket-util:1.5.7 [compile,master,runtime]
|
  |
  |
  \--- org.slf4j:slf4j-api:1.6.1 [compile,master,runtime] (*)
|
  |
  \--- org.apache.wicket:wicket-request:1.5.7 [compile,master,runtime]
|
  |
       +--- org.slf4j:slf4j-api:1.6.1 [compile,master,runtime] (*)
|
  |
       \--- org.apache.wicket:wicket-util:1.5.7 [compile,master,runtime] (*)
|
  \--- org.slf4j:slf4j-api:1.6.1 [compile,master,runtime] (*)
+--- org.apache.wicket:wicket-guice:1.5.7 [default]
|
  +--- org.apache.wicket:wicket-core:1.5.7 [compile,master,runtime] (*)
|
  +--- org.slf4j:slf4j-api:1.6.1 [compile,master,runtime] (*)
|
  \--- org.apache.wicket:wicket-ioc:1.5.7 [compile,master,runtime]
|
       +--- org.apache.wicket:wicket-core:1.5.7 [compile,master,runtime] (*)
|
       \--- org.slf4j:slf4j-api:1.6.1 [compile,master,runtime] (*)
+--- org.codehaus.groovy:groovy:2.0.0 [default] (*)
+--- org.testng:testng:6.5.2 [default]
|
  +--- org.beanshell:bsh:2.0b4 [compile,master,runtime]
|
  +--- com.beust:jcommander:1.12 [compile,master,runtime]
|
  \--- org.yaml:snakeyaml:1.6 [compile,master,runtime]
+--- org.hamcrest:hamcrest-core:1.2.1 [default]
+--- org.hamcrest:hamcrest-library:1.2.1 [default]
|
  \--- org.hamcrest:hamcrest-core:1.2.1 [compile,runtime,master] (*)
\--- org.mockito:mockito-core:1.9.0 [default]
     \--- org.objenesis:objenesis:1.0 [compile,master,runtime]

Please notice that in testRuntime, social:wiring-guice has a (transitive) dependency on social:core-neo4j, wheres in runtime it doesn’t. This is not 100% reproducible, though. Sometimes the module ist there. Something very strange is going on with my build right now…

This seems to have something to do with the fact that I was doing stuff on the command line, but IDEA, with the same project open, was running as well. Now that I stopped IDEA, the output is as expected (i.e., project A is transitively on the runtime classpath) - I guess when I cleand on the cp, IDEA kicked in and tried to build, and somehow prevented subsequent command line calls from working properly…

wujek