【发布时间】:2021-01-13 00:20:45
【问题描述】:
所以我有一个 Groovy 脚本:
// TestScript.groovy
println args
然后在 Gradle 任务中我有
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'))
}
}
我需要做的是两件事:
a) 传入TestScript.groovy 程序参数,以便打印出args 数组
b) 将 Spring Boot 配置文件传递给 JVM,即 spring.profiles.active=dev
有什么建议吗?
注意,我使用的是 Groovy 2.4.3 并参考此文档:http://docs.groovy-lang.org/2.4.3/html/api/groovy/lang/GroovyShell.html
我尝试了以下不成功的方法:
doLast {
Binding b = new Binding();
b.setVariable('spring.profiles.active', $profile)
new GroovyShell(b).run(file('package.TestScript.groovy'))
}
【问题讨论】:
标签: java spring-boot gradle groovy