Pass Spring Boot jar name to Gradle Groovy script
up vote
0
down vote
favorite
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)
java gradle groovy
add a comment |
up vote
0
down vote
favorite
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)
java gradle groovy
you can configure bootJar task likebootJar{ archiveName = project.property('theFileName') }
and then use commandline parameter :./gradlew -PtheFileName="the-target-name.jar"
– M.Ricciuti
Nov 10 at 15:49
I added exactly what I am looking for
– mikeb
Nov 10 at 17:12
then tryprintln "hello world generated jar file name is $bootJar.archiveName"
– M.Ricciuti
Nov 10 at 17:16
Exception in thread "main" groovy.lang.MissingPropertyException: No such property: bootJar for class: postpackage
– mikeb
Nov 10 at 17:19
See the edits - I used$bootJar.archiveName
and${$bootJar.archiveName}
– mikeb
Nov 10 at 17:28
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
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)
java gradle groovy
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)
java gradle groovy
java gradle groovy
edited Nov 10 at 17:28
asked Nov 10 at 15:02
mikeb
5,20622660
5,20622660
you can configure bootJar task likebootJar{ archiveName = project.property('theFileName') }
and then use commandline parameter :./gradlew -PtheFileName="the-target-name.jar"
– M.Ricciuti
Nov 10 at 15:49
I added exactly what I am looking for
– mikeb
Nov 10 at 17:12
then tryprintln "hello world generated jar file name is $bootJar.archiveName"
– M.Ricciuti
Nov 10 at 17:16
Exception in thread "main" groovy.lang.MissingPropertyException: No such property: bootJar for class: postpackage
– mikeb
Nov 10 at 17:19
See the edits - I used$bootJar.archiveName
and${$bootJar.archiveName}
– mikeb
Nov 10 at 17:28
add a comment |
you can configure bootJar task likebootJar{ archiveName = project.property('theFileName') }
and then use commandline parameter :./gradlew -PtheFileName="the-target-name.jar"
– M.Ricciuti
Nov 10 at 15:49
I added exactly what I am looking for
– mikeb
Nov 10 at 17:12
then tryprintln "hello world generated jar file name is $bootJar.archiveName"
– M.Ricciuti
Nov 10 at 17:16
Exception in thread "main" groovy.lang.MissingPropertyException: No such property: bootJar for class: postpackage
– mikeb
Nov 10 at 17:19
See the edits - I used$bootJar.archiveName
and${$bootJar.archiveName}
– mikeb
Nov 10 at 17:28
you can configure bootJar task like
bootJar{ archiveName = project.property('theFileName') }
and then use commandline parameter : ./gradlew -PtheFileName="the-target-name.jar"
– M.Ricciuti
Nov 10 at 15:49
you can configure bootJar task like
bootJar{ archiveName = project.property('theFileName') }
and then use commandline parameter : ./gradlew -PtheFileName="the-target-name.jar"
– M.Ricciuti
Nov 10 at 15:49
I added exactly what I am looking for
– mikeb
Nov 10 at 17:12
I added exactly what I am looking for
– mikeb
Nov 10 at 17:12
then try
println "hello world generated jar file name is $bootJar.archiveName"
– M.Ricciuti
Nov 10 at 17:16
then try
println "hello world generated jar file name is $bootJar.archiveName"
– M.Ricciuti
Nov 10 at 17:16
Exception in thread "main" groovy.lang.MissingPropertyException: No such property: bootJar for class: postpackage
– mikeb
Nov 10 at 17:19
Exception in thread "main" groovy.lang.MissingPropertyException: No such property: bootJar for class: postpackage
– mikeb
Nov 10 at 17:19
See the edits - I used
$bootJar.archiveName
and ${$bootJar.archiveName}
– mikeb
Nov 10 at 17:28
See the edits - I used
$bootJar.archiveName
and ${$bootJar.archiveName}
– mikeb
Nov 10 at 17:28
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
Answer:
Pass the argument via the build.gradle like this:
task runScript (dependsOn: 'bootJar', type: JavaExec) {
main = 'postpackage'
classpath = sourceSets.main.runtimeClasspath
args "${bootJar.archiveName}"
}
Reference it in the script like this:
println "hello world from groovy version ${GroovySystem.version}"
println "hello world from groovy version ${args[0]}"
Works just fine:
:bootJar UP-TO-DATE :runScript hello world from groovy version 2.4.15
hello world from groovy version my-service-0.1.1.jar
BUILD SUCCESSFUL in 2s
5 actionable tasks: 1 executed, 4 up-to-date
12:36:00 PM: Task execution finished 'runScript'.
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
Answer:
Pass the argument via the build.gradle like this:
task runScript (dependsOn: 'bootJar', type: JavaExec) {
main = 'postpackage'
classpath = sourceSets.main.runtimeClasspath
args "${bootJar.archiveName}"
}
Reference it in the script like this:
println "hello world from groovy version ${GroovySystem.version}"
println "hello world from groovy version ${args[0]}"
Works just fine:
:bootJar UP-TO-DATE :runScript hello world from groovy version 2.4.15
hello world from groovy version my-service-0.1.1.jar
BUILD SUCCESSFUL in 2s
5 actionable tasks: 1 executed, 4 up-to-date
12:36:00 PM: Task execution finished 'runScript'.
add a comment |
up vote
0
down vote
Answer:
Pass the argument via the build.gradle like this:
task runScript (dependsOn: 'bootJar', type: JavaExec) {
main = 'postpackage'
classpath = sourceSets.main.runtimeClasspath
args "${bootJar.archiveName}"
}
Reference it in the script like this:
println "hello world from groovy version ${GroovySystem.version}"
println "hello world from groovy version ${args[0]}"
Works just fine:
:bootJar UP-TO-DATE :runScript hello world from groovy version 2.4.15
hello world from groovy version my-service-0.1.1.jar
BUILD SUCCESSFUL in 2s
5 actionable tasks: 1 executed, 4 up-to-date
12:36:00 PM: Task execution finished 'runScript'.
add a comment |
up vote
0
down vote
up vote
0
down vote
Answer:
Pass the argument via the build.gradle like this:
task runScript (dependsOn: 'bootJar', type: JavaExec) {
main = 'postpackage'
classpath = sourceSets.main.runtimeClasspath
args "${bootJar.archiveName}"
}
Reference it in the script like this:
println "hello world from groovy version ${GroovySystem.version}"
println "hello world from groovy version ${args[0]}"
Works just fine:
:bootJar UP-TO-DATE :runScript hello world from groovy version 2.4.15
hello world from groovy version my-service-0.1.1.jar
BUILD SUCCESSFUL in 2s
5 actionable tasks: 1 executed, 4 up-to-date
12:36:00 PM: Task execution finished 'runScript'.
Answer:
Pass the argument via the build.gradle like this:
task runScript (dependsOn: 'bootJar', type: JavaExec) {
main = 'postpackage'
classpath = sourceSets.main.runtimeClasspath
args "${bootJar.archiveName}"
}
Reference it in the script like this:
println "hello world from groovy version ${GroovySystem.version}"
println "hello world from groovy version ${args[0]}"
Works just fine:
:bootJar UP-TO-DATE :runScript hello world from groovy version 2.4.15
hello world from groovy version my-service-0.1.1.jar
BUILD SUCCESSFUL in 2s
5 actionable tasks: 1 executed, 4 up-to-date
12:36:00 PM: Task execution finished 'runScript'.
answered Nov 10 at 17:38
mikeb
5,20622660
5,20622660
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53240211%2fpass-spring-boot-jar-name-to-gradle-groovy-script%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
you can configure bootJar task like
bootJar{ archiveName = project.property('theFileName') }
and then use commandline parameter :./gradlew -PtheFileName="the-target-name.jar"
– M.Ricciuti
Nov 10 at 15:49
I added exactly what I am looking for
– mikeb
Nov 10 at 17:12
then try
println "hello world generated jar file name is $bootJar.archiveName"
– M.Ricciuti
Nov 10 at 17:16
Exception in thread "main" groovy.lang.MissingPropertyException: No such property: bootJar for class: postpackage
– mikeb
Nov 10 at 17:19
See the edits - I used
$bootJar.archiveName
and${$bootJar.archiveName}
– mikeb
Nov 10 at 17:28