Fail on bootBuildImage with launch script

This commit adds a check to the support code for the Gradle plugin
bootBuildImage task to ensure that the jar file that will be passed
to a builder is readable and has a valid directory. This prevents a
situation where the jar file cannot be read because it is prepended
with a launch script, and the builder does not receive any files to
process.

Notes have also been added to the Gradle plugin documentation to warn
against using a bootJar launchScript configuration and bootBuildImage
together, as well as caveats about launchScript that match the Maven
plugin documentation.

Fixes gh-22223
This commit is contained in:
Scott Frederick
2020-07-14 11:03:22 -05:00
parent 259ea65388
commit 210282260e
6 changed files with 38 additions and 2 deletions

View File

@@ -126,6 +126,15 @@ class BootBuildImageIntegrationTests {
}
}
@TestTemplate
void failsWithLaunchScript() {
writeMainClass();
writeLongNameResource();
BuildResult result = this.gradleBuild.buildAndFail("bootBuildImage");
assertThat(result.task(":bootBuildImage").getOutcome()).isEqualTo(TaskOutcome.FAILED);
assertThat(result.getOutput()).contains("not compatible with buildpacks");
}
@TestTemplate
void failsWithBuilderError() {
writeMainClass();