Last active
November 23, 2016 12:27
-
-
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.
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
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