From 18d83cf711cde27135fd39b87eada5f91b025593 Mon Sep 17 00:00:00 2001
From: Derek Sharpe <derek.sharpe@oracle.com>
Date: Tue, 3 Dec 2024 13:52:21 -0600
Subject: [PATCH 1/4] preparing for next development iteration

---
 imagetool/pom.xml | 2 +-
 installer/pom.xml | 2 +-
 pom.xml           | 2 +-
 tests/pom.xml     | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/imagetool/pom.xml b/imagetool/pom.xml
index e92a08ab..d5439e4f 100644
--- a/imagetool/pom.xml
+++ b/imagetool/pom.xml
@@ -13,7 +13,7 @@
     <parent>
         <artifactId>imagetool-parent</artifactId>
         <groupId>com.oracle.weblogic.lifecycle.imagetool</groupId>
-        <version>1.14.3</version>
+        <version>1.14.4-SNAPSHOT</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
 
diff --git a/installer/pom.xml b/installer/pom.xml
index f8193a67..52b3c9a5 100644
--- a/installer/pom.xml
+++ b/installer/pom.xml
@@ -13,7 +13,7 @@
     <parent>
         <artifactId>imagetool-parent</artifactId>
         <groupId>com.oracle.weblogic.lifecycle.imagetool</groupId>
-        <version>1.14.3</version>
+        <version>1.14.4-SNAPSHOT</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
 
diff --git a/pom.xml b/pom.xml
index 57936cc4..28812a75 100644
--- a/pom.xml
+++ b/pom.xml
@@ -8,7 +8,7 @@
     <modelVersion>4.0.0</modelVersion>
     <groupId>com.oracle.weblogic.lifecycle.imagetool</groupId>
     <artifactId>imagetool-parent</artifactId>
-    <version>1.14.3</version>
+    <version>1.14.4-SNAPSHOT</version>
     <packaging>pom</packaging>
 
     <name>WebLogic Image Tool</name>
diff --git a/tests/pom.xml b/tests/pom.xml
index 23d78a39..9ce217a0 100644
--- a/tests/pom.xml
+++ b/tests/pom.xml
@@ -12,7 +12,7 @@
     <parent>
         <artifactId>imagetool-parent</artifactId>
         <groupId>com.oracle.weblogic.lifecycle.imagetool</groupId>
-        <version>1.14.3</version>
+        <version>1.14.4-SNAPSHOT</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
 

From c5af585aed32cd0c4601fd6baa18509740e9928a Mon Sep 17 00:00:00 2001
From: "derek.sharpe" <derek.sharpe@oracle.com>
Date: Tue, 7 Jan 2025 19:28:20 +0000
Subject: [PATCH 2/4] Remove force-rm default from buildx and add command line
 option for buildx

---
 bug_release.sh                                | 26 ++++++++++---------
 .../content/userguide/tools/create-image.md   |  1 +
 .../content/userguide/tools/rebase-image.md   |  1 +
 .../content/userguide/tools/update-image.md   |  1 +
 .../imagetool/builder/BuildCommand.java       | 17 ++++++++++--
 .../imagetool/cli/menu/CommonOptions.java     | 11 ++++++--
 .../imagetool/builder/BuilderTest.java        | 21 +++++++++++++++
 pom.xml                                       | 10 +++----
 .../imagetool/tests/utils/Runner.java         | 11 ++++----
 9 files changed, 73 insertions(+), 26 deletions(-)

diff --git a/bug_release.sh b/bug_release.sh
index de4440aa..64588b02 100755
--- a/bug_release.sh
+++ b/bug_release.sh
@@ -1,4 +1,6 @@
 #!/bin/bash
+# Only use this script when releasing bug fixes (removes SNAPSHOT for version)
+git checkout main
 
 project_version=$(mvn help:evaluate -q -DforceStdout -D"expression=project.version")
 echo Current POM version: ${project_version}
