Parallel task execution in multiproject build
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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