I just upgraded the Gradle SpringBoot plugin version to 2.5.2 and found out about the difference between the jar
and bootJar
tasks - the former builds an artifact suffixed with -plain.jar
whereas the latter builds an actual executable artifact. I also have a custom plugin that consumes the output of the jar
task as follows:
@Override
void apply(Project project) {
project.copy {
from project.jar
into someDir
}
}
Given that project.jar
is a -plain.jar
that isn't actually executable, is there any way to modify the behavior of the jar
task such that I won't have to modify the plugin? The artifact that is to be copied must be the executable application.
It looks like your plugin was relying on the jar
and bootJar
tasks creating a jar file with the same name. This isn’t ideal. For example, in the code that you have shown above, there’s no guarantee that bootJar
will have built the executable jar file before it is copied. If at all possible, I would recommend updating the plugin to copy from bootJar
rather than jar
.
If you are unable to change the plugin, you should be able to reinstate the old behaviour by disabling the jar
task and removing its classifier:
jar {
enabled = false
classifier = ''
}
This will resulting in the jar
task having the same output location as the bootJar
task and disable it so that the output from one task isn’t overwritten by the other.