@@ -10,18 +12,18 @@ new_version=$(echo $project_version | sed -e "s/[0-9][0-9]*\([^0-9]*\)$/$next_di
 
 echo New Version: ${new_version}
 
-echo mvn versions:set -DremoveSnapshot -DgenerateBackupPoms=false
-echo mvn clean install
-echo git add .
-echo git commit -m \"release ${project_version_number_only}\"
-echo git push
+mvn versions:set -DremoveSnapshot -DgenerateBackupPoms=false
+mvn clean install
+git add .
+git commit -m \"release ${project_version_number_only}\"
+git push
 
-echo git tag release-${project_version_number_only}
-echo git push origin release-${project_version_number_only}
+git tag release-${project_version_number_only}
+git push origin release-${project_version_number_only}
 
-echo mvn versions:set -DgenerateBackupPoms=false -DnewVersion=${new_version}
-echo mvn clean install
-echo git add .
-echo git commit -m \"preparing for next development iteration\"
-echo git push
+mvn versions:set -DgenerateBackupPoms=false -DnewVersion=${new_version}
+mvn clean install
+git add .
+git commit -m \"preparing for next development iteration\"
+git push
 
diff --git a/documentation/site/content/userguide/tools/create-image.md b/documentation/site/content/userguide/tools/create-image.md
index 68a1f5ae..e14ebe58 100644
--- a/documentation/site/content/userguide/tools/create-image.md
+++ b/documentation/site/content/userguide/tools/create-image.md
@@ -48,6 +48,7 @@ Usage: imagetool create [OPTIONS]
 | `--strictPatchOrdering` |  Instruct OPatch to apply patches one at a time (uses `apply` instead of `napply`). |   |
 | `--target` | Select the target environment in which the created image will be used. Supported values: `Default` (Docker/Kubernetes), `OpenShift`. See [Additional information](#--target). | `Default`  |
 | `--type` | Installer type. Supported values: `WLS`, `WLSDEV`, `WLSSLIM`, `FMW`, `IDM`, `MFT`, `OAM`, `ODI`, `OHS`, `OIG`, `OUD`, `OUD_WLS`, `OID`, `OSB`, `SOA`, `SOA_OSB`, `SOA_OSB_B2B`, `WCC`, `WCP`, `WCS`  | `WLS`  |
+| `--useBuildx` | Use BuildKit for building the container image.  |  |
 | `--user` | Oracle support email ID. When supplying `user`, you must supply the password either as an environment variable using `--passwordEnv`, or as a file using `--passwordFile`, or interactively, on the command line with `--password`.  |   |
 | `--version` | Installer version. | `12.2.1.3.0`  |
 | `--wdtArchive` | A WDT archive ZIP file or comma-separated list of files.  |   |
diff --git a/documentation/site/content/userguide/tools/rebase-image.md b/documentation/site/content/userguide/tools/rebase-image.md
index 25f7fd54..a4cf080d 100644
--- a/documentation/site/content/userguide/tools/rebase-image.md
+++ b/documentation/site/content/userguide/tools/rebase-image.md
@@ -47,6 +47,7 @@ Usage: imagetool rebase [OPTIONS]
 | `--target` | Select the target environment in which the created image will be used. Supported values: `Default` (Docker/Kubernetes), `OpenShift`. See [Additional information](#--target). | `Default`  |
 | `--targetImage` | Container image to extend for the domain's new image. |   |
 | `--type` | Installer type. Supported values: `WLS`, `WLSDEV`, `WLSSLIM`, `FMW`, `IDM`, `MFT`, `OAM`, `ODI`, `OHS`, `OIG`, `OUD`, `OUD_WLS`, `OID`, `OSB`, `SOA`, `SOA_OSB`, `SOA_OSB_B2B`, `WCC`, `WCP`, `WCS`  | `WLS`  |
+| `--useBuildx` | Use BuildKit for building the container image.  |  |
 | `--user` | Your Oracle support email ID. When supplying `user`, you must supply the password either as an environment variable using `--passwordEnv`, or as a file using `--passwordFile`, or interactively, on the command line with `--password`. |   |
 | `--version` | Installer version. | `12.2.1.3.0`  |
 
diff --git a/documentation/site/content/userguide/tools/update-image.md b/documentation/site/content/userguide/tools/update-image.md
index e634b182..a2c06157 100644
--- a/documentation/site/content/userguide/tools/update-image.md
+++ b/documentation/site/content/userguide/tools/update-image.md
@@ -49,6 +49,7 @@ Update WebLogic Docker image with selected patches
 | `--strictPatchOrdering` | Instruct OPatch to apply patches one at a time (uses `apply` instead of `napply`). |  |
 | `--target` | Select the target environment in which the created image will be used. Supported values: `Default` (Docker/Kubernetes), `OpenShift`. See [Additional information](#--target). | `Default` |
 | `--type` | Installer type. Supported values: `WLS`, `WLSDEV`, `WLSSLIM`, `FMW`, `IDM`, `MFT`, `OAM`, `ODI`, `OHS`, `OIG`, `OUD`, `OUD_WLS`, `OID`, `OSB`, `SOA`, `SOA_OSB`, `SOA_OSB_B2B`, `WCC`, `WCP`, `WCS`  | `WLS`  |
+| `--useBuildx` | Use BuildKit for building the container image.  |  |
 | `--user` | Oracle support email ID. When supplying `user`, you must supply the password either as an environment variable using `--passwordEnv`, or as a file using `--passwordFile`, or interactively, on the command line with `--password`. |  |
 | `--wdtArchive` | A WDT archive ZIP file or comma-separated list of files. |  |
 | `--wdtDomainHome` | Path to the `-domain_home` for WDT. | `/u01/domains/base_domain`    |
diff --git a/imagetool/src/main/java/com/oracle/weblogic/imagetool/builder/BuildCommand.java b/imagetool/src/main/java/com/oracle/weblogic/imagetool/builder/BuildCommand.java
index fa55d133..b5e39821 100644
--- a/imagetool/src/main/java/com/oracle/weblogic/imagetool/builder/BuildCommand.java
+++ b/imagetool/src/main/java/com/oracle/weblogic/imagetool/builder/BuildCommand.java
@@ -60,6 +60,18 @@ public BuildCommand tag(String value) {
         return this;
     }
 
+    /**
+     * Toggle the use of the BuildKit.
+     * If true, the build command will start "buildx build".
+     * If false, the build command will start "build".
+     * @param value true to enable buildx
+     * @return this
+     */
+    public BuildCommand useBuildx(boolean value) {
+        useBuildx = value;
+        return this;
+    }
+
     /**
      * Add container build platform.  Pass the desired
      * build architecture to the build process.
@@ -72,7 +84,7 @@ public BuildCommand platform(String value) {
         }
         command.add("--platform");
         command.add(value);
-        useBuildx = true;
+        useBuildx(true);
         return this;
     }
 
@@ -83,7 +95,8 @@ public BuildCommand platform(String value) {
      * @return this
      */
     public BuildCommand forceRm(boolean value) {
-        if (value) {
+        // Docker removed --force-rm from the buildx build API, and Podman defaults --force-rm=true
+        if (value && !useBuildx) {
             command.add("--force-rm");
         }
         return this;
diff --git a/imagetool/src/main/java/com/oracle/weblogic/imagetool/cli/menu/CommonOptions.java b/imagetool/src/main/java/com/oracle/weblogic/imagetool/cli/menu/CommonOptions.java
index af6bddc9..63eaae58 100644
--- a/imagetool/src/main/java/com/oracle/weblogic/imagetool/cli/menu/CommonOptions.java
+++ b/imagetool/src/main/java/com/oracle/weblogic/imagetool/cli/menu/CommonOptions.java
@@ -121,9 +121,10 @@ BuildCommand getInitialBuildCmd(String contextFolder) {
         logger.entering();
         BuildCommand cmdBuilder = new BuildCommand(buildEngine, contextFolder);
 
-        cmdBuilder.forceRm(!skipcleanup)
-            .tag(imageTag)
+        cmdBuilder.tag(imageTag)
+            .useBuildx(useBuildx)
             .platform(buildPlatform)
+            .forceRm(!skipcleanup)
             .network(buildNetwork)
             .pull(buildPull)
             .additionalOptions(buildOptions)
@@ -450,6 +451,12 @@ public Architecture getTargetArchitecture() {
     )
     private String buildPlatform;
 
+    @Option(
+        names = {"--useBuildx"},
+        description = "Use the BuildKit for building the container image (default when building multi-architecture)"
+    )
+    private boolean useBuildx;
+
     @Parameters(
         description = "Container build options.",
         hidden = true
diff --git a/imagetool/src/test/java/com/oracle/weblogic/imagetool/builder/BuilderTest.java b/imagetool/src/test/java/com/oracle/weblogic/imagetool/builder/BuilderTest.java
index bfd029ce..42893212 100644
--- a/imagetool/src/test/java/com/oracle/weblogic/imagetool/builder/BuilderTest.java
+++ b/imagetool/src/test/java/com/oracle/weblogic/imagetool/builder/BuilderTest.java
@@ -79,4 +79,25 @@ void testBuildWithProxyPass() {
         cmd.tag("img:3").buildArg("http_proxy", "http://user:pass@blah/blah", true);
         assertEquals(expected("--tag img:3 --build-arg http_proxy=********"), cmd.toString());
     }
+
+    @Test
+    void testBuildArgsWithPlatform() {
+        Map<String,String> argMap = null;
+
+        BuildCommand cmd = new BuildCommand(BUILD_ENGINE, BUILD_CONTEXT)
+            .tag("img:4")
+            .pull(true)
+            .platform("linux/amd64")
+            .forceRm(true)
+            .network("private-net")
+            .buildArg(argMap);
+
+        // expect that "--force-rm" will not be used, expect "buildx build" will be used
+        assertEquals(
+            String.format("%s buildx build %s %s",
+                BUILD_ENGINE,
+                "--tag img:4 --pull --platform linux/amd64 --network private-net",
+                BUILD_CONTEXT),
+            cmd.toString());
+    }
 }
diff --git a/pom.xml b/pom.xml
index 28812a75..3338ede0 100644
--- a/pom.xml
+++ b/pom.xml
@@ -72,7 +72,7 @@
             <dependency>
                 <groupId>org.junit.jupiter</groupId>
                 <artifactId>junit-jupiter-engine</artifactId>
-                <version>5.11.3</version>
+                <version>5.11.4</version>
                 <scope>test</scope>
             </dependency>
             <dependency>
@@ -154,7 +154,7 @@
                 <plugin>
                     <groupId>org.apache.maven.plugins</groupId>
                     <artifactId>maven-failsafe-plugin</artifactId>
-                    <version>3.5.0</version>
+                    <version>3.5.2</version>
                     <configuration>
                         <groups>${test.groups}</groups>
                         <excludedGroups>failing</excludedGroups>
@@ -214,7 +214,7 @@
                 <plugin>
                     <groupId>org.apache.maven.plugins</groupId>
                     <artifactId>maven-checkstyle-plugin</artifactId>
-                    <version>3.5.0</version>
+                    <version>3.6.0</version>
                     <executions>
                         <execution>
                             <id>checkstyle</id>
@@ -242,14 +242,14 @@
                         <dependency>
                             <groupId>com.puppycrawl.tools</groupId>
                             <artifactId>checkstyle</artifactId>
-                            <version>10.20.2</version>
+                            <version>10.21.1</version>
                         </dependency>
                     </dependencies>
                 </plugin>
                 <plugin>
                     <groupId>org.apache.maven.plugins</groupId>
                     <artifactId>maven-surefire-plugin</artifactId>
-                    <version>3.5.1</version>
+                    <version>3.5.2</version>
                     <configuration>
                         <groups>unit</groups>
                         <excludedGroups>failing</excludedGroups>
diff --git a/tests/src/test/java/com/oracle/weblogic/imagetool/tests/utils/Runner.java b/tests/src/test/java/com/oracle/weblogic/imagetool/tests/utils/Runner.java
index 80070410..d9d89e23 100644
--- a/tests/src/test/java/com/oracle/weblogic/imagetool/tests/utils/Runner.java
+++ b/tests/src/test/java/com/oracle/weblogic/imagetool/tests/utils/Runner.java
@@ -68,12 +68,13 @@ public static CommandResult run(String command, PrintWriter output) throws IOExc
 
             p = pb.start();
 
-            BufferedReader reader = new BufferedReader(new InputStreamReader(p.getInputStream(), UTF_8));
             StringBuilder processOut = new StringBuilder();
-            String line;
-            while ((line = reader.readLine()) != null) {
-                processOut.append(line);
-                output.println(line);
+            try (BufferedReader reader = new BufferedReader(new InputStreamReader(p.getInputStream(), UTF_8))) {
+                String line;
+                while ((line = reader.readLine()) != null) {
+                    processOut.append(line);
+                    output.println(line);
+                }
             }
 
             p.waitFor();

From 43cf0b93967b2286242d3aa0fef09182e277662e Mon Sep 17 00:00:00 2001
From: Derek Sharpe <derek.sharpe@oracle.com>
Date: Thu, 9 Jan 2025 10:41:41 -0600
Subject: [PATCH 3/4] Allow spaces in the WLS installer zip name

---
 .../main/resources/docker-files/install-middleware.mustache | 6 +++---
 pom.xml                                                     | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/imagetool/src/main/resources/docker-files/install-middleware.mustache b/imagetool/src/main/resources/docker-files/install-middleware.mustache
index 1beccc6a..a20961fc 100644
--- a/imagetool/src/main/resources/docker-files/install-middleware.mustache
+++ b/imagetool/src/main/resources/docker-files/install-middleware.mustache
@@ -21,10 +21,10 @@ RUN mkdir -p {{{oracle_home}}} \
 && chown {{userid}}:{{groupid}} {{orainv_dir}} \
 && chown {{userid}}:{{groupid}} {{{oracle_home}}}
 
-{{#installJava}}COPY --from=jdk_build --chown={{userid}}:{{groupid}} {{{java_home}}} {{{java_home}}}/
+{{#installJava}}COPY --from=jdk_build --chown={{userid}}:{{groupid}} ["{{{java_home}}}", "{{{java_home}}}/"]
 {{/installJava}}
 
-{{#installPackages}}COPY --chown={{userid}}:{{groupid}} {{installerFilename}} {{responseFile.name}} {{{tempDir}}}/{{{type}}}/
+{{#installPackages}}COPY --chown={{userid}}:{{groupid}} ["{{installerFilename}}", "{{responseFile.name}}", "{{{tempDir}}}/{{{type}}}/"]
 {{/installPackages}}
 COPY --chown={{userid}}:{{groupid}} oraInst.loc {{inv_loc}}/
 
@@ -38,7 +38,7 @@ RUN echo "INSTALLING MIDDLEWARE" \
 {{#installPackages}}
   && echo "INSTALLING {{type}}" \
   # If installer is packaged in a ZIP, extract it before running it
-  {{#isZip}}&& unzip -q {{{tempDir}}}/{{{type}}}/{{installerFilename}} -d {{{tempDir}}}/{{{type}}} {{/isZip}} \
+  {{#isZip}}&& unzip -q "{{{tempDir}}}/{{{type}}}/{{installerFilename}}" -d {{{tempDir}}}/{{{type}}} {{/isZip}} \
   {{#preinstallCommands}}&& {{{tempDir}}}/{{{type}}}/{{{.}}} {{/preinstallCommands}} \
   # IF the installer is a JAR file (not a .bin), run the silent install using Java
   {{^isBin}}  && {{{java_home}}}/bin/java -Xmx1024m -jar {{{tempDir}}}/{{{type}}}/{{jarName}} \
diff --git a/pom.xml b/pom.xml
index 3338ede0..71dba6aa 100644
--- a/pom.xml
+++ b/pom.xml
@@ -281,7 +281,7 @@
                 <plugin>
                     <groupId>org.sonarsource.scanner.maven</groupId>
                     <artifactId>sonar-maven-plugin</artifactId>
-                    <version>4.0.0.4121</version>
+                    <version>5.0.0.4389</version>
                 </plugin>
                 <plugin>
                     <groupId>org.apache.maven.plugins</groupId>

From eb25493950854dc1fc36095f78300cc0d871c878 Mon Sep 17 00:00:00 2001
From: Derek Sharpe <derek.sharpe@oracle.com>
Date: Wed, 5 Feb 2025 11:19:46 -0600
Subject: [PATCH 4/4] release 1.14.4

---
 bug_release.sh    | 5 +++--
 imagetool/pom.xml | 2 +-
 installer/pom.xml | 2 +-
 pom.xml           | 2 +-
 tests/pom.xml     | 2 +-
 5 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/bug_release.sh b/bug_release.sh
index 64588b02..6bdc4766 100755
--- a/bug_release.sh
+++ b/bug_release.sh
@@ -1,5 +1,6 @@
 #!/bin/bash
 # Only use this script when releasing bug fixes (removes SNAPSHOT for version)
+set -e
 git checkout main
 
 project_version=$(mvn help:evaluate -q -DforceStdout -D"expression=project.version")
@@ -15,7 +16,7 @@ echo New Version: ${new_version}
 mvn versions:set -DremoveSnapshot -DgenerateBackupPoms=false
 mvn clean install
 git add .
-git commit -m \"release ${project_version_number_only}\"
+git commit -m "release ${project_version_number_only}"
 git push
 
 git tag release-${project_version_number_only}
@@ -24,6 +25,6 @@ git push origin release-${project_version_number_only}
 mvn versions:set -DgenerateBackupPoms=false -DnewVersion=${new_version}
 mvn clean install
 git add .
-git commit -m \"preparing for next development iteration\"
+git commit -m "preparing for next development iteration"
 git push
 
diff --git a/imagetool/pom.xml b/imagetool/pom.xml
index d5439e4f..6d543ff0 100644
--- a/imagetool/pom.xml
+++ b/imagetool/pom.xml
@@ -13,7 +13,7 @@
     <parent>
         <artifactId>imagetool-parent</artifactId>
         <groupId>com.oracle.weblogic.lifecycle.imagetool</groupId>
-        <version>1.14.4-SNAPSHOT</version>
+        <version>1.14.4</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
 
diff --git a/installer/pom.xml b/installer/pom.xml
index 52b3c9a5..46260a22 100644
--- a/installer/pom.xml
+++ b/installer/pom.xml
@@ -13,7 +13,7 @@
     <parent>
         <artifactId>imagetool-parent</artifactId>
         <groupId>com.oracle.weblogic.lifecycle.imagetool</groupId>
-        <version>1.14.4-SNAPSHOT</version>
+        <version>1.14.4</version>
         <relativePath>../pom.xml</relativePath>
     </parent>
 
diff --git a/pom.xml b/pom.xml
index 71dba6aa..485c44cf 100644
--- a/pom.xml
+++ b/pom.xml
@@ -8,7 +8,7 @@
     <modelVersion>4.0.0</modelVersion>
     <groupId>com.oracle.weblogic.lifecycle.imagetool</groupId>
     <artifactId>imagetool-parent</artifactId>
-    <version>1.14.4-SNAPSHOT</version>
+    <version>1.14.4</version>
     <packaging>pom</packaging>
 
     <name>WebLogic Image Tool</name>
diff --git a/tests/pom.xml b/tests/pom.xml
index 9ce217a0..c8a8adaf 100644
--- a/tests/pom.xml
+++ b/tests/pom.xml
@@ -12,7 +12,7 @@
     <parent>
         <artifactId>imagetool-parent</artifactId>
         <groupId>com.oracle.weblogic.lifecycle.imagetool</groupId>
-        <version>1.14.4-SNAPSHOT</version>
+        <version>1.14.4</version>
         <relativePath>../pom.xml</relativePath>
     </parent>