Skip to content

Instantly share code, notes, and snippets.

@binarycreations
Created April 27, 2018 09:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save binarycreations/e87e1a322f37d1f7cbdee57a3123a6c0 to your computer and use it in GitHub Desktop.
Save binarycreations/e87e1a322f37d1f7cbdee57a3123a6c0 to your computer and use it in GitHub Desktop.
Filtering out JVM argument warnings using TaskCollection#matching(Spec...)
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"
}
@binarycreations
Copy link
Author

binarycreations commented Apr 27, 2018

Much better solution can be found here on StackOverflow.

Thanks goes to ToYonos

@ToYonos
Copy link

ToYonos commented Apr 27, 2018

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" }
  }

@binarycreations
Copy link
Author

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