Created
March 27, 2014 16:33
-
-
Save andy-berry-dev/9811808 to your computer and use it in GitHub Desktop.
Config to add a test-integration source set in a Gradle build
This file contains hidden or 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
if (project.plugins.hasPlugin(JavaPlugin)) { | |
configurations { | |
testIntegrationCompile { | |
extendsFrom testCompile | |
} | |
testIntegrationRuntime { | |
extendsFrom testRuntime | |
} | |
} | |
sourceSets { | |
testIntegration { | |
def actualName = "test-integration" // needed because 'name' is readonly and cannot have dashes | |
java { | |
srcDirs = ["src/${actualName}/java"] | |
} | |
resources { | |
srcDirs = ["src/${actualName}/resources"] | |
} | |
output.classesDir = project.buildDir.path+'/classes/'+actualName | |
output.resourcesDir = project.buildDir.path+'/classes/'+actualName | |
compileClasspath = main.output + project.configurations.testIntegrationCompile | |
runtimeClasspath = main.output + output + project.configurations.testIntegrationRuntime | |
} | |
} | |
compileTestIntegrationJava.dependsOn classes | |
task testIntegration(type: Test, dependsOn: compileTestIntegrationJava) { | |
// we need to do this because Gradle complains it cant cast a LinkedHashSet -> List | |
def srcDirs_linkedHashSet = project.sourceSets.testIntegration.java.srcDirs; | |
def srcDirs_list = new ArrayList<File>(); | |
srcDirs_linkedHashSet.each { file -> | |
srcDirs_list.add(file) | |
} | |
testSrcDirs = srcDirs_list | |
classpath = project.sourceSets.testIntegration.runtimeClasspath | |
testClassesDir = project.sourceSets.testIntegration.output.classesDir | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment