Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save vrudikov/d043778f5236d309b890b9413c9e71b9 to your computer and use it in GitHub Desktop.
Save vrudikov/d043778f5236d309b890b9413c9e71b9 to your computer and use it in GitHub Desktop.
Gradle multi-project build where project2's test classes depend on project1's test classes
.
├── build.gradle
├── project1
│ ├── build.gradle
│ └── src
│ └── test
│ └── java
│ └── sample
│ └── Foo.java
├── project2
│ ├── build.gradle
│ └── src
│ └── test
│ └── java
│ └── sample
│ └── BarTest.java
└── settings.gradle
== BarTest.java
package sample;
import org.junit.Test;
import static org.junit.Assert.*;
public class BarTest {
@Test
public void doit() {
assertNotNull(new Foo());
}
}
== build.gradle (project1)
task testJar(type: Jar) {
classifier 'test'
from sourceSets.test.output
}
== build.gradle (project2)
dependencies {
compile project(':project1')
testCompile files(project(':project1').testJar.archivePath)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment