I have a gradle script that runs after the SpringBoot jar file is generated:
task runScript (dependsOn: 'bootJar', type: JavaExec) {
main = 'postpackage'
classpath = sourceSets.main.runtimeClasspath
}
So far, the gradle script just prints a message:
println "hello world from groovy version ${GroovySystem.version}"
This works fine in my build.
gradle runScript
Task :runScript hello world from groovy version 2.4.15
What I want is something like:
println "hello world generated jar file name is ${jarFileName}"
What I want to do is pass in the SpringBoot generated jar name, or the name of the jar in build/libs/my-service-0.1.1.jar or whatever it is.
So it would print:
hello world generated jar file name is my-service-0.1.1.jar
How can I do that?
Here is what I tried:
postpackage.groovy:
println "hello world from groovy version ${GroovySystem.version}"
println "hello world from groovy version $bootJar.archiveName"
build.gradle:
task runScript (dependsOn: 'bootJar', type: JavaExec) {
main = 'postpackage'
classpath = sourceSets.main.runtimeClasspath
}
Here's the error:
Task :runScript FAILED hello world from groovy version 2.4.15 Exception in thread "main" groovy.lang.MissingPropertyException: No such property: bootJar for class: postpackage at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:66)
bootJar{ archiveName = project.property('theFileName') }and then use commandline parameter :./gradlew -PtheFileName="the-target-name.jar"- M.Ricciutiprintln "hello world generated jar file name is $bootJar.archiveName"- M.RicciutiException in thread "main" groovy.lang.MissingPropertyException: No such property: bootJar for class: postpackage- mikeb$bootJar.archiveNameand${$bootJar.archiveName}- mikeb