This is an automated email from the ASF dual-hosted git repository.
zihaoxiang pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/dolphinscheduler.git
The following commit(s) were added to refs/heads/dev by this push:
new bd48c99178 [BUG][Task] fix java task classpath (#15470)
bd48c99178 is described below
commit bd48c991783b2e0ea0c602f6ef6c9a09c92e7b42
Author: lizhenglei <[email protected]>
AuthorDate: Fri Jan 12 14:39:59 2024 +0800
[BUG][Task] fix java task classpath (#15470)
* fix javatask bug
* cover
---------
Co-authored-by: 80597928 <[email protected]>
Co-authored-by: fuchanghai <[email protected]>
---
.../java/org/apache/dolphinscheduler/plugin/task/java/JavaTask.java | 2 +-
.../org/apache/dolphinscheduler/plugin/task/java/JavaTaskTest.java | 6 +++---
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git
a/dolphinscheduler-task-plugin/dolphinscheduler-task-java/src/main/java/org/apache/dolphinscheduler/plugin/task/java/JavaTask.java
b/dolphinscheduler-task-plugin/dolphinscheduler-task-java/src/main/java/org/apache/dolphinscheduler/plugin/task/java/JavaTask.java
index 43dd5de586..179b50c35c 100644
---
a/dolphinscheduler-task-plugin/dolphinscheduler-task-java/src/main/java/org/apache/dolphinscheduler/plugin/task/java/JavaTask.java
+++
b/dolphinscheduler-task-plugin/dolphinscheduler-task-java/src/main/java/org/apache/dolphinscheduler/plugin/task/java/JavaTask.java
@@ -280,7 +280,7 @@ public class JavaTask extends AbstractTask {
if (javaParameters.isModulePath()) {
builder.append("--module-path");
} else {
- builder.append("--class-path");
+ builder.append("-classpath");
}
builder.append(" ")
.append(JavaConstants.CLASSPATH_CURRENT_DIR)
diff --git
a/dolphinscheduler-task-plugin/dolphinscheduler-task-java/src/test/java/org/apache/dolphinscheduler/plugin/task/java/JavaTaskTest.java
b/dolphinscheduler-task-plugin/dolphinscheduler-task-java/src/test/java/org/apache/dolphinscheduler/plugin/task/java/JavaTaskTest.java
index 39e1dac18d..7ea5a792b7 100644
---
a/dolphinscheduler-task-plugin/dolphinscheduler-task-java/src/test/java/org/apache/dolphinscheduler/plugin/task/java/JavaTaskTest.java
+++
b/dolphinscheduler-task-plugin/dolphinscheduler-task-java/src/test/java/org/apache/dolphinscheduler/plugin/task/java/JavaTaskTest.java
@@ -84,7 +84,7 @@ public class JavaTaskTest {
String homeBinPath = JavaConstants.JAVA_HOME_VAR + File.separator +
"bin" + File.separator;
JavaTask javaTask = runJarType();
Assertions.assertEquals(javaTask.buildJarCommand(), homeBinPath
- + "java --class-path
.:/tmp/dolphinscheduler/test/executepath:/tmp/dolphinscheduler/test/executepath/opt/share/jar/resource2.jar
-jar /tmp/dolphinscheduler/test/executepath/opt/share/jar/main.jar -host
127.0.0.1 -port 8080 -xms:50m");
+ + "java -classpath
.:/tmp/dolphinscheduler/test/executepath:/tmp/dolphinscheduler/test/executepath/opt/share/jar/resource2.jar
-jar /tmp/dolphinscheduler/test/executepath/opt/share/jar/main.jar -host
127.0.0.1 -port 8080 -xms:50m");
}
/**
@@ -106,7 +106,7 @@ public class JavaTaskTest {
Files.delete(path);
}
Assertions.assertEquals(homeBinPath
- + "javac --class-path
.:/tmp/dolphinscheduler/test/executepath:/tmp/dolphinscheduler/test/executepath/opt/share/jar/resource2.jar
/tmp/dolphinscheduler/test/executepath/JavaTaskTest.java",
+ + "javac -classpath
.:/tmp/dolphinscheduler/test/executepath:/tmp/dolphinscheduler/test/executepath/opt/share/jar/resource2.jar
/tmp/dolphinscheduler/test/executepath/JavaTaskTest.java",
javaTask.buildJavaCompileCommand(sourceCode));
} finally {
Path path = Paths.get(fileName);
@@ -125,7 +125,7 @@ public class JavaTaskTest {
@Test
public void buildJavaCommand() throws Exception {
String wantJavaCommand =
- "${JAVA_HOME}/bin/javac --class-path
.:/tmp/dolphinscheduler/test/executepath:/tmp/dolphinscheduler/test/executepath/opt/share/jar/resource2.jar
/tmp/dolphinscheduler/test/executepath/JavaTaskTest.java;${JAVA_HOME}/bin/java
--class-path
.:/tmp/dolphinscheduler/test/executepath:/tmp/dolphinscheduler/test/executepath/opt/share/jar/resource2.jar
JavaTaskTest -host 127.0.0.1 -port 8080 -xms:50m";
+ "${JAVA_HOME}/bin/javac -classpath
.:/tmp/dolphinscheduler/test/executepath:/tmp/dolphinscheduler/test/executepath/opt/share/jar/resource2.jar
/tmp/dolphinscheduler/test/executepath/JavaTaskTest.java;${JAVA_HOME}/bin/java
-classpath
.:/tmp/dolphinscheduler/test/executepath:/tmp/dolphinscheduler/test/executepath/opt/share/jar/resource2.jar
JavaTaskTest -host 127.0.0.1 -port 8080 -xms:50m";
JavaTask javaTask = runJavaType();
String sourceCode = javaTask.buildJavaSourceContent();
String publicClassName = javaTask.getPublicClassName(sourceCode);