[Gradle] Missing compile dependencies after being resolved

Answered

I have the following multiproject build:

project(":project1") {
  dependencies {
      compile "org.apache.geronimo.specs:geronimo-jms_1.1_spec:1.0"
  }
}

project(":project2") {
  dependencies {
      runtime "org.apache.geronimo.specs:geronimo-jms_1.1_spec:1.1.1"
  }
}

project(":project-tests") {
  dependencies {
      compile project(':project1')
      runtime project(':project2')
      compile 'junit:junit:4.11'
  }
}

  • The Project1 has a compile dependency on JMS 1.0.
  • The Project2 has a runtime dependency on JMS 1.1.1.
  • The Project-tests has a runtime dependency on Project2.


This is perfectly defined and it's easy to check using the Gradle command line:

$ ./gradlew project-tests:dependencies --configuration compile

Parallel execution with configuration on demand is an incubating feature.

:project-tests:dependencies

------------------------------------------------------------

Project :project-tests

------------------------------------------------------------

compile - Compile classpath for source set 'main'.

+--- project :project1

|    \--- org.apache.geronimo.specs:geronimo-jms_1.1_spec:1.0

\--- junit:junit:4.11

     \--- org.hamcrest:hamcrest-core:1.3


$ ./gradlew project-tests:dependencies --configuration runtime
Parallel execution with configuration on demand is an incubating feature.
:project-tests:dependencies

------------------------------------------------------------
Project :project-tests
------------------------------------------------------------

runtime - Runtime classpath for source set 'main'.
+--- project :project1
|    \--- org.apache.geronimo.specs:geronimo-jms_1.1_spec:1.0 -> 1.1.1
+--- junit:junit:4.11
|    \--- org.hamcrest:hamcrest-core:1.3
\--- project :project2
     \--- org.apache.geronimo.specs:geronimo-jms_1.1_spec:1.1.1

(*) - dependencies omitted (listed previously)





The issue:





The problem is in IntelliJ Idea when I make/build the project, a class in Project-tests, which is doing a import of a JMS class, fails complaining that the JMS package does not exist.

If I open the Module settings, I can see that the JMS dependency is actually a runtime dependency, not compile:

Screenshot-Settings.png

My configuration:

- Gradle 2.8

- IntelliJ IDEA 144.2925.2

I have attached to this post the project. Just import it to Idea as a Gradle project and execute a Make.

Is this a known issue?
Shall I raise it as an issue?



Attachment(s):
idea_wrong_classpath.zip

Please sign in to leave a comment.