Dependency missing testCompile when already in compile with other classifier

When adding a dependency to compile and the test dependency to testCompile (only distinguished by classifier), the testCompile dependency is missing:

repositories {

apply plugin: 'java'

dependencies {
  compile(group: 'org.elasticsearch', name: 'elasticsearch', version: '2.0.0')

  testCompile(group: 'junit', name: 'junit', version: '4.12')
  testCompile(group: 'org.hamcrest', name: 'hamcrest-library', version: '1.3')
  testCompile(group: 'org.elasticsearch', name: 'elasticsearch', version: '2.0.0', classifier: 'tests')
  testCompile(group: 'org.apache.lucene', name: 'lucene-test-framework', version: '5.2.1')

gradlew dependencies misses elasticsearch-tests.jar from testCompile.

IntelliJ shows the correct dependencies and they can be used by a test:

import org.elasticsearch.test.ESIntegTestCase;
import org.junit.Test;

public class DummyTest extends ESIntegTestCase {
  public void shouldDoSomething() {

This was tested with gralde 1.12, 2.7 and 2.8.

Is there any way to get around that?

What I forgot: only seems to be a problem of gradlew dependencies. testCompile and running tests seems to work.

The dependency report only lists unique module dependencies, not artifacts. As far as dependency resolution is concerned, ‘elasticsearch’ and ‘elasticsearch-tests’ are the same module (same pom.xml). Essentially, gradle dependencies displays the resolved metadata whereas it is the resolved artifacts that are used to construct the classpath.