Missing dependency (Hamcrest) in compile scope


(Marcel Overdijk) #1

I have a project that depends on an internal jar that contains a compile scoped dependency for Hamcrest.
The pom of the library contains this like:

<dependency>
  <groupId>org.hamcrest</groupId>
  <artifactId>hamcrest-core</artifactId>
  <scope>compile</scope>
  <exclusions>
    <exclusion>
      <artifactId>commons-logging</artifactId>
      <groupId>commons-logging</groupId>
    </exclusion>
  </exclusions>
</dependency>
<dependency>
  <groupId>org.hamcrest</groupId>
  <artifactId>hamcrest-core</artifactId>
  <scope>test</scope>
  <exclusions>
    <exclusion>
      <artifactId>commons-logging</artifactId>
      <groupId>commons-logging</groupId>
    </exclusion>
  </exclusions>
</dependency>

The project also contains e.g. junit and mockito (with scope compileTest) which also have dependency for Hamcrest (albeit testCompile).

Now my own project does only include Hamcrest for testCompile scopt but not for compile scope.

I was expecting that it would include Hamcrest for compile scope as it would pick ip up as transitive dependency form my internal jar.


(Marcel Overdijk) #2

While creating this post I noticed the internal jar had the Hamcrest dep twice, once for compile and once for compileTest.
I guess Gradle just took the last entry.