From c2a483a78f1499b83468a96dc3f85b98063dfcb2 Mon Sep 17 00:00:00 2001 From: Kedar Joshi Date: Fri, 16 Oct 2020 01:13:52 +0530 Subject: [PATCH 1/2] Allow overriding image.cleanCache from the command-line See gh-32719 --- .../src/docs/asciidoc/packaging-oci-image.adoc | 2 +- .../springframework/boot/maven/BuildImageMojo.java | 11 +++++++++++ .../java/org/springframework/boot/maven/Image.java | 12 +++++++++--- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/docs/asciidoc/packaging-oci-image.adoc b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/docs/asciidoc/packaging-oci-image.adoc index f59509e187..7aa2462927 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/docs/asciidoc/packaging-oci-image.adoc +++ b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/docs/asciidoc/packaging-oci-image.adoc @@ -153,7 +153,7 @@ Acceptable values are `ALWAYS`, `NEVER`, and `IF_NOT_PRESENT`. | `cleanCache` | Whether to clean the cache before building. -| +| `spring-boot.build-image.cleanCache` | `false` | `verboseLogging` diff --git a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/BuildImageMojo.java b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/BuildImageMojo.java index 7b85d7aa68..e094d2abbe 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/BuildImageMojo.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/BuildImageMojo.java @@ -130,6 +130,14 @@ public class BuildImageMojo extends AbstractPackagerMojo { @Parameter(property = "spring-boot.build-image.runImage", readonly = true) String runImage; + /** + * Alias for {@link Image#cleanCache} to support configuration via command-line + * property. + * @since 2.4.0 + */ + @Parameter(property = "spring-boot.build-image.cleanCache", readonly = true) + Boolean cleanCache; + /** * Alias for {@link Image#pullPolicy} to support configuration via command-line * property. @@ -189,6 +197,9 @@ public class BuildImageMojo extends AbstractPackagerMojo { if (image.runImage == null && this.runImage != null) { image.setRunImage(this.runImage); } + if (image.cleanCache == null && this.cleanCache != null) { + image.setCleanCache(this.cleanCache); + } if (image.pullPolicy == null && this.pullPolicy != null) { image.setPullPolicy(this.pullPolicy); } diff --git a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/Image.java b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/Image.java index 83ca2f0a94..a4edaa098a 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/Image.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/Image.java @@ -46,7 +46,7 @@ public class Image { Map env; - boolean cleanCache; + Boolean cleanCache; boolean verboseLogging; @@ -102,10 +102,14 @@ public class Image { * If the cache should be cleaned before building. * @return {@code true} if the cache should be cleaned */ - public boolean isCleanCache() { + public Boolean isCleanCache() { return this.cleanCache; } + void setCleanCache(Boolean cleanCache) { + this.cleanCache = cleanCache; + } + /** * If verbose logging is required. * @return {@code true} for verbose logging @@ -160,7 +164,9 @@ public class Image { if (this.env != null && !this.env.isEmpty()) { request = request.withEnv(this.env); } - request = request.withCleanCache(this.cleanCache); + if (this.cleanCache != null) { + request = request.withCleanCache(this.cleanCache); + } request = request.withVerboseLogging(this.verboseLogging); if (this.pullPolicy != null) { request = request.withPullPolicy(this.pullPolicy); From 59bcbd4885a80e2b277111459deb3500b30fef12 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Thu, 22 Oct 2020 10:27:59 +0200 Subject: [PATCH 2/2] Polish "Allow overriding image.cleanCache from the command-line" See gh-32719 --- .../src/main/java/org/springframework/boot/maven/Image.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/Image.java b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/Image.java index a4edaa098a..bdec55f3e1 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/Image.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/Image.java @@ -102,7 +102,7 @@ public class Image { * If the cache should be cleaned before building. * @return {@code true} if the cache should be cleaned */ - public Boolean isCleanCache() { + public Boolean getCleanCache() { return this.cleanCache; }