this is a mix of a spring/gradle question. with th...
# spring
s
this is a mix of a spring/gradle question. with the spring boot gradle plugin, is there anyway to copy the runnable jar to a different location and rename it? I've tried to do it with just a copy task, but that's messy because it depends on the project name. I'd rather just copy the single runnable jar without regex.
d
You can use a task as an input to a copy task - it'll work out the task dependency and input file for you
You could also change the output filename for the runnable jar task
s
I think there are several output files though, like sources and javadoc. I only want the runnable
d
Those will be separate jar tasks
s
ah, how do I change the output filename?
oh they will be?
hm.
d
The
BootJar
task extends the standard
Jar
task
s
yes I've seen that.
s
fantastic. that worked perfectly!
from
Copy code
val copyBoot = tasks.create<Copy>("copyBootJar") {
    from("build/libs") {
        include("lp-server-deploy-*.jar")
        exclude("*-javadoc.jar")
        exclude("*-sources.jar")
    }

    into("build/docker")
    exclude("**/*.bak")
    rename(".*.jar", "runnable.jar")
    includeEmptyDirs = false
}
copyBoot.dependsOn("bootJar")
tasks["assemble"].dependsOn(copyBoot)
to
Copy code
val copyBoot = tasks.create("copyBootJar", Copy::class.java) {
            from(tasks["bootJar"])
            into("build/runnable")
            rename(".*.jar", "runnable.jar")
        }
        copyBoot.dependsOn("bootJar")
        tasks["assemble"].dependsOn(copyBoot)