Commit c2a483a7 authored by Kedar Joshi's avatar Kedar Joshi Committed by Stephane Nicoll

Allow overriding image.cleanCache from the command-line

See gh-32719
parent 771503f3
...@@ -153,7 +153,7 @@ Acceptable values are `ALWAYS`, `NEVER`, and `IF_NOT_PRESENT`. ...@@ -153,7 +153,7 @@ Acceptable values are `ALWAYS`, `NEVER`, and `IF_NOT_PRESENT`.
| `cleanCache` | `cleanCache`
| Whether to clean the cache before building. | Whether to clean the cache before building.
| | `spring-boot.build-image.cleanCache`
| `false` | `false`
| `verboseLogging` | `verboseLogging`
......
...@@ -130,6 +130,14 @@ public class BuildImageMojo extends AbstractPackagerMojo { ...@@ -130,6 +130,14 @@ public class BuildImageMojo extends AbstractPackagerMojo {
@Parameter(property = "spring-boot.build-image.runImage", readonly = true) @Parameter(property = "spring-boot.build-image.runImage", readonly = true)
String runImage; 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 * Alias for {@link Image#pullPolicy} to support configuration via command-line
* property. * property.
...@@ -189,6 +197,9 @@ public class BuildImageMojo extends AbstractPackagerMojo { ...@@ -189,6 +197,9 @@ public class BuildImageMojo extends AbstractPackagerMojo {
if (image.runImage == null && this.runImage != null) { if (image.runImage == null && this.runImage != null) {
image.setRunImage(this.runImage); image.setRunImage(this.runImage);
} }
if (image.cleanCache == null && this.cleanCache != null) {
image.setCleanCache(this.cleanCache);
}
if (image.pullPolicy == null && this.pullPolicy != null) { if (image.pullPolicy == null && this.pullPolicy != null) {
image.setPullPolicy(this.pullPolicy); image.setPullPolicy(this.pullPolicy);
} }
......
...@@ -46,7 +46,7 @@ public class Image { ...@@ -46,7 +46,7 @@ public class Image {
Map<String, String> env; Map<String, String> env;
boolean cleanCache; Boolean cleanCache;
boolean verboseLogging; boolean verboseLogging;
...@@ -102,10 +102,14 @@ public class Image { ...@@ -102,10 +102,14 @@ public class Image {
* If the cache should be cleaned before building. * If the cache should be cleaned before building.
* @return {@code true} if the cache should be cleaned * @return {@code true} if the cache should be cleaned
*/ */
public boolean isCleanCache() { public Boolean isCleanCache() {
return this.cleanCache; return this.cleanCache;
} }
void setCleanCache(Boolean cleanCache) {
this.cleanCache = cleanCache;
}
/** /**
* If verbose logging is required. * If verbose logging is required.
* @return {@code true} for verbose logging * @return {@code true} for verbose logging
...@@ -160,7 +164,9 @@ public class Image { ...@@ -160,7 +164,9 @@ public class Image {
if (this.env != null && !this.env.isEmpty()) { if (this.env != null && !this.env.isEmpty()) {
request = request.withEnv(this.env); request = request.withEnv(this.env);
} }
request = request.withCleanCache(this.cleanCache); if (this.cleanCache != null) {
request = request.withCleanCache(this.cleanCache);
}
request = request.withVerboseLogging(this.verboseLogging); request = request.withVerboseLogging(this.verboseLogging);
if (this.pullPolicy != null) { if (this.pullPolicy != null) {
request = request.withPullPolicy(this.pullPolicy); request = request.withPullPolicy(this.pullPolicy);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment