Skip to content

Commit cfc16ad

Browse files
author
Dave Syer
committed
Re-use the already built JAR file if possible
The build-image Mojo doesn't attempt to re-use an existing JAR file that it has already built. This is a small change that just checks if it already exists and re-uses it. A side effect is that other plugins can modify the JAR file (e.g. to optimize the reflection usage for a native-image build) and those changes are visible in the container image.
1 parent d2926e0 commit cfc16ad

File tree

1 file changed

+5
-1
lines changed
  • spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven

1 file changed

+5
-1
lines changed

spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/BuildImageMojo.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,11 @@ private BuildRequest getBuildRequest(Libraries libraries) {
164164
}
165165

166166
private TarArchive getApplicationContent(Owner owner, Libraries libraries) {
167-
ImagePackager packager = getConfiguredPackager(() -> new ImagePackager(getJarFile()));
167+
File jarFile = getJarFile();
168+
if (jarFile.exists()) {
169+
return TarArchive.fromZip(jarFile, owner);
170+
}
171+
ImagePackager packager = getConfiguredPackager(() -> new ImagePackager(jarFile));
168172
return new PackagedTarArchive(owner, libraries, packager);
169173
}
170174

0 commit comments

Comments
 (0)