Skip to content

Instantly share code, notes, and snippets.

Created December 9, 2013 10:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/7870525 to your computer and use it in GitHub Desktop.
Save anonymous/7870525 to your computer and use it in GitHub Desktop.
example for running Gradle multimodule tasks in parallel
apply plugin: 'java'
apply plugin: 'eclipse'
sourceCompatibility = 1.5
version = '1.0'
jar {
manifest {
attributes 'Implementation-Title': 'Gradle Quickstart', 'Implementation-Version': version
}
}
repositories {
flatDir(dir: "$projectDir/lib", name: 'external library directory')
}
dependencies {
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 + sourceSets.main.output + files("$rootProject.projectDir/lib/junit-4.8.2.jar")
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")
}
task printU(dependsOn: unitTest)<<{
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 + sourceSets.main.output + files("$rootProject.projectDir/lib/junit-4.8.2.jar")
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")
}
task printE(dependsOn: e2eTest)<<{
for(int i=0; i<10;i++){
sleep(1000)
println "from e $i"
}
}
}
task x(dependsOn: [':u:printU', ':e:printE'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment