So I have a Groovy script:
// TestScript.groovy
println args
Then in a Gradle task I have
test {
String profile = System.getenv("spring.profiles.active")
jvmArgs '-Dspring.profiles.active=$profile" // THIS DOES NOT WORK! :(
doLast {
new GroovyShell().run(file('package.TestScript.groovy'))
}
}
What I need to do is two things:
a) Pass into TestScript.groovy program arguments so it will print out the args array
b) Pass to JVM the Spring Boot profile i.e. spring.profiles.active=dev
Any suggestions?
Note, I'm using Groovy 2.4.3 and referring to this documentation: http://docs.groovy-lang.org/2.4.3/html/api/groovy/lang/GroovyShell.html
I tried the following which was unsuccessful:
doLast {
Binding b = new Binding();
b.setVariable('spring.profiles.active', $profile)
new GroovyShell(b).run(file('package.TestScript.groovy'))
}