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>
You can do
dependencies {
compile project(':shared-module')
testCompile project(path: ':shared-module', configuration: 'testRuntime')
}
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.