troymass
troymass

Reputation: 1062

Gradle dependency project test-jar

I have a multi-module gradle project and I want to make use of some of the test classes from the shared module in my dependent module.

dependencies {
    compile project(':shared-module')

    testCompile project(':shared-module'), classifier: 'test-jar'
}

The first dependency works, but the testCompile dependency does not work. I cannot seem to find the syntax for it. The maven equivalent would be:

<dependency>
    <groupId>${project.groupId}</groupId>
    <artifactId>shared-module</artifactId>
    <version>${project.version}</version>
    <type>test-jar</type>
    <scope>test</scope>
</dependency>

Upvotes: 2

Views: 4232

Answers (2)

lance-java
lance-java

Reputation: 27996

You can do

dependencies {
    compile project(':shared-module')
    testCompile project(path: ':shared-module', configuration: 'testRuntime') 
} 

Upvotes: 2

lance-java
lance-java

Reputation: 27996

You could use the nebula test jar plugin

Note Nebula have deprecated this plugin as they believe test utilities should live in their own project. I tend to agree with them

Upvotes: 0

Related Questions