This is an automated email from the ASF dual-hosted git repository.

benjobs pushed a commit to branch dev-2.1.4
in repository https://gitbox.apache.org/repos/asf/incubator-streampark.git


The following commit(s) were added to refs/heads/dev-2.1.4 by this push:
     new d59e269d3 [Improve] maven build args check improvements
d59e269d3 is described below

commit d59e269d3e1fc80c55a3fd188e04ebd51292d59f
Author: benjobs <[email protected]>
AuthorDate: Fri Mar 22 16:31:38 2024 +0800

    [Improve] maven build args check improvements
---
 .../core/controller/ApplicationController.java     |  2 +-
 .../streampark/console/core/entity/Project.java    | 76 +++++++++++-----------
 2 files changed, 38 insertions(+), 40 deletions(-)

diff --git 
a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/controller/ApplicationController.java
 
b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/controller/ApplicationController.java
index 1eacf882d..f3cb05fb8 100644
--- 
a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/controller/ApplicationController.java
+++ 
b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/controller/ApplicationController.java
@@ -391,7 +391,7 @@ public class ApplicationController {
     } else if (pathPart == null) {
       error =
           "The path to store the checkpoint data in is null. Please specify a 
directory path for the checkpoint data.";
-    } else if (pathPart.length() == 0 || "/".equals(pathPart)) {
+    } else if (pathPart.isEmpty() || "/".equals(pathPart)) {
       error = "Cannot use the root directory for checkpoints.";
     }
     if (error != null) {
diff --git 
a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/Project.java
 
b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/Project.java
index 3f2491f15..67c2ec772 100644
--- 
a/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/Project.java
+++ 
b/streampark-console/streampark-console-service/src/main/java/org/apache/streampark/console/core/entity/Project.java
@@ -188,6 +188,40 @@ public class Project implements Serializable {
 
   @JsonIgnore
   public String getMavenArgs() {
+    StringBuilder mvnArgBuffer = new StringBuilder("clean package -DskipTests 
");
+    if (StringUtils.isNotBlank(this.buildArgs)) {
+      mvnArgBuffer.append(this.buildArgs.trim());
+    }
+
+    // --settings
+    String setting = 
InternalConfigHolder.get(CommonConfig.MAVEN_SETTINGS_PATH());
+    if (StringUtils.isNotBlank(setting)) {
+      File file = new File(setting);
+      if (file.exists() && file.isFile()) {
+        mvnArgBuffer.append(" --settings ").append(setting.trim());
+      } else {
+        throw new IllegalArgumentException(
+            String.format(
+                "Invalid maven-setting file path \"%s\", the path not exist or 
is not file",
+                setting));
+      }
+    }
+
+    // check maven args
+    String mvnArgs = mvnArgBuffer.toString();
+    if (mvnArgs.contains("\n")) {
+      throw new IllegalArgumentException(
+          String.format(
+              "Illegal argument: newline character in maven build parameters: 
\"%s\"", mvnArgs));
+    }
+
+    String args = getIllegalArgs(mvnArgs);
+    if (args != null) {
+      throw new IllegalArgumentException(
+          String.format("Illegal argument: \"%s\" in maven build parameters: 
%s", args, mvnArgs));
+    }
+
+    // find mvn
     boolean windows = Utils.isWindows();
     String mvn = windows ? "mvn.cmd" : "mvn";
 
@@ -211,48 +245,12 @@ public class Project implements Serializable {
 
     if (useWrapper) {
       if (windows) {
-        mvn = WebUtils.getAppHome().concat("/bin/mvnw.cmd");
-      } else {
-        mvn = WebUtils.getAppHome().concat("/bin/mvnw");
-      }
-    }
-
-    StringBuilder cmdBuffer = new StringBuilder(mvn).append(" clean package 
-DskipTests ");
-    if (StringUtils.isNotBlank(this.buildArgs)) {
-      this.buildArgs = this.buildArgs.trim();
-      if (this.buildArgs.contains("\n")) {
-        throw new IllegalArgumentException(
-            String.format(
-                "Illegal argument: newline character in maven build 
parameters: \"%s\"",
-                this.buildArgs));
-      }
-      String args = getIllegalArgs(this.buildArgs);
-      if (args != null) {
-        throw new IllegalArgumentException(
-            String.format(
-                "Illegal argument: \"%s\" in maven build parameters: %s", 
args, this.buildArgs));
-      }
-      cmdBuffer.append(this.buildArgs);
-    }
-
-    String setting = 
InternalConfigHolder.get(CommonConfig.MAVEN_SETTINGS_PATH());
-    if (StringUtils.isNotBlank(setting)) {
-      String args = getIllegalArgs(setting);
-      if (args != null) {
-        throw new IllegalArgumentException(
-            String.format("Illegal argument \"%s\" in maven-setting file path: 
%s", args, setting));
-      }
-      File file = new File(setting);
-      if (file.exists() && file.isFile()) {
-        cmdBuffer.append(" --settings ").append(setting);
+        mvn = WebUtils.getAppHome().concat("/bin/mvnw.cmd ");
       } else {
-        throw new IllegalArgumentException(
-            String.format(
-                "Invalid maven-setting file path \"%s\", the path not exist or 
is not file",
-                setting));
+        mvn = WebUtils.getAppHome().concat("/bin/mvnw ");
       }
     }
-    return cmdBuffer.toString();
+    return mvn.concat(mvnArgs);
   }
 
   private String getIllegalArgs(String param) {

Reply via email to