Created
August 8, 2019 13:11
-
-
Save breskeby/f2dd0a648e848d67734df9a79d8afbe6 to your computer and use it in GitHub Desktop.
non input system properties for test tasks
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
tasks.withType(Test).configureEach { Test testTask -> | |
def nonInputs = new InconsequentialSystemProperty() | |
testTask.jvmArgumentProviders.add(nonInputs) | |
def nonInputSystemProperty = { String key, value -> | |
nonInputs.props.put(key, value) | |
} | |
testTask.extensions.extraProperties.set("nonInputSystemProperty", nonInputSystemProperty) | |
} | |
class InconsequentialSystemProperty implements CommandLineArgumentProvider, Named { | |
final Map<String, Object> props = [:] | |
@Override | |
Iterable<String> asArguments() { | |
props.collect { key, value -> "-D${key}=${value}".toString() } | |
} | |
@Override | |
String getName() { | |
"inconsequentialSystemProperties" | |
} | |
} |
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
// example usage | |
apply plugin:'java-libary' | |
test { | |
//Use TMPDIR as set on TeamCity | |
nonInputSystemProperty "java.io.tmpdir", System.getenv('TMPDIR') ?: System.getProperty("java.io.tmpdir") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment