Skip to content

Instantly share code, notes, and snippets.

@thomaseizinger
Last active November 23, 2016 12:27
Show Gist options
  • Save thomaseizinger/dd6271dc38e2e62b21ea041bca1e3bdc to your computer and use it in GitHub Desktop.
Save thomaseizinger/dd6271dc38e2e62b21ea041bca1e3bdc to your computer and use it in GitHub Desktop.
Gradle configuration for sharing code between several test source sets of a java project.
configurations {
// Create the configuration we will use to refer to our sources.
testSupport.extendsFrom compile
}
sourceSets {
// Creates two configurations (testSupportCompile, testSupportRuntime) we will ignore.
testSupport {
// We will at least need access to our main sourceSet and all dependencies that are declared for our configuration.
compileClasspath += sourceSets.main.output + configurations.testSupport
}
}
// Define a task to create a jar out of our sources.
task testSupportJar(type: Jar) {
from sourceSets.testSupport.output
classifier 'testSupport'
}
artifacts {
// Expose the output of our Jar-Task as an artifact so other project can depend on it.
testSupport testSupportJar
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment