Created
April 27, 2018 09:38
-
-
Save binarycreations/e87e1a322f37d1f7cbdee57a3123a6c0 to your computer and use it in GitHub Desktop.
Filtering out JVM argument warnings using TaskCollection#matching(Spec...)
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
allprojects { | |
repositories { | |
jcenter() | |
} | |
afterEvaluate { | |
project.tasks.matching(new Spec<Task> () { | |
def boolean isSatisfiedBy(Task el) { | |
return (el instanceof JavaExec || el instanceof Test) ? true : false | |
} | |
}).each { | |
it.jvmArgs "--add-opens=java.base/java.lang=ALL-UNNAMED" | |
} | |
} | |
} | |
subprojects { | |
version = "0.0.1-SNAPSHOT" | |
} |
Same solution but more compact
afterEvaluate {
project.tasks
.matching { el -> el instanceof JavaExec || el instanceof Test }
.each { it.jvmArgs "--add-opens=java.base/java.lang=ALL-UNNAMED" }
}
Your Groovy foo is much better than mine @ToYonos
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Much better solution can be found here on StackOverflow.
Thanks goes to ToYonos