Skip to content

Instantly share code, notes, and snippets.

Created December 6, 2013 17:42
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save anonymous/7829021 to your computer and use it in GitHub Desktop.
Parallel task execution in multiproject build
apply plugin: 'java'
apply plugin: 'eclipse'
sourceCompatibility = 1.5
version = '1.0'
jar {
manifest {
attributes 'Implementation-Title': 'Gradle Quickstart', 'Implementation-Version': version
}
}
repositories {
mavenCentral()
}
dependencies {
compile group: 'commons-collections', name: 'commons-collections', version: '3.2'
testCompile group: 'junit', name: 'junit', version: '4.+'
}
project(':u'){
sourceSets
{
unitTest{
java
{
srcDir "$rootProject.projectDir/src/unit/java"
}
compileClasspath += test.compileClasspath
}
}
task unitTest(type: Test){
testClassesDir file("$rootProject.buildDir/classes/unitTest")
classpath = sourceSets.unitTest.output
include "org/gradle/PersonTest2.class"
outputs.upToDateWhen { false }
testResultsDir file("$rootProject.buildDir/results/u")
binResultsDir file("$rootProject.buildDir/bin/u")
testReportDir file("$rootProject.buildDir/reports/u")
workingDir file("$rootProject.buildDir")
ignoreFailures true
scanForTestClasses false
doLast{
// To see whether tests run in parallel
for(int i=0; i<10;i++){
sleep(1500)
println "from u $i"
}
}
}
}
project(':e'){
sourceSets
{
e2eTest{
java
{
srcDir "$rootProject.projectDir/src/e2e/java"
}
compileClasspath += test.compileClasspath
}
}
task e2eTest(type: Test){
testClassesDir file("$rootProject.buildDir/classes/e2eTest")
classpath = sourceSets.e2eTest.output
classpath.each{println it}
include "org/gradle/PersonTest1.class"
outputs.upToDateWhen { false }
workingDir file("$rootProject.buildDir")
testResultsDir file("$rootProject.buildDir/results/e")
binResultsDir file("$rootProject.buildDir/bin/e")
testReportDir file("$rootProject.buildDir/reports/e")
workingDir file("$rootProject.buildDir")
scanForTestClasses false
ignoreFailures true
doLast{
for(int i=0; i<10;i++){
sleep(1000)
println "from e $i"
}
}
}}
task x(dependsOn: [':u:unitTest', ':e:e2eTest', test])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment