You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dolphinscheduler.apache.org by "ailiujiarui (via GitHub)" <gi...@apache.org> on 2024/08/29 04:38:30 UTC

[PR] [Feature-15819][Task Plugin]Update the JAVA task [dolphinscheduler]

ailiujiarui opened a new pull request, #16542:
URL: https://github.com/apache/dolphinscheduler/pull/16542

   <!--Thanks very much for contributing to Apache DolphinScheduler, we are happy that you want to help us improve DolphinScheduler! -->
   
   ## Purpose of the pull request
     Update the Java task plugin
     close:https://github.com/apache/dolphinscheduler/issues/15819
   <!--(For example: This pull request adds checkstyle plugin).-->
   
   ## Brief change log
   - *Deprecate write java code in JAVA task*
   - *Rename the JAR to FATJAR*
   - *Add the new type NORMALJAR*
   - *Update the tests*
   - *Update the Javadoc comment*
   ## Verify this pull request
   
   <!--*(Please pick either of the following options)*-->
   
   This pull request is code cleanup without any test coverage.
   
   *(or)*
   
   This pull request is already covered by existing tests, such as *(please describe tests)*.
   
   (or)
   
   This change added tests and can be verified as follows:
   
   <!--*(example:)*
   - *Added dolphinscheduler-dao tests for end-to-end.*
   - *Added CronUtilsTest to verify the change.*
   - *Manually verified the change by testing locally.* -->
   
   (or)
   
   ## Pull Request Notice
   [Pull Request Notice](https://github.com/apache/dolphinscheduler/blob/dev/docs/docs/en/contribute/join/pull-request.md)
   
   If your pull request contain incompatible change, you should also add it to `docs/docs/en/guide/upgrede/incompatible.md`
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [DSIP-27][Task Plugin] Some improvements of JAVA task plugin [dolphinscheduler]

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #16542:
URL: https://github.com/apache/dolphinscheduler/pull/16542#issuecomment-2428092626

   ## [![Quality Gate Failed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-failed-20px.png 'Quality Gate Failed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16542) **Quality Gate failed**  
   Failed conditions  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/failed-16px.png '') [E Reliability Rating on New Code](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16542) (required ≥ A)  
     
   [See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16542)
   
   ##   
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/light_bulb-16px.png '') Catch issues before they fail your Quality Gate with our IDE extension ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/sonarlint-16px.png '') [SonarLint](https://www.sonarsource.com/products/sonarlint/features/connected-mode/?referrer=pull-request)
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [DSIP-27][Task Plugin] Some improvements of JAVA task plugin [dolphinscheduler]

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #16542:
URL: https://github.com/apache/dolphinscheduler/pull/16542#issuecomment-2450280456

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16542) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [5 New issues](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=16542&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=16542&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=16542&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [85.7% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=16542&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=16542&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16542)
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [DSIP-27][Task Plugin] Some improvements of JAVA task plugin [dolphinscheduler]

Posted by "SbloodyS (via GitHub)" <gi...@apache.org>.
SbloodyS commented on code in PR #16542:
URL: https://github.com/apache/dolphinscheduler/pull/16542#discussion_r1814163962


##########
dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/resources/fat.jar:
##########


Review Comment:
   Don't mark unaddressed comment into resolved.



##########
dolphinscheduler-task-plugin/dolphinscheduler-task-java/src/main/java/org/apache/dolphinscheduler/plugin/task/java/MainClassExtractor.java:
##########
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.dolphinscheduler.plugin.task.java;
+
+import java.io.File;
+import java.util.jar.JarFile;
+import java.util.jar.Manifest;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class MainClassExtractor {
+
+    private static final Logger logger = LoggerFactory.getLogger(MainClassExtractor.class);

Review Comment:
   Using `@Slf4j` instead.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [DSIP-27][Task Plugin] Some improvements of JAVA task plugin [dolphinscheduler]

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #16542:
URL: https://github.com/apache/dolphinscheduler/pull/16542#issuecomment-2441081316

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16542) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 New issues](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=16542&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=16542&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=16542&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=16542&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=16542&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16542)
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [DSIP-27][Task Plugin] Some improvements of JAVA task plugin [dolphinscheduler]

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #16542:
URL: https://github.com/apache/dolphinscheduler/pull/16542#issuecomment-2377107123

   Please retry analysis of this Pull-Request directly on SonarCloud


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [DSIP-27][Task Plugin] Some improvements of JAVA task plugin [dolphinscheduler]

Posted by "SbloodyS (via GitHub)" <gi...@apache.org>.
SbloodyS commented on code in PR #16542:
URL: https://github.com/apache/dolphinscheduler/pull/16542#discussion_r1777049236


##########
.github/workflows/e2e.yml:
##########
@@ -124,8 +124,6 @@ jobs:
             class: org.apache.dolphinscheduler.e2e.cases.WorkflowE2ETest
           - name: WorkflowHttpTaskE2ETest
             class: org.apache.dolphinscheduler.e2e.cases.WorkflowHttpTaskE2ETest
-          - name: WorkflowJavaTaskE2ETest
-            class: org.apache.dolphinscheduler.e2e.cases.WorkflowJavaTaskE2ETest

Review Comment:
   Why delete this? CI-related content should not be deleted in PR in general.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [DSIP-27][Task Plugin] Some improvements of JAVA task plugin [dolphinscheduler]

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #16542:
URL: https://github.com/apache/dolphinscheduler/pull/16542#issuecomment-2502503288

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16542) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 New issues](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=16542&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=16542&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=16542&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=16542&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=16542&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16542)
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [DSIP-27][Task Plugin] Some improvements of JAVA task plugin [dolphinscheduler]

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #16542:
URL: https://github.com/apache/dolphinscheduler/pull/16542#issuecomment-2439240282

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16542) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 New issues](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=16542&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=16542&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=16542&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=16542&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=16542&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16542)
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [DSIP-27][Task Plugin] Some improvements of JAVA task plugin [dolphinscheduler]

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #16542:
URL: https://github.com/apache/dolphinscheduler/pull/16542#issuecomment-2449195332

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16542) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 New issues](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=16542&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=16542&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=16542&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [80.6% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=16542&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=16542&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16542)
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [DSIP-27][Task Plugin] Some improvements of JAVA task plugin [dolphinscheduler]

Posted by "pinkfloyds (via GitHub)" <gi...@apache.org>.
pinkfloyds commented on PR #16542:
URL: https://github.com/apache/dolphinscheduler/pull/16542#issuecomment-2449521633

   Don't be discouraged. Keep going and keep up the good work.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [DSIP-27][Task Plugin] Some improvements of JAVA task plugin [dolphinscheduler]

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #16542:
URL: https://github.com/apache/dolphinscheduler/pull/16542#issuecomment-2435494861

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16542) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 New issues](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=16542&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=16542&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=16542&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [80.6% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=16542&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=16542&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16542)
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [DSIP-27][Task Plugin] Some improvements of JAVA task plugin [dolphinscheduler]

Posted by "ailiujiarui (via GitHub)" <gi...@apache.org>.
ailiujiarui commented on code in PR #16542:
URL: https://github.com/apache/dolphinscheduler/pull/16542#discussion_r1828915108


##########
dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/cases/WorkflowJavaTaskE2ETest.java:
##########
@@ -70,16 +97,110 @@ public class WorkflowJavaTaskE2ETest {
 
     private static final String environmentWorkerGroup = "default";
 
-    private static final String javaContent = "public class Test {" +
-            "    public static void main(String[] args) {" +
-            "        System.out.println(\"hello world\");" +
-            "    }" +
-            "}";
+    private static final String filePath = "/tmp";
 
     private static RemoteWebDriver browser;
 
+    private static void createJar(String className, String classFilePath, String entryName, String mainPackage,
+                                  String jarName) {
+
+        String jarFilePath = "/tmp/" + jarName;
+
+        Manifest manifest = new Manifest();
+        manifest.getMainAttributes().put(Attributes.Name.MANIFEST_VERSION, "1.0");
+        manifest.getMainAttributes().put(Attributes.Name.MAIN_CLASS, mainPackage);
+
+        try (
+                FileOutputStream fos = new FileOutputStream(jarFilePath);
+                JarOutputStream jos = new JarOutputStream(fos, manifest)) {
+            Path path = new File(classFilePath + className).toPath();
+            JarEntry entry = new JarEntry(entryName);
+            jos.putNextEntry(entry);
+            byte[] bytes = Files.readAllBytes(path);
+            jos.write(bytes, 0, bytes.length);
+            jos.closeEntry();
+        } catch (IOException e) {
+            log.error("create jar failed:", e);
+        }
+
+    }
+    private static void getJar() {
+        String classPath = "/tmp/common/";
+        compileJavaFile("common/Fat.java");
+        compileJavaFile("common/Normal1.java");
+        compileJavaFile("common/Normal2.java");
+        createJar("Fat.class", classPath,
+                "common/Fat.class",
+                "common.Fat",
+                "fat.jar");
+        createJar("Normal1.class",
+                classPath,
+                "common/Normal1.class",
+                "common.Normal1",
+                "normal1.jar");
+        createJar("Normal2.class",
+                classPath,
+                "common/Normal2.class",
+                "common.Normal2",
+                "normal2.jar");
+
+    }
+
+    public static void compileJavaFile(String sourceFilePath) {
+
+        JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
+        if (compiler == null) {
+            log.error("Cannot find the system Java compiler.", new IllegalStateException());
+        }
+
+        ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+        URL resourceUrl = classLoader.getResource(sourceFilePath);
+        String absolutePath = "";
+
+        try {
+            File resourceFile = new File(resourceUrl.toURI());
+            absolutePath = resourceFile.getAbsolutePath();
+        } catch (Exception e) {
+            log.error(" java file cannot find:", e);
+        }
+
+        String outputDirPath = "/tmp";

Review Comment:
   Has been modified



##########
dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/cases/WorkflowJavaTaskE2ETest.java:
##########
@@ -70,16 +97,110 @@ public class WorkflowJavaTaskE2ETest {
 
     private static final String environmentWorkerGroup = "default";
 
-    private static final String javaContent = "public class Test {" +
-            "    public static void main(String[] args) {" +
-            "        System.out.println(\"hello world\");" +
-            "    }" +
-            "}";
+    private static final String filePath = "/tmp";
 
     private static RemoteWebDriver browser;
 
+    private static void createJar(String className, String classFilePath, String entryName, String mainPackage,
+                                  String jarName) {
+
+        String jarFilePath = "/tmp/" + jarName;
+
+        Manifest manifest = new Manifest();
+        manifest.getMainAttributes().put(Attributes.Name.MANIFEST_VERSION, "1.0");
+        manifest.getMainAttributes().put(Attributes.Name.MAIN_CLASS, mainPackage);
+
+        try (
+                FileOutputStream fos = new FileOutputStream(jarFilePath);
+                JarOutputStream jos = new JarOutputStream(fos, manifest)) {
+            Path path = new File(classFilePath + className).toPath();
+            JarEntry entry = new JarEntry(entryName);
+            jos.putNextEntry(entry);
+            byte[] bytes = Files.readAllBytes(path);
+            jos.write(bytes, 0, bytes.length);
+            jos.closeEntry();
+        } catch (IOException e) {
+            log.error("create jar failed:", e);
+        }
+
+    }
+    private static void getJar() {
+        String classPath = "/tmp/common/";
+        compileJavaFile("common/Fat.java");
+        compileJavaFile("common/Normal1.java");
+        compileJavaFile("common/Normal2.java");
+        createJar("Fat.class", classPath,
+                "common/Fat.class",
+                "common.Fat",
+                "fat.jar");
+        createJar("Normal1.class",
+                classPath,
+                "common/Normal1.class",
+                "common.Normal1",
+                "normal1.jar");
+        createJar("Normal2.class",
+                classPath,
+                "common/Normal2.class",
+                "common.Normal2",
+                "normal2.jar");
+
+    }
+
+    public static void compileJavaFile(String sourceFilePath) {
+
+        JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
+        if (compiler == null) {
+            log.error("Cannot find the system Java compiler.", new IllegalStateException());
+        }
+
+        ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+        URL resourceUrl = classLoader.getResource(sourceFilePath);
+        String absolutePath = "";
+
+        try {
+            File resourceFile = new File(resourceUrl.toURI());
+            absolutePath = resourceFile.getAbsolutePath();
+        } catch (Exception e) {
+            log.error(" java file cannot find:", e);
+        }
+
+        String outputDirPath = "/tmp";
+
+        try (StandardJavaFileManager fileManager = compiler.getStandardFileManager(null, null, null)) {
+
+            File sourceFile = new File(absolutePath);
+            if (!sourceFile.exists()) {
+                log.error("java file not exist", new IllegalArgumentException());
+            }
+
+            Iterable<? extends JavaFileObject> compilationUnits =
+                    fileManager.getJavaFileObjectsFromFiles(Arrays.asList(sourceFile));
+
+            List<String> options = Arrays.asList(
+                    "--release", "8",
+                    "-d", outputDirPath);
+
+            JavaCompiler.CompilationTask task = compiler.getTask(
+                    null,
+                    fileManager,
+                    null,
+                    options,
+                    null,
+                    compilationUnits);
+
+            boolean success = task.call();
+
+            if (!success) {
+                throw new RuntimeException("Compilation failed.");
+            }
+        } catch (IOException e) {
+            log.error("compile java file failed:", e);

Review Comment:
   Has been modified



##########
dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/cases/WorkflowJavaTaskE2ETest.java:
##########
@@ -70,16 +97,110 @@ public class WorkflowJavaTaskE2ETest {
 
     private static final String environmentWorkerGroup = "default";
 
-    private static final String javaContent = "public class Test {" +
-            "    public static void main(String[] args) {" +
-            "        System.out.println(\"hello world\");" +
-            "    }" +
-            "}";
+    private static final String filePath = "/tmp";
 
     private static RemoteWebDriver browser;
 
+    private static void createJar(String className, String classFilePath, String entryName, String mainPackage,
+                                  String jarName) {
+
+        String jarFilePath = "/tmp/" + jarName;
+
+        Manifest manifest = new Manifest();
+        manifest.getMainAttributes().put(Attributes.Name.MANIFEST_VERSION, "1.0");
+        manifest.getMainAttributes().put(Attributes.Name.MAIN_CLASS, mainPackage);
+
+        try (
+                FileOutputStream fos = new FileOutputStream(jarFilePath);
+                JarOutputStream jos = new JarOutputStream(fos, manifest)) {
+            Path path = new File(classFilePath + className).toPath();
+            JarEntry entry = new JarEntry(entryName);
+            jos.putNextEntry(entry);
+            byte[] bytes = Files.readAllBytes(path);
+            jos.write(bytes, 0, bytes.length);
+            jos.closeEntry();
+        } catch (IOException e) {
+            log.error("create jar failed:", e);
+        }
+
+    }
+    private static void getJar() {
+        String classPath = "/tmp/common/";
+        compileJavaFile("common/Fat.java");
+        compileJavaFile("common/Normal1.java");
+        compileJavaFile("common/Normal2.java");
+        createJar("Fat.class", classPath,
+                "common/Fat.class",
+                "common.Fat",
+                "fat.jar");
+        createJar("Normal1.class",
+                classPath,
+                "common/Normal1.class",
+                "common.Normal1",
+                "normal1.jar");
+        createJar("Normal2.class",
+                classPath,
+                "common/Normal2.class",
+                "common.Normal2",
+                "normal2.jar");
+
+    }
+
+    public static void compileJavaFile(String sourceFilePath) {
+
+        JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
+        if (compiler == null) {
+            log.error("Cannot find the system Java compiler.", new IllegalStateException());
+        }
+
+        ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+        URL resourceUrl = classLoader.getResource(sourceFilePath);
+        String absolutePath = "";
+
+        try {
+            File resourceFile = new File(resourceUrl.toURI());
+            absolutePath = resourceFile.getAbsolutePath();
+        } catch (Exception e) {
+            log.error(" java file cannot find:", e);
+        }
+
+        String outputDirPath = "/tmp";
+
+        try (StandardJavaFileManager fileManager = compiler.getStandardFileManager(null, null, null)) {
+
+            File sourceFile = new File(absolutePath);
+            if (!sourceFile.exists()) {
+                log.error("java file not exist", new IllegalArgumentException());
+            }
+
+            Iterable<? extends JavaFileObject> compilationUnits =
+                    fileManager.getJavaFileObjectsFromFiles(Arrays.asList(sourceFile));
+
+            List<String> options = Arrays.asList(
+                    "--release", "8",
+                    "-d", outputDirPath);
+
+            JavaCompiler.CompilationTask task = compiler.getTask(
+                    null,
+                    fileManager,
+                    null,
+                    options,
+                    null,
+                    compilationUnits);
+
+            boolean success = task.call();
+
+            if (!success) {
+                throw new RuntimeException("Compilation failed.");

Review Comment:
   Has been modified



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [DSIP-27][Task Plugin] Some improvements of JAVA task plugin [dolphinscheduler]

Posted by "ailiujiarui (via GitHub)" <gi...@apache.org>.
ailiujiarui commented on code in PR #16542:
URL: https://github.com/apache/dolphinscheduler/pull/16542#discussion_r1846165470


##########
dolphinscheduler-task-plugin/dolphinscheduler-task-java/src/main/java/org/apache/dolphinscheduler/plugin/task/java/MainClassExtractor.java:
##########
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.dolphinscheduler.plugin.task.java;
+
+import java.io.File;
+import java.util.jar.JarFile;
+import java.util.jar.Manifest;
+
+import lombok.extern.slf4j.Slf4j;
+
+@Slf4j
+public class MainClassExtractor {
+
+    private MainClassExtractor() {
+    }
+    public static String getMainClassName(String jarFilePath) {
+        String mainClassName = null;
+        try (JarFile jarFile = new JarFile(new File(jarFilePath))) {
+
+            Manifest manifest = jarFile.getManifest();
+            mainClassName = manifest.getMainAttributes().getValue("Main-Class");
+
+        } catch (Exception e) {
+            log.error("get mainJarName failed:", e);

Review Comment:
   Has been deleted



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [DSIP-27][Task Plugin] Some improvements of JAVA task plugin [dolphinscheduler]

Posted by "ailiujiarui (via GitHub)" <gi...@apache.org>.
ailiujiarui commented on PR #16542:
URL: https://github.com/apache/dolphinscheduler/pull/16542#issuecomment-2488654133

   > > > There are some CI failed. Please check it. @ailiujiarui
   > > 
   > > 
   > > The bug has been fixed
   > 
   > The `WorkflowJavaTaskE2ETest` still failed.
   
   I've encountered a similar issue before as well. What worked for me was rerunning the entire test from the beginning, and that allowed it to pass successfully.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [DSIP-27][Task Plugin] Some improvements of JAVA task plugin [dolphinscheduler]

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #16542:
URL: https://github.com/apache/dolphinscheduler/pull/16542#issuecomment-2525246415

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16542) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 New issues](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=16542&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=16542&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=16542&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=16542&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=16542&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16542)
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [DSIP-27][Task Plugin] Some improvements of JAVA task plugin [dolphinscheduler]

Posted by "ailiujiarui (via GitHub)" <gi...@apache.org>.
ailiujiarui commented on PR #16542:
URL: https://github.com/apache/dolphinscheduler/pull/16542#issuecomment-2408803212

   > 请先解决冲突。
   
   Conflict has been resolved.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [DSIP-27][Task Plugin] Some improvements of JAVA task plugin [dolphinscheduler]

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #16542:
URL: https://github.com/apache/dolphinscheduler/pull/16542#issuecomment-2408808276

   ## [![Quality Gate Failed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-failed-20px.png 'Quality Gate Failed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16542) **Quality Gate failed**  
   Failed conditions  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/failed-16px.png '') [E Reliability Rating on New Code](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16542) (required ≥ A)  
     
   [See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16542)
   
   ##   
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/light_bulb-16px.png '') Catch issues before they fail your Quality Gate with our IDE extension ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/sonarlint-16px.png '') [SonarLint](https://www.sonarsource.com/products/sonarlint/features/connected-mode/?referrer=pull-request)
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [DSIP-27][Task Plugin] Some improvements of JAVA task plugin [dolphinscheduler]

Posted by "ailiujiarui (via GitHub)" <gi...@apache.org>.
ailiujiarui commented on PR #16542:
URL: https://github.com/apache/dolphinscheduler/pull/16542#issuecomment-2498241284

   > > I've encountered a similar issue before as well. What worked for me was rerunning the entire test from the beginning, and that allowed it to pass successfully.
   > 
   > You should check the error message of `java.lang.RuntimeException: No such package: normal1.jar at org.apache.dolphinscheduler.e2e.cases.WorkflowJavaTaskE2ETest.testCreateNormalJarWorkflow(WorkflowJavaTaskE2ETest.java:341)`
   
   Through testing, it was found that unstable file uploads—often resulting in failed uploads—and frequently missing resource file selections in the Resources panel are caused by the component's loading process. Specifically, webwait only detects the presence of DOM elements without ensuring that their child elements have fully loaded. In other words, the code continues to execute before the page is completely rendered, leading to these issues.
   
   To address this problem, I implemented thread.sleep to wait for the complete loading. This method is currently stable and effective. I also considered other approaches, but none could effectively and concisely replace it.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [DSIP-27][Task Plugin] Some improvements of JAVA task plugin [dolphinscheduler]

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #16542:
URL: https://github.com/apache/dolphinscheduler/pull/16542#issuecomment-2482522424

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16542) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [1 New issue](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=16542&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=16542&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=16542&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [86.7% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=16542&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=16542&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16542)
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [DSIP-27][Task Plugin] Some improvements of JAVA task plugin [dolphinscheduler]

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #16542:
URL: https://github.com/apache/dolphinscheduler/pull/16542#issuecomment-2449198541

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16542) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 New issues](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=16542&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=16542&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=16542&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [80.6% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=16542&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=16542&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16542)
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [DSIP-27][Task Plugin] Some improvements of JAVA task plugin [dolphinscheduler]

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #16542:
URL: https://github.com/apache/dolphinscheduler/pull/16542#issuecomment-2487777215

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16542) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [1 New issue](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=16542&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=16542&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=16542&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [86.7% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=16542&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=16542&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16542)
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [DSIP-27][Task Plugin] Some improvements of JAVA task plugin [dolphinscheduler]

Posted by "ailiujiarui (via GitHub)" <gi...@apache.org>.
ailiujiarui commented on code in PR #16542:
URL: https://github.com/apache/dolphinscheduler/pull/16542#discussion_r1828884674


##########
dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/cases/WorkflowJavaTaskE2ETest.java:
##########
@@ -121,35 +247,47 @@ public static void cleanup() {
 
     @Test
     @Order(1)
-    void testCreateWorkflow() {
-        WorkflowDefinitionTab workflowDefinitionPage =
-                new ProjectPage(browser)
-                        .goTo(project)
-                        .goToTab(WorkflowDefinitionTab.class);
+    void testCreateFatWorkflow() {
+        FileManagePage file = new NavBarPage(browser)
+                .goToNav(ResourcePage.class)
+                .goToTab(FileManagePage.class)
+                .uploadFile(filePath + "/fat.jar");
+
+        WebDriverWait wait = WebDriverWaitFactory.createWebDriverWait(browser);
 
-        workflowDefinitionPage
-                .createWorkflow()
-                .<JavaTaskForm>addTask(WorkflowForm.TaskType.JAVA)
-                .script(javaContent)
+        wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//span[text()='fat.jar']")));
+
+        ProjectPage projectPage = new NavBarPage(browser)
+                .goToNav(ProjectPage.class);
+
+        wait.until(ExpectedConditions.visibilityOfAllElements(projectPage.projectList()));
+
+        WorkflowDefinitionTab workflowDefinitionPage = projectPage
+                .goTo(project)
+                .goToTab(WorkflowDefinitionTab.class);
+
+        WorkflowForm workflow1 = workflowDefinitionPage.createWorkflow();
+        workflow1.<JavaTaskForm>addTask(WorkflowForm.TaskType.JAVA)
+                .selectRunType("FAT_JAR")
+                .selectMainPackage("fat.jar")
+                .selectJavaResource("fat.jar")
                 .name("test-1")
-                .addParam("today", "${system.datetime}")
                 .selectEnv(environmentName)
                 .submit()
                 .submit()
                 .name(workflow)
-                .addGlobalParam("global_param", "hello world")
                 .submit();
 
         Awaitility.await().untilAsserted(() -> assertThat(workflowDefinitionPage.workflowList())
                 .as("Workflow list should contain newly-created workflow")
-                .anyMatch(
-                        it -> it.getText().contains(workflow)));
+                .anyMatch(it -> it.getText().contains(workflow)));
+
         workflowDefinitionPage.publish(workflow);
     }
 
     @Test
     @Order(30)
-    void testRunWorkflow() {
+    void testRunFatWorkflow() {

Review Comment:
   The normal jar test has been added



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [DSIP-27][Task Plugin] Some improvements of JAVA task plugin [dolphinscheduler]

Posted by "ailiujiarui (via GitHub)" <gi...@apache.org>.
ailiujiarui commented on code in PR #16542:
URL: https://github.com/apache/dolphinscheduler/pull/16542#discussion_r1814068808


##########
dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/cases/WorkflowJavaTaskE2ETest.java:
##########
@@ -97,6 +100,11 @@ public static void setup() {
         userPage.update(user, user, email, phone, tenant)
                 .goToNav(ProjectPage.class)
                 .create(project);
+
+        ProjectPage projectPage = new ProjectPage(browser);
+        Awaitility.await().untilAsserted(() -> assertThat(projectPage.projectList())
+                .as("项目列表应包含新创建的项目")

Review Comment:
   The code has been modified.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [DSIP-27][Task Plugin] Some improvements of JAVA task plugin [dolphinscheduler]

Posted by "ailiujiarui (via GitHub)" <gi...@apache.org>.
ailiujiarui commented on code in PR #16542:
URL: https://github.com/apache/dolphinscheduler/pull/16542#discussion_r1865181327


##########
dolphinscheduler-task-plugin/dolphinscheduler-task-java/src/main/java/org/apache/dolphinscheduler/plugin/task/java/JavaTask.java:
##########
@@ -150,44 +133,45 @@ public void handle(TaskCallBack taskCallBack) throws TaskException {
     }
 
     /**
-     * Construct a shell command for the java Run mode
+     * Construct a shell command for the java -jar Run mode
      *
      * @return String
-     * @throws Exception
      **/
-    protected String buildJavaCommand() throws Exception {
+    protected String buildJarCommand() {
+        ResourceContext resourceContext = taskRequest.getResourceContext();
+        String mainJarAbsolutePathInLocal = resourceContext
+                .getResourceItem(javaParameters.getMainJar().getResourceName())
+                .getResourceAbsolutePathInLocal();
         StringBuilder builder = new StringBuilder();
-        String sourceCode = buildJavaSourceContent();
-        builder.append(buildJavaCompileCommand(sourceCode))
-                .append(";")
-                .append(getJavaCommandPath())
-                .append("java").append(" ")
-                .append(buildResourcePath())
-                .append(" ")
-                .append(getPublicClassName(sourceCode))
-                .append(" ")
-                .append(javaParameters.getMainArgs().trim()).append(" ")
+        builder.append(getJavaCommandPath())
+                .append("java").append(Constants.SPACE)
+                .append(buildResourcePath()).append(Constants.SPACE)
+                .append("-jar").append(Constants.SPACE)
+                .append(mainJarAbsolutePathInLocal).append(Constants.SPACE)
+                .append(javaParameters.getMainArgs().trim()).append(Constants.SPACE)
                 .append(javaParameters.getJvmArgs().trim());
         return builder.toString();
     }
 
     /**
-     * Construct a shell command for the java -jar Run mode
+     * Construct a shell command for the java -cp run mode
      *
      * @return String
      **/
-    protected String buildJarCommand() {
+    protected String buildNormalJarCommand() {
         ResourceContext resourceContext = taskRequest.getResourceContext();
-        String mainJarAbsolutePathInLocal = resourceContext
-                .getResourceItem(javaParameters.getMainJar().getResourceName())
+        String mainJarAbsolutePathInLocal = resourceContext.getResourceItem(
+                javaParameters.getMainJar()
+                        .getResourceName())
                 .getResourceAbsolutePathInLocal();
+        String mainJarName = MainClassExtractor.getMainClassName(mainJarAbsolutePathInLocal);

Review Comment:
   This functionality has been implemented to let users choose whether to input the main class name. If they do not provide it, the main class name will be extracted from the main program package.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [DSIP-27][Task Plugin] Some improvements of JAVA task plugin [dolphinscheduler]

Posted by "ailiujiarui (via GitHub)" <gi...@apache.org>.
ailiujiarui commented on code in PR #16542:
URL: https://github.com/apache/dolphinscheduler/pull/16542#discussion_r1865180150


##########
docs/docs/zh/guide/task/java.md:
##########
@@ -22,25 +22,39 @@
 | 模块路径     | 开启使用JAVA9+的模块化特性,把所有资源放入--module-path中,要求您的worker中的JDK版本支持模块化 |
 | 主程序参数    | 作为普通Java程序main方法入口参数                                          |
 | 虚拟机参数    | 配置启动虚拟机参数                                                     |
-| 脚本       | 若使用JAVA运行类型则需要编写JAVA代码。代码中必须存在public类,不用写package语句            |
+| 主程序包     | 选择要运行程序的主程序包                                                  |
 | 资源       | 可以是外部JAR包也可以是其他资源文件,它们都会被加入到类路径或模块路径中,您可以在自己的JAVA脚本中轻松获取      |
 
 ## 任务样例
 
-java任务类型有两种运行模式,这里以JAVA模式为例进行演示。
+java任务类型有两种运行模式,这里进行分别进行演示。
 
 主要配置参数如下:
 
 - 运行类型
 - 模块路径
 - 主程序参数
 - 虚拟机参数
-- 脚本文件
+- 主程序包
+- 资源文件
 
-![java_task](../../../../img/tasks/demo/java_task02.png)
+如图所示
+
+- FAT_JAR类型
+
+![java_task](../../../../img/tasks/demo/java_fat.png)
+
+`FAT_JAR`即`uber-jar`,依赖和代码都在同一个`jar`中,只需选择这一个`jar`即可
+
+- NORMAL_JAR类型
+
+![java_task](../../../../img/tasks/demo/java_normal.png)
+
+`normal1.jar`是程序运行的入口,`normal2.jar`是所需的依赖,需要用主程序包指定程序的入口,并且在资源文件中选择所有依赖和程序入口的`jar`文件,才能正确运行
 
 ## 注意事项
 
-使用JAVA运行类型时代码中必须存在public类,可以不写package语句
+1. 使用`FAT_JAR`运行类型必须选择主程序包,使用和对应的资源文件,否则任务会直接失败
+2. 使用`NORMAL_JAR`运行类型必须选择主程序包和对应的资源文件,否则任务会直接失败。主程序包决定程序从哪里开始运行,选择资源文件之后,运行程序时,资源文件会以`-cp`的方式进行调用

Review Comment:
   It has been modified.



##########
dolphinscheduler-task-plugin/dolphinscheduler-task-java/src/main/java/org/apache/dolphinscheduler/plugin/task/java/JavaParameters.java:
##########
@@ -67,11 +62,11 @@ public class JavaParameters extends AbstractParameters {
     /**
      * Check that the parameters are valid
      *
-     * @returnboolean
+     * @return boolean
      */
     @Override
     public boolean checkParameters() {
-        return runType != null && (StringUtils.isNotBlank(rawScript) || mainJar != null);
+        return StringUtils.isNotEmpty(runType);

Review Comment:
   It has already been modified.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [DSIP-27][Task Plugin] Some improvements of JAVA task plugin [dolphinscheduler]

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #16542:
URL: https://github.com/apache/dolphinscheduler/pull/16542#issuecomment-2525246194

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16542) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 New issues](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=16542&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=16542&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=16542&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=16542&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=16542&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16542)
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [DSIP-27][Task Plugin] Some improvements of JAVA task plugin [dolphinscheduler]

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #16542:
URL: https://github.com/apache/dolphinscheduler/pull/16542#issuecomment-2435495605

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16542) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 New issues](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=16542&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=16542&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=16542&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [80.6% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=16542&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=16542&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16542)
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [DSIP-27][Task Plugin] Some improvements of JAVA task plugin [dolphinscheduler]

Posted by "ailiujiarui (via GitHub)" <gi...@apache.org>.
ailiujiarui commented on PR #16542:
URL: https://github.com/apache/dolphinscheduler/pull/16542#issuecomment-2450092323

   > Please don't add `.jar` in the source code, the `.jar` file will be excluded in src, these means the e2e will not be executed after release.请不要在源码中添加 `.jar`,`.jar` 文件将被排除在 src 中,这意味着 e2e 发布后不会执行。
   
   I implemented a strategy where the source code is compiled and packaged into a JAR file during the application's runtime. This approach eliminates the necessity of mounting files within the image.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [DSIP-27][Task Plugin] Some improvements of JAVA task plugin [dolphinscheduler]

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #16542:
URL: https://github.com/apache/dolphinscheduler/pull/16542#issuecomment-2450284718

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16542) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [5 New issues](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=16542&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=16542&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=16542&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [85.7% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=16542&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=16542&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16542)
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [DSIP-27][Task Plugin] Some improvements of JAVA task plugin [dolphinscheduler]

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #16542:
URL: https://github.com/apache/dolphinscheduler/pull/16542#issuecomment-2489927878

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16542) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [1 New issue](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=16542&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=16542&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=16542&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [86.7% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=16542&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=16542&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16542)
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [DSIP-27][Task Plugin] Some improvements of JAVA task plugin [dolphinscheduler]

Posted by "ailiujiarui (via GitHub)" <gi...@apache.org>.
ailiujiarui commented on code in PR #16542:
URL: https://github.com/apache/dolphinscheduler/pull/16542#discussion_r1828914512


##########
dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/cases/WorkflowJavaTaskE2ETest.java:
##########
@@ -70,16 +97,110 @@ public class WorkflowJavaTaskE2ETest {
 
     private static final String environmentWorkerGroup = "default";
 
-    private static final String javaContent = "public class Test {" +
-            "    public static void main(String[] args) {" +
-            "        System.out.println(\"hello world\");" +
-            "    }" +
-            "}";
+    private static final String filePath = "/tmp";
 
     private static RemoteWebDriver browser;
 
+    private static void createJar(String className, String classFilePath, String entryName, String mainPackage,
+                                  String jarName) {
+
+        String jarFilePath = "/tmp/" + jarName;

Review Comment:
   Has been modified



##########
dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/cases/WorkflowJavaTaskE2ETest.java:
##########
@@ -70,16 +97,110 @@ public class WorkflowJavaTaskE2ETest {
 
     private static final String environmentWorkerGroup = "default";
 
-    private static final String javaContent = "public class Test {" +
-            "    public static void main(String[] args) {" +
-            "        System.out.println(\"hello world\");" +
-            "    }" +
-            "}";
+    private static final String filePath = "/tmp";
 
     private static RemoteWebDriver browser;
 
+    private static void createJar(String className, String classFilePath, String entryName, String mainPackage,
+                                  String jarName) {
+
+        String jarFilePath = "/tmp/" + jarName;
+
+        Manifest manifest = new Manifest();
+        manifest.getMainAttributes().put(Attributes.Name.MANIFEST_VERSION, "1.0");
+        manifest.getMainAttributes().put(Attributes.Name.MAIN_CLASS, mainPackage);
+
+        try (
+                FileOutputStream fos = new FileOutputStream(jarFilePath);
+                JarOutputStream jos = new JarOutputStream(fos, manifest)) {
+            Path path = new File(classFilePath + className).toPath();
+            JarEntry entry = new JarEntry(entryName);
+            jos.putNextEntry(entry);
+            byte[] bytes = Files.readAllBytes(path);
+            jos.write(bytes, 0, bytes.length);
+            jos.closeEntry();
+        } catch (IOException e) {
+            log.error("create jar failed:", e);

Review Comment:
   Has been modified



##########
dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/cases/WorkflowJavaTaskE2ETest.java:
##########
@@ -70,16 +97,110 @@ public class WorkflowJavaTaskE2ETest {
 
     private static final String environmentWorkerGroup = "default";
 
-    private static final String javaContent = "public class Test {" +
-            "    public static void main(String[] args) {" +
-            "        System.out.println(\"hello world\");" +
-            "    }" +
-            "}";
+    private static final String filePath = "/tmp";
 
     private static RemoteWebDriver browser;
 
+    private static void createJar(String className, String classFilePath, String entryName, String mainPackage,
+                                  String jarName) {
+
+        String jarFilePath = "/tmp/" + jarName;
+
+        Manifest manifest = new Manifest();
+        manifest.getMainAttributes().put(Attributes.Name.MANIFEST_VERSION, "1.0");
+        manifest.getMainAttributes().put(Attributes.Name.MAIN_CLASS, mainPackage);
+
+        try (
+                FileOutputStream fos = new FileOutputStream(jarFilePath);
+                JarOutputStream jos = new JarOutputStream(fos, manifest)) {
+            Path path = new File(classFilePath + className).toPath();
+            JarEntry entry = new JarEntry(entryName);
+            jos.putNextEntry(entry);
+            byte[] bytes = Files.readAllBytes(path);
+            jos.write(bytes, 0, bytes.length);
+            jos.closeEntry();
+        } catch (IOException e) {
+            log.error("create jar failed:", e);
+        }
+
+    }
+    private static void getJar() {
+        String classPath = "/tmp/common/";
+        compileJavaFile("common/Fat.java");
+        compileJavaFile("common/Normal1.java");
+        compileJavaFile("common/Normal2.java");
+        createJar("Fat.class", classPath,
+                "common/Fat.class",
+                "common.Fat",
+                "fat.jar");
+        createJar("Normal1.class",
+                classPath,
+                "common/Normal1.class",
+                "common.Normal1",
+                "normal1.jar");
+        createJar("Normal2.class",
+                classPath,
+                "common/Normal2.class",
+                "common.Normal2",
+                "normal2.jar");
+
+    }
+
+    public static void compileJavaFile(String sourceFilePath) {
+
+        JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
+        if (compiler == null) {
+            log.error("Cannot find the system Java compiler.", new IllegalStateException());
+        }
+
+        ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+        URL resourceUrl = classLoader.getResource(sourceFilePath);
+        String absolutePath = "";
+
+        try {
+            File resourceFile = new File(resourceUrl.toURI());
+            absolutePath = resourceFile.getAbsolutePath();
+        } catch (Exception e) {
+            log.error(" java file cannot find:", e);

Review Comment:
   Has been modified



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [DSIP-27][Task Plugin] Some improvements of JAVA task plugin [dolphinscheduler]

Posted by "ailiujiarui (via GitHub)" <gi...@apache.org>.
ailiujiarui commented on code in PR #16542:
URL: https://github.com/apache/dolphinscheduler/pull/16542#discussion_r1839842845


##########
docs/docs/zh/guide/task/java.md:
##########
@@ -22,25 +22,38 @@
 | 模块路径     | 开启使用JAVA9+的模块化特性,把所有资源放入--module-path中,要求您的worker中的JDK版本支持模块化 |
 | 主程序参数    | 作为普通Java程序main方法入口参数                                          |
 | 虚拟机参数    | 配置启动虚拟机参数                                                     |
-| 脚本       | 若使用JAVA运行类型则需要编写JAVA代码。代码中必须存在public类,不用写package语句            |
+| 主程序包     | 选择要运行程序的主程序包                                                  |
 | 资源       | 可以是外部JAR包也可以是其他资源文件,它们都会被加入到类路径或模块路径中,您可以在自己的JAVA脚本中轻松获取      |
 
 ## 任务样例
 
-java任务类型有两种运行模式,这里以JAVA模式为例进行演示。
+java任务类型有两种运行模式,这里进行分别进行演示。
 
 主要配置参数如下:
 
 - 运行类型
 - 模块路径
 - 主程序参数
 - 虚拟机参数
-- 脚本文件
+- 主程序包
+- 资源文件
 
-![java_task](../../../../img/tasks/demo/java_task02.png)
+如图所示
+
+- FAT_JAR类型
+
+![java_task](../../../../img/tasks/demo/java_fat.png)
+
+因为fat类型的jar,依赖和代码都在同一个jar中,则只需选择这一个jar即可

Review Comment:
   The docs have been updated



##########
docs/docs/zh/guide/task/java.md:
##########
@@ -2,7 +2,7 @@
 
 ## 综述
 
-该节点用于执行 java 类型的任务,支持使用单文件和jar包作为程序入口。
+该节点用于执行 java 类型的任务,支持使用fat类型和normal类型的jar包作为程序入口。

Review Comment:
   The docs have been updated



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [DSIP-27][Task Plugin] Some improvements of JAVA task plugin [dolphinscheduler]

Posted by "ailiujiarui (via GitHub)" <gi...@apache.org>.
ailiujiarui commented on code in PR #16542:
URL: https://github.com/apache/dolphinscheduler/pull/16542#discussion_r1808459662


##########
.github/workflows/e2e.yml:
##########
@@ -124,8 +124,6 @@ jobs:
             class: org.apache.dolphinscheduler.e2e.cases.WorkflowE2ETest
           - name: WorkflowHttpTaskE2ETest
             class: org.apache.dolphinscheduler.e2e.cases.WorkflowHttpTaskE2ETest
-          - name: WorkflowJavaTaskE2ETest
-            class: org.apache.dolphinscheduler.e2e.cases.WorkflowJavaTaskE2ETest

Review Comment:
   > You should modify it base on the new logic according to the previous test case, not delete it.
   The e2e test for Java has been updated.



##########
.github/workflows/e2e.yml:
##########
@@ -124,8 +124,6 @@ jobs:
             class: org.apache.dolphinscheduler.e2e.cases.WorkflowE2ETest
           - name: WorkflowHttpTaskE2ETest
             class: org.apache.dolphinscheduler.e2e.cases.WorkflowHttpTaskE2ETest
-          - name: WorkflowJavaTaskE2ETest
-            class: org.apache.dolphinscheduler.e2e.cases.WorkflowJavaTaskE2ETest

Review Comment:
   > You should modify it base on the new logic according to the previous test case, not delete it.
   
   The e2e test for Java has been updated.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [DSIP-27][Task Plugin] Update the JAVA task [dolphinscheduler]

Posted by "ailiujiarui (via GitHub)" <gi...@apache.org>.
ailiujiarui commented on code in PR #16542:
URL: https://github.com/apache/dolphinscheduler/pull/16542#discussion_r1743531135


##########
dolphinscheduler-task-plugin/dolphinscheduler-task-java/src/main/java/org/apache/dolphinscheduler/plugin/task/java/JavaParameters.java:
##########
@@ -67,11 +60,12 @@ public class JavaParameters extends AbstractParameters {
     /**
      * Check that the parameters are valid
      *
-     * @returnboolean
+     * @return boolean
      */
     @Override
     public boolean checkParameters() {

Review Comment:
   ok



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [DSIP-27][Task Plugin] Some improvements of JAVA task plugin [dolphinscheduler]

Posted by "ailiujiarui (via GitHub)" <gi...@apache.org>.
ailiujiarui commented on code in PR #16542:
URL: https://github.com/apache/dolphinscheduler/pull/16542#discussion_r1839843006


##########
docs/docs/zh/guide/task/java.md:
##########
@@ -22,25 +22,38 @@
 | 模块路径     | 开启使用JAVA9+的模块化特性,把所有资源放入--module-path中,要求您的worker中的JDK版本支持模块化 |
 | 主程序参数    | 作为普通Java程序main方法入口参数                                          |
 | 虚拟机参数    | 配置启动虚拟机参数                                                     |
-| 脚本       | 若使用JAVA运行类型则需要编写JAVA代码。代码中必须存在public类,不用写package语句            |
+| 主程序包     | 选择要运行程序的主程序包                                                  |
 | 资源       | 可以是外部JAR包也可以是其他资源文件,它们都会被加入到类路径或模块路径中,您可以在自己的JAVA脚本中轻松获取      |
 
 ## 任务样例
 
-java任务类型有两种运行模式,这里以JAVA模式为例进行演示。
+java任务类型有两种运行模式,这里进行分别进行演示。
 
 主要配置参数如下:
 
 - 运行类型
 - 模块路径
 - 主程序参数
 - 虚拟机参数
-- 脚本文件
+- 主程序包
+- 资源文件
 
-![java_task](../../../../img/tasks/demo/java_task02.png)
+如图所示
+
+- FAT_JAR类型
+
+![java_task](../../../../img/tasks/demo/java_fat.png)
+
+因为fat类型的jar,依赖和代码都在同一个jar中,则只需选择这一个jar即可
+
+- NORMAL_JAR类型
+
+![java_task](../../../../img/tasks/demo/java_normal.png)
+
+normal1.jar是程序运行的入口,normal2.jar是所需的依赖,需要用主程序包指定程序的入口,并且在资源文件中选择所有依赖和程序入口jar文件,才能正确运行

Review Comment:
   The docs have updated



##########
docs/docs/zh/guide/task/java.md:
##########
@@ -22,25 +22,38 @@
 | 模块路径     | 开启使用JAVA9+的模块化特性,把所有资源放入--module-path中,要求您的worker中的JDK版本支持模块化 |
 | 主程序参数    | 作为普通Java程序main方法入口参数                                          |
 | 虚拟机参数    | 配置启动虚拟机参数                                                     |
-| 脚本       | 若使用JAVA运行类型则需要编写JAVA代码。代码中必须存在public类,不用写package语句            |
+| 主程序包     | 选择要运行程序的主程序包                                                  |
 | 资源       | 可以是外部JAR包也可以是其他资源文件,它们都会被加入到类路径或模块路径中,您可以在自己的JAVA脚本中轻松获取      |
 
 ## 任务样例
 
-java任务类型有两种运行模式,这里以JAVA模式为例进行演示。
+java任务类型有两种运行模式,这里进行分别进行演示。
 
 主要配置参数如下:
 
 - 运行类型
 - 模块路径
 - 主程序参数
 - 虚拟机参数
-- 脚本文件
+- 主程序包
+- 资源文件
 
-![java_task](../../../../img/tasks/demo/java_task02.png)
+如图所示
+
+- FAT_JAR类型
+
+![java_task](../../../../img/tasks/demo/java_fat.png)
+
+因为fat类型的jar,依赖和代码都在同一个jar中,则只需选择这一个jar即可
+
+- NORMAL_JAR类型
+
+![java_task](../../../../img/tasks/demo/java_normal.png)
+
+normal1.jar是程序运行的入口,normal2.jar是所需的依赖,需要用主程序包指定程序的入口,并且在资源文件中选择所有依赖和程序入口jar文件,才能正确运行
 
 ## 注意事项
 
-使用JAVA运行类型时代码中必须存在public类,可以不写package语句
+使用这两种运行类型,都必须选择主程序包和对应的资源文件,否则任务会直接失败。因为主程序包是选择程序从哪里开始运行,资源文件选择文件之后,运行程序时,资源文件才能被加入其中

Review Comment:
   The docs have updated



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [DSIP-27][Task Plugin] Some improvements of JAVA task plugin [dolphinscheduler]

Posted by "ailiujiarui (via GitHub)" <gi...@apache.org>.
ailiujiarui commented on code in PR #16542:
URL: https://github.com/apache/dolphinscheduler/pull/16542#discussion_r1839843185


##########
docs/docs/zh/guide/task/java.md:
##########
@@ -22,25 +22,38 @@
 | 模块路径     | 开启使用JAVA9+的模块化特性,把所有资源放入--module-path中,要求您的worker中的JDK版本支持模块化 |
 | 主程序参数    | 作为普通Java程序main方法入口参数                                          |
 | 虚拟机参数    | 配置启动虚拟机参数                                                     |
-| 脚本       | 若使用JAVA运行类型则需要编写JAVA代码。代码中必须存在public类,不用写package语句            |
+| 主程序包     | 选择要运行程序的主程序包                                                  |
 | 资源       | 可以是外部JAR包也可以是其他资源文件,它们都会被加入到类路径或模块路径中,您可以在自己的JAVA脚本中轻松获取      |
 
 ## 任务样例
 
-java任务类型有两种运行模式,这里以JAVA模式为例进行演示。
+java任务类型有两种运行模式,这里进行分别进行演示。
 
 主要配置参数如下:
 
 - 运行类型
 - 模块路径
 - 主程序参数
 - 虚拟机参数
-- 脚本文件
+- 主程序包
+- 资源文件
 
-![java_task](../../../../img/tasks/demo/java_task02.png)
+如图所示
+
+- FAT_JAR类型
+
+![java_task](../../../../img/tasks/demo/java_fat.png)
+
+因为fat类型的jar,依赖和代码都在同一个jar中,则只需选择这一个jar即可
+
+- NORMAL_JAR类型
+
+![java_task](../../../../img/tasks/demo/java_normal.png)
+
+normal1.jar是程序运行的入口,normal2.jar是所需的依赖,需要用主程序包指定程序的入口,并且在资源文件中选择所有依赖和程序入口jar文件,才能正确运行
 
 ## 注意事项
 
-使用JAVA运行类型时代码中必须存在public类,可以不写package语句
+使用这两种运行类型,都必须选择主程序包和对应的资源文件,否则任务会直接失败。因为主程序包是选择程序从哪里开始运行,资源文件选择文件之后,运行程序时,资源文件才能被加入其中

Review Comment:
   The docs have been updated



##########
docs/docs/zh/guide/task/java.md:
##########
@@ -22,25 +22,38 @@
 | 模块路径     | 开启使用JAVA9+的模块化特性,把所有资源放入--module-path中,要求您的worker中的JDK版本支持模块化 |
 | 主程序参数    | 作为普通Java程序main方法入口参数                                          |
 | 虚拟机参数    | 配置启动虚拟机参数                                                     |
-| 脚本       | 若使用JAVA运行类型则需要编写JAVA代码。代码中必须存在public类,不用写package语句            |
+| 主程序包     | 选择要运行程序的主程序包                                                  |
 | 资源       | 可以是外部JAR包也可以是其他资源文件,它们都会被加入到类路径或模块路径中,您可以在自己的JAVA脚本中轻松获取      |
 
 ## 任务样例
 
-java任务类型有两种运行模式,这里以JAVA模式为例进行演示。
+java任务类型有两种运行模式,这里进行分别进行演示。
 
 主要配置参数如下:
 
 - 运行类型
 - 模块路径
 - 主程序参数
 - 虚拟机参数
-- 脚本文件
+- 主程序包
+- 资源文件
 
-![java_task](../../../../img/tasks/demo/java_task02.png)
+如图所示
+
+- FAT_JAR类型
+
+![java_task](../../../../img/tasks/demo/java_fat.png)
+
+因为fat类型的jar,依赖和代码都在同一个jar中,则只需选择这一个jar即可
+
+- NORMAL_JAR类型
+
+![java_task](../../../../img/tasks/demo/java_normal.png)
+
+normal1.jar是程序运行的入口,normal2.jar是所需的依赖,需要用主程序包指定程序的入口,并且在资源文件中选择所有依赖和程序入口jar文件,才能正确运行

Review Comment:
   The docs have been updated



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [DSIP-27][Task Plugin] Some improvements of JAVA task plugin [dolphinscheduler]

Posted by "SbloodyS (via GitHub)" <gi...@apache.org>.
SbloodyS commented on code in PR #16542:
URL: https://github.com/apache/dolphinscheduler/pull/16542#discussion_r1845944085


##########
dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/cases/WorkflowJavaTaskE2ETest.java:
##########
@@ -70,16 +99,102 @@ public class WorkflowJavaTaskE2ETest {
 
     private static final String environmentWorkerGroup = "default";
 
-    private static final String javaContent = "public class Test {" +
-            "    public static void main(String[] args) {" +
-            "        System.out.println(\"hello world\");" +
-            "    }" +
-            "}";
+    private static final String filePath = Constants.HOST_TMP_PATH.toString();
 
     private static RemoteWebDriver browser;
 
+    public static void main(String[] args) {
+        createAndBuildJars();
+    }
+
+    private static void createJar(String className, String classFilePath, String entryName, String mainPackage,
+                                  String jarName) {
+
+        String jarFilePath = Constants.HOST_TMP_PATH + "/" + jarName;
+
+        Manifest manifest = new Manifest();
+        manifest.getMainAttributes().put(Attributes.Name.MANIFEST_VERSION, "1.0");
+        manifest.getMainAttributes().put(Attributes.Name.MAIN_CLASS, mainPackage);
+
+        try (
+                FileOutputStream fos = new FileOutputStream(jarFilePath);
+                JarOutputStream jos = new JarOutputStream(fos, manifest)) {
+            Path path = new File(classFilePath + className).toPath();
+            JarEntry entry = new JarEntry(entryName);
+            jos.putNextEntry(entry);
+            byte[] bytes = Files.readAllBytes(path);
+            jos.write(bytes, 0, bytes.length);
+            jos.closeEntry();
+        } catch (IOException e) {
+            throw new RuntimeException("Create jar failed:", e);
+        }
+
+    }
+    private static void createAndBuildJars() {

Review Comment:
   ```suggestion
       }
       
       private static void createAndBuildJars() {
   ```



##########
dolphinscheduler-task-plugin/dolphinscheduler-task-java/src/main/java/org/apache/dolphinscheduler/plugin/task/java/MainClassExtractor.java:
##########
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.dolphinscheduler.plugin.task.java;
+
+import java.io.File;
+import java.util.jar.JarFile;
+import java.util.jar.Manifest;
+
+import lombok.extern.slf4j.Slf4j;
+
+@Slf4j
+public class MainClassExtractor {
+
+    private MainClassExtractor() {
+    }
+    public static String getMainClassName(String jarFilePath) {
+        String mainClassName = null;
+        try (JarFile jarFile = new JarFile(new File(jarFilePath))) {
+
+            Manifest manifest = jarFile.getManifest();
+            mainClassName = manifest.getMainAttributes().getValue("Main-Class");
+
+        } catch (Exception e) {
+            log.error("get mainJarName failed:", e);

Review Comment:
   ```suggestion
   ```



##########
dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/cases/WorkflowJavaTaskE2ETest.java:
##########
@@ -70,16 +99,102 @@ public class WorkflowJavaTaskE2ETest {
 
     private static final String environmentWorkerGroup = "default";
 
-    private static final String javaContent = "public class Test {" +
-            "    public static void main(String[] args) {" +
-            "        System.out.println(\"hello world\");" +
-            "    }" +
-            "}";
+    private static final String filePath = Constants.HOST_TMP_PATH.toString();
 
     private static RemoteWebDriver browser;
 
+    public static void main(String[] args) {
+        createAndBuildJars();
+    }

Review Comment:
   We don't need this since this have been execute in `setup`



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [DSIP-27][Task Plugin] Some improvements of JAVA task plugin [dolphinscheduler]

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #16542:
URL: https://github.com/apache/dolphinscheduler/pull/16542#issuecomment-2487774316

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16542) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [1 New issue](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=16542&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=16542&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=16542&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [86.7% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=16542&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=16542&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16542)
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [DSIP-27][Task Plugin] Some improvements of JAVA task plugin [dolphinscheduler]

Posted by "ailiujiarui (via GitHub)" <gi...@apache.org>.
ailiujiarui commented on code in PR #16542:
URL: https://github.com/apache/dolphinscheduler/pull/16542#discussion_r1811609498


##########
dolphinscheduler-task-plugin/dolphinscheduler-task-java/src/main/java/org/apache/dolphinscheduler/plugin/task/java/JavaTask.java:
##########
@@ -150,43 +132,48 @@ public void handle(TaskCallBack taskCallBack) throws TaskException {
     }
 
     /**
-     * Construct a shell command for the java Run mode
+     * Construct a shell command for the java -jar Run mode
      *
      * @return String
-     * @throws Exception
      **/
-    protected String buildJavaCommand() throws Exception {
+    protected String buildJarCommand() {
+        ResourceContext resourceContext = taskRequest.getResourceContext();
+        String mainJarAbsolutePathInLocal = resourceContext
+                .getResourceItem(javaParameters.getMainJar().getResourceName())
+                .getResourceAbsolutePathInLocal();
         StringBuilder builder = new StringBuilder();
-        String sourceCode = buildJavaSourceContent();
-        builder.append(buildJavaCompileCommand(sourceCode))
-                .append(";")
-                .append(getJavaCommandPath())
+        builder.append(getJavaCommandPath())
                 .append("java").append(" ")
-                .append(buildResourcePath())
-                .append(" ")
-                .append(getPublicClassName(sourceCode))
-                .append(" ")
+                .append(buildResourcePath()).append(" ")
+                .append("-jar").append(" ")
+                .append(mainJarAbsolutePathInLocal).append(" ")

Review Comment:
   Updated



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [DSIP-27][Task Plugin] Some improvements of JAVA task plugin [dolphinscheduler]

Posted by "ailiujiarui (via GitHub)" <gi...@apache.org>.
ailiujiarui commented on code in PR #16542:
URL: https://github.com/apache/dolphinscheduler/pull/16542#discussion_r1814178795


##########
dolphinscheduler-task-plugin/dolphinscheduler-task-java/src/main/java/org/apache/dolphinscheduler/plugin/task/java/MainClassExtractor.java:
##########
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.dolphinscheduler.plugin.task.java;
+
+import java.io.File;
+import java.util.jar.JarFile;
+import java.util.jar.Manifest;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class MainClassExtractor {
+
+    private static final Logger logger = LoggerFactory.getLogger(MainClassExtractor.class);

Review Comment:
   The code has been updated



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [DSIP-27][Task Plugin] Some improvements of JAVA task plugin [dolphinscheduler]

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #16542:
URL: https://github.com/apache/dolphinscheduler/pull/16542#issuecomment-2377106818

   ## [![Quality Gate Failed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-failed-20px.png 'Quality Gate Failed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16542) **Quality Gate failed**  
   Failed conditions  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/failed-16px.png '') [E Reliability Rating on New Code](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16542) (required ≥ A)  
     
   [See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16542)
   
   ##   
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/light_bulb-16px.png '') Catch issues before they fail your Quality Gate with our IDE extension ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/sonarlint-16px.png '') [SonarLint](https://www.sonarsource.com/products/sonarlint/features/connected-mode/?referrer=pull-request)
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [DSIP-27][Task Plugin] Some improvements of JAVA task plugin [dolphinscheduler]

Posted by "ailiujiarui (via GitHub)" <gi...@apache.org>.
ailiujiarui commented on PR #16542:
URL: https://github.com/apache/dolphinscheduler/pull/16542#issuecomment-2408802854

   > 请也更改文档。
   
   Document has been updated.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [DSIP-27][Task Plugin] Update the JAVA task [dolphinscheduler]

Posted by "ailiujiarui (via GitHub)" <gi...@apache.org>.
ailiujiarui commented on PR #16542:
URL: https://github.com/apache/dolphinscheduler/pull/16542#issuecomment-2340125655

   Hi everyone, could you please let me know if there’s anything that needs improvement? Thanks!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [DSIP-27][Task Plugin] Some improvements of JAVA task plugin [dolphinscheduler]

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #16542:
URL: https://github.com/apache/dolphinscheduler/pull/16542#issuecomment-2525090482

   Please retry analysis of this Pull-Request directly on SonarQube Cloud


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [DSIP-27][Task Plugin] Some improvements of JAVA task plugin [dolphinscheduler]

Posted by "SbloodyS (via GitHub)" <gi...@apache.org>.
SbloodyS commented on code in PR #16542:
URL: https://github.com/apache/dolphinscheduler/pull/16542#discussion_r1777096742


##########
.github/workflows/e2e.yml:
##########
@@ -124,8 +124,6 @@ jobs:
             class: org.apache.dolphinscheduler.e2e.cases.WorkflowE2ETest
           - name: WorkflowHttpTaskE2ETest
             class: org.apache.dolphinscheduler.e2e.cases.WorkflowHttpTaskE2ETest
-          - name: WorkflowJavaTaskE2ETest
-            class: org.apache.dolphinscheduler.e2e.cases.WorkflowJavaTaskE2ETest

Review Comment:
   You should modify it base on the new logic according to the previous test case, not delete it.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [DSIP-27][Task Plugin] Some improvements of JAVA task plugin [dolphinscheduler]

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #16542:
URL: https://github.com/apache/dolphinscheduler/pull/16542#issuecomment-2428090841

   ## [![Quality Gate Failed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-failed-20px.png 'Quality Gate Failed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16542) **Quality Gate failed**  
   Failed conditions  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/failed-16px.png '') [E Reliability Rating on New Code](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16542) (required ≥ A)  
     
   [See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16542)
   
   ##   
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/light_bulb-16px.png '') Catch issues before they fail your Quality Gate with our IDE extension ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/sonarlint-16px.png '') [SonarLint](https://www.sonarsource.com/products/sonarlint/features/connected-mode/?referrer=pull-request)
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [DSIP-27][Task Plugin] Some improvements of JAVA task plugin [dolphinscheduler]

Posted by "SbloodyS (via GitHub)" <gi...@apache.org>.
SbloodyS commented on PR #16542:
URL: https://github.com/apache/dolphinscheduler/pull/16542#issuecomment-2408812422

   > Document has been updated.
   
   I didn't see any docs in this PR. Please check it.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [DSIP-27][Task Plugin] Some improvements of JAVA task plugin [dolphinscheduler]

Posted by "SbloodyS (via GitHub)" <gi...@apache.org>.
SbloodyS commented on PR #16542:
URL: https://github.com/apache/dolphinscheduler/pull/16542#issuecomment-2449040170

   > The workload for this end-to-end test case is much greater than I initially anticipated. Would it be possible to focus on unit testing in the current pull request? We can add the end-to-end tests later on. @SbloodyS @ruanwenjun
   
   I don't think it's a good idea. I'm -1 on this.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [DSIP-27][Task Plugin] Some improvements of JAVA task plugin [dolphinscheduler]

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #16542:
URL: https://github.com/apache/dolphinscheduler/pull/16542#issuecomment-2461759647

   Please retry analysis of this Pull-Request directly on SonarCloud


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [DSIP-27][Task Plugin] Some improvements of JAVA task plugin [dolphinscheduler]

Posted by "ailiujiarui (via GitHub)" <gi...@apache.org>.
ailiujiarui commented on code in PR #16542:
URL: https://github.com/apache/dolphinscheduler/pull/16542#discussion_r1828915698


##########
dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/cases/WorkflowJavaTaskE2ETest.java:
##########
@@ -70,16 +97,110 @@ public class WorkflowJavaTaskE2ETest {
 
     private static final String environmentWorkerGroup = "default";
 
-    private static final String javaContent = "public class Test {" +
-            "    public static void main(String[] args) {" +
-            "        System.out.println(\"hello world\");" +
-            "    }" +
-            "}";
+    private static final String filePath = "/tmp";
 
     private static RemoteWebDriver browser;
 
+    private static void createJar(String className, String classFilePath, String entryName, String mainPackage,
+                                  String jarName) {
+
+        String jarFilePath = "/tmp/" + jarName;
+
+        Manifest manifest = new Manifest();
+        manifest.getMainAttributes().put(Attributes.Name.MANIFEST_VERSION, "1.0");
+        manifest.getMainAttributes().put(Attributes.Name.MAIN_CLASS, mainPackage);
+
+        try (
+                FileOutputStream fos = new FileOutputStream(jarFilePath);
+                JarOutputStream jos = new JarOutputStream(fos, manifest)) {
+            Path path = new File(classFilePath + className).toPath();
+            JarEntry entry = new JarEntry(entryName);
+            jos.putNextEntry(entry);
+            byte[] bytes = Files.readAllBytes(path);
+            jos.write(bytes, 0, bytes.length);
+            jos.closeEntry();
+        } catch (IOException e) {
+            log.error("create jar failed:", e);
+        }
+
+    }
+    private static void getJar() {

Review Comment:
   Has been modified



##########
dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/cases/WorkflowJavaTaskE2ETest.java:
##########
@@ -121,35 +247,47 @@ public static void cleanup() {
 
     @Test
     @Order(1)
-    void testCreateWorkflow() {
-        WorkflowDefinitionTab workflowDefinitionPage =
-                new ProjectPage(browser)
-                        .goTo(project)
-                        .goToTab(WorkflowDefinitionTab.class);
+    void testCreateFatWorkflow() {

Review Comment:
   Has been modified



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [DSIP-27][Task Plugin] Some improvements of JAVA task plugin [dolphinscheduler]

Posted by "ailiujiarui (via GitHub)" <gi...@apache.org>.
ailiujiarui commented on code in PR #16542:
URL: https://github.com/apache/dolphinscheduler/pull/16542#discussion_r1839874801


##########
dolphinscheduler-task-plugin/dolphinscheduler-task-java/src/main/java/org/apache/dolphinscheduler/plugin/task/java/MainClassExtractor.java:
##########
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.dolphinscheduler.plugin.task.java;
+
+import java.io.File;
+import java.util.jar.JarFile;
+import java.util.jar.Manifest;
+
+import lombok.extern.slf4j.Slf4j;
+
+@Slf4j
+public class MainClassExtractor {
+
+    private MainClassExtractor() {
+    }
+    public static String getMainClassName(String jarFilePath) {
+        String mainClassName = null;
+        try (JarFile jarFile = new JarFile(new File(jarFilePath))) {
+
+            Manifest manifest = jarFile.getManifest();
+            mainClassName = manifest.getMainAttributes().getValue("Main-Class");
+
+        } catch (Exception e) {
+            log.error("get mainJarName failed:", e);

Review Comment:
   The code has been updated



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [DSIP-27][Task Plugin] Some improvements of JAVA task plugin [dolphinscheduler]

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #16542:
URL: https://github.com/apache/dolphinscheduler/pull/16542#issuecomment-2502502628

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16542) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 New issues](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=16542&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=16542&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=16542&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=16542&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=16542&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16542)
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [DSIP-27][Task Plugin] Some improvements of JAVA task plugin [dolphinscheduler]

Posted by "ailiujiarui (via GitHub)" <gi...@apache.org>.
ailiujiarui commented on code in PR #16542:
URL: https://github.com/apache/dolphinscheduler/pull/16542#discussion_r1865180209


##########
dolphinscheduler-task-plugin/dolphinscheduler-task-java/src/main/java/org/apache/dolphinscheduler/plugin/task/java/JavaParameters.java:
##########
@@ -67,11 +62,11 @@ public class JavaParameters extends AbstractParameters {
     /**
      * Check that the parameters are valid
      *
-     * @returnboolean
+     * @return boolean
      */
     @Override
     public boolean checkParameters() {
-        return runType != null && (StringUtils.isNotBlank(rawScript) || mainJar != null);
+        return StringUtils.isNotEmpty(runType);

Review Comment:
   It has been modified. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [DSIP-27][Task Plugin] Update the JAVA task [dolphinscheduler]

Posted by "fuchanghai (via GitHub)" <gi...@apache.org>.
fuchanghai commented on PR #16542:
URL: https://github.com/apache/dolphinscheduler/pull/16542#issuecomment-2327803636

   <img width="1227" alt="image" src="https://github.com/user-attachments/assets/d2a1d8f1-b97c-498e-bcd1-74fd3941a257">
   Please check if additional explanation is needed


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [DSIP-27][Task Plugin] Some improvements of JAVA task plugin [dolphinscheduler]

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #16542:
URL: https://github.com/apache/dolphinscheduler/pull/16542#issuecomment-2481889263

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16542) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 New issues](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=16542&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=16542&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=16542&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=16542&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=16542&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16542)
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [DSIP-27][Task Plugin] Some improvements of JAVA task plugin [dolphinscheduler]

Posted by "ailiujiarui (via GitHub)" <gi...@apache.org>.
ailiujiarui commented on code in PR #16542:
URL: https://github.com/apache/dolphinscheduler/pull/16542#discussion_r1846165030


##########
dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/cases/WorkflowJavaTaskE2ETest.java:
##########
@@ -70,16 +99,102 @@ public class WorkflowJavaTaskE2ETest {
 
     private static final String environmentWorkerGroup = "default";
 
-    private static final String javaContent = "public class Test {" +
-            "    public static void main(String[] args) {" +
-            "        System.out.println(\"hello world\");" +
-            "    }" +
-            "}";
+    private static final String filePath = Constants.HOST_TMP_PATH.toString();
 
     private static RemoteWebDriver browser;
 
+    public static void main(String[] args) {
+        createAndBuildJars();
+    }
+
+    private static void createJar(String className, String classFilePath, String entryName, String mainPackage,
+                                  String jarName) {
+
+        String jarFilePath = Constants.HOST_TMP_PATH + "/" + jarName;
+
+        Manifest manifest = new Manifest();
+        manifest.getMainAttributes().put(Attributes.Name.MANIFEST_VERSION, "1.0");
+        manifest.getMainAttributes().put(Attributes.Name.MAIN_CLASS, mainPackage);
+
+        try (
+                FileOutputStream fos = new FileOutputStream(jarFilePath);
+                JarOutputStream jos = new JarOutputStream(fos, manifest)) {
+            Path path = new File(classFilePath + className).toPath();
+            JarEntry entry = new JarEntry(entryName);
+            jos.putNextEntry(entry);
+            byte[] bytes = Files.readAllBytes(path);
+            jos.write(bytes, 0, bytes.length);
+            jos.closeEntry();
+        } catch (IOException e) {
+            throw new RuntimeException("Create jar failed:", e);
+        }
+
+    }
+    private static void createAndBuildJars() {

Review Comment:
   Updated



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [DSIP-27][Task Plugin] Some improvements of JAVA task plugin [dolphinscheduler]

Posted by "ailiujiarui (via GitHub)" <gi...@apache.org>.
ailiujiarui commented on code in PR #16542:
URL: https://github.com/apache/dolphinscheduler/pull/16542#discussion_r1846164632


##########
dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/cases/WorkflowJavaTaskE2ETest.java:
##########
@@ -70,16 +99,102 @@ public class WorkflowJavaTaskE2ETest {
 
     private static final String environmentWorkerGroup = "default";
 
-    private static final String javaContent = "public class Test {" +
-            "    public static void main(String[] args) {" +
-            "        System.out.println(\"hello world\");" +
-            "    }" +
-            "}";
+    private static final String filePath = Constants.HOST_TMP_PATH.toString();
 
     private static RemoteWebDriver browser;
 
+    public static void main(String[] args) {
+        createAndBuildJars();
+    }

Review Comment:
   Has been deleted



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [DSIP-27][Task Plugin] Some improvements of JAVA task plugin [dolphinscheduler]

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #16542:
URL: https://github.com/apache/dolphinscheduler/pull/16542#issuecomment-2439241325

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16542) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 New issues](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=16542&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=16542&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=16542&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=16542&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=16542&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16542)
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [DSIP-27][Task Plugin] Some improvements of JAVA task plugin [dolphinscheduler]

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #16542:
URL: https://github.com/apache/dolphinscheduler/pull/16542#issuecomment-2441081935

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16542) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 New issues](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=16542&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=16542&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=16542&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=16542&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=16542&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16542)
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [DSIP-27][Task Plugin] Some improvements of JAVA task plugin [dolphinscheduler]

Posted by "ailiujiarui (via GitHub)" <gi...@apache.org>.
ailiujiarui commented on PR #16542:
URL: https://github.com/apache/dolphinscheduler/pull/16542#issuecomment-2448962060

   The workload for this end-to-end test case is much greater than I initially anticipated. Would it be possible to focus on unit testing in the current pull request? We can add the end-to-end tests later on.
   @SbloodyS @ruanwenjun 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [DSIP-27][Task Plugin] Some improvements of JAVA task plugin [dolphinscheduler]

Posted by "SbloodyS (via GitHub)" <gi...@apache.org>.
SbloodyS commented on code in PR #16542:
URL: https://github.com/apache/dolphinscheduler/pull/16542#discussion_r1825337433


##########
dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/cases/WorkflowJavaTaskE2ETest.java:
##########
@@ -70,16 +97,110 @@ public class WorkflowJavaTaskE2ETest {
 
     private static final String environmentWorkerGroup = "default";
 
-    private static final String javaContent = "public class Test {" +
-            "    public static void main(String[] args) {" +
-            "        System.out.println(\"hello world\");" +
-            "    }" +
-            "}";
+    private static final String filePath = "/tmp";
 
     private static RemoteWebDriver browser;
 
+    private static void createJar(String className, String classFilePath, String entryName, String mainPackage,
+                                  String jarName) {
+
+        String jarFilePath = "/tmp/" + jarName;
+
+        Manifest manifest = new Manifest();
+        manifest.getMainAttributes().put(Attributes.Name.MANIFEST_VERSION, "1.0");
+        manifest.getMainAttributes().put(Attributes.Name.MAIN_CLASS, mainPackage);
+
+        try (
+                FileOutputStream fos = new FileOutputStream(jarFilePath);
+                JarOutputStream jos = new JarOutputStream(fos, manifest)) {
+            Path path = new File(classFilePath + className).toPath();
+            JarEntry entry = new JarEntry(entryName);
+            jos.putNextEntry(entry);
+            byte[] bytes = Files.readAllBytes(path);
+            jos.write(bytes, 0, bytes.length);
+            jos.closeEntry();
+        } catch (IOException e) {
+            log.error("create jar failed:", e);
+        }
+
+    }
+    private static void getJar() {
+        String classPath = "/tmp/common/";
+        compileJavaFile("common/Fat.java");
+        compileJavaFile("common/Normal1.java");
+        compileJavaFile("common/Normal2.java");
+        createJar("Fat.class", classPath,
+                "common/Fat.class",
+                "common.Fat",
+                "fat.jar");
+        createJar("Normal1.class",
+                classPath,
+                "common/Normal1.class",
+                "common.Normal1",
+                "normal1.jar");
+        createJar("Normal2.class",
+                classPath,
+                "common/Normal2.class",
+                "common.Normal2",
+                "normal2.jar");
+
+    }
+
+    public static void compileJavaFile(String sourceFilePath) {
+
+        JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
+        if (compiler == null) {
+            log.error("Cannot find the system Java compiler.", new IllegalStateException());
+        }
+
+        ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+        URL resourceUrl = classLoader.getResource(sourceFilePath);
+        String absolutePath = "";
+
+        try {
+            File resourceFile = new File(resourceUrl.toURI());
+            absolutePath = resourceFile.getAbsolutePath();
+        } catch (Exception e) {
+            log.error(" java file cannot find:", e);
+        }
+
+        String outputDirPath = "/tmp";

Review Comment:
   Using `Constants` instead.



##########
dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/cases/WorkflowJavaTaskE2ETest.java:
##########
@@ -70,16 +97,110 @@ public class WorkflowJavaTaskE2ETest {
 
     private static final String environmentWorkerGroup = "default";
 
-    private static final String javaContent = "public class Test {" +
-            "    public static void main(String[] args) {" +
-            "        System.out.println(\"hello world\");" +
-            "    }" +
-            "}";
+    private static final String filePath = "/tmp";
 
     private static RemoteWebDriver browser;
 
+    private static void createJar(String className, String classFilePath, String entryName, String mainPackage,
+                                  String jarName) {
+
+        String jarFilePath = "/tmp/" + jarName;
+
+        Manifest manifest = new Manifest();
+        manifest.getMainAttributes().put(Attributes.Name.MANIFEST_VERSION, "1.0");
+        manifest.getMainAttributes().put(Attributes.Name.MAIN_CLASS, mainPackage);
+
+        try (
+                FileOutputStream fos = new FileOutputStream(jarFilePath);
+                JarOutputStream jos = new JarOutputStream(fos, manifest)) {
+            Path path = new File(classFilePath + className).toPath();
+            JarEntry entry = new JarEntry(entryName);
+            jos.putNextEntry(entry);
+            byte[] bytes = Files.readAllBytes(path);
+            jos.write(bytes, 0, bytes.length);
+            jos.closeEntry();
+        } catch (IOException e) {
+            log.error("create jar failed:", e);
+        }
+
+    }
+    private static void getJar() {
+        String classPath = "/tmp/common/";
+        compileJavaFile("common/Fat.java");
+        compileJavaFile("common/Normal1.java");
+        compileJavaFile("common/Normal2.java");
+        createJar("Fat.class", classPath,
+                "common/Fat.class",
+                "common.Fat",
+                "fat.jar");
+        createJar("Normal1.class",
+                classPath,
+                "common/Normal1.class",
+                "common.Normal1",
+                "normal1.jar");
+        createJar("Normal2.class",
+                classPath,
+                "common/Normal2.class",
+                "common.Normal2",
+                "normal2.jar");
+
+    }
+
+    public static void compileJavaFile(String sourceFilePath) {
+
+        JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
+        if (compiler == null) {
+            log.error("Cannot find the system Java compiler.", new IllegalStateException());
+        }
+
+        ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+        URL resourceUrl = classLoader.getResource(sourceFilePath);
+        String absolutePath = "";
+
+        try {
+            File resourceFile = new File(resourceUrl.toURI());
+            absolutePath = resourceFile.getAbsolutePath();
+        } catch (Exception e) {
+            log.error(" java file cannot find:", e);

Review Comment:
   Same here.



##########
dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/cases/WorkflowJavaTaskE2ETest.java:
##########
@@ -70,16 +97,110 @@ public class WorkflowJavaTaskE2ETest {
 
     private static final String environmentWorkerGroup = "default";
 
-    private static final String javaContent = "public class Test {" +
-            "    public static void main(String[] args) {" +
-            "        System.out.println(\"hello world\");" +
-            "    }" +
-            "}";
+    private static final String filePath = "/tmp";
 
     private static RemoteWebDriver browser;
 
+    private static void createJar(String className, String classFilePath, String entryName, String mainPackage,
+                                  String jarName) {
+
+        String jarFilePath = "/tmp/" + jarName;
+
+        Manifest manifest = new Manifest();
+        manifest.getMainAttributes().put(Attributes.Name.MANIFEST_VERSION, "1.0");
+        manifest.getMainAttributes().put(Attributes.Name.MAIN_CLASS, mainPackage);
+
+        try (
+                FileOutputStream fos = new FileOutputStream(jarFilePath);
+                JarOutputStream jos = new JarOutputStream(fos, manifest)) {
+            Path path = new File(classFilePath + className).toPath();
+            JarEntry entry = new JarEntry(entryName);
+            jos.putNextEntry(entry);
+            byte[] bytes = Files.readAllBytes(path);
+            jos.write(bytes, 0, bytes.length);
+            jos.closeEntry();
+        } catch (IOException e) {
+            log.error("create jar failed:", e);

Review Comment:
   Need to throw exception here.



##########
dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/cases/WorkflowJavaTaskE2ETest.java:
##########
@@ -70,16 +97,110 @@ public class WorkflowJavaTaskE2ETest {
 
     private static final String environmentWorkerGroup = "default";
 
-    private static final String javaContent = "public class Test {" +
-            "    public static void main(String[] args) {" +
-            "        System.out.println(\"hello world\");" +
-            "    }" +
-            "}";
+    private static final String filePath = "/tmp";
 
     private static RemoteWebDriver browser;
 
+    private static void createJar(String className, String classFilePath, String entryName, String mainPackage,
+                                  String jarName) {
+
+        String jarFilePath = "/tmp/" + jarName;
+
+        Manifest manifest = new Manifest();
+        manifest.getMainAttributes().put(Attributes.Name.MANIFEST_VERSION, "1.0");
+        manifest.getMainAttributes().put(Attributes.Name.MAIN_CLASS, mainPackage);
+
+        try (
+                FileOutputStream fos = new FileOutputStream(jarFilePath);
+                JarOutputStream jos = new JarOutputStream(fos, manifest)) {
+            Path path = new File(classFilePath + className).toPath();
+            JarEntry entry = new JarEntry(entryName);
+            jos.putNextEntry(entry);
+            byte[] bytes = Files.readAllBytes(path);
+            jos.write(bytes, 0, bytes.length);
+            jos.closeEntry();
+        } catch (IOException e) {
+            log.error("create jar failed:", e);
+        }
+
+    }
+    private static void getJar() {
+        String classPath = "/tmp/common/";
+        compileJavaFile("common/Fat.java");
+        compileJavaFile("common/Normal1.java");
+        compileJavaFile("common/Normal2.java");
+        createJar("Fat.class", classPath,
+                "common/Fat.class",
+                "common.Fat",
+                "fat.jar");
+        createJar("Normal1.class",
+                classPath,
+                "common/Normal1.class",
+                "common.Normal1",
+                "normal1.jar");
+        createJar("Normal2.class",
+                classPath,
+                "common/Normal2.class",
+                "common.Normal2",
+                "normal2.jar");
+
+    }
+
+    public static void compileJavaFile(String sourceFilePath) {
+
+        JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
+        if (compiler == null) {
+            log.error("Cannot find the system Java compiler.", new IllegalStateException());
+        }
+
+        ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+        URL resourceUrl = classLoader.getResource(sourceFilePath);
+        String absolutePath = "";
+
+        try {
+            File resourceFile = new File(resourceUrl.toURI());
+            absolutePath = resourceFile.getAbsolutePath();
+        } catch (Exception e) {
+            log.error(" java file cannot find:", e);
+        }
+
+        String outputDirPath = "/tmp";
+
+        try (StandardJavaFileManager fileManager = compiler.getStandardFileManager(null, null, null)) {
+
+            File sourceFile = new File(absolutePath);
+            if (!sourceFile.exists()) {
+                log.error("java file not exist", new IllegalArgumentException());
+            }
+
+            Iterable<? extends JavaFileObject> compilationUnits =
+                    fileManager.getJavaFileObjectsFromFiles(Arrays.asList(sourceFile));
+
+            List<String> options = Arrays.asList(
+                    "--release", "8",
+                    "-d", outputDirPath);
+
+            JavaCompiler.CompilationTask task = compiler.getTask(
+                    null,
+                    fileManager,
+                    null,
+                    options,
+                    null,
+                    compilationUnits);
+
+            boolean success = task.call();
+
+            if (!success) {
+                throw new RuntimeException("Compilation failed.");

Review Comment:
   ```suggestion
                   throw new RuntimeException("Jar compilation failed.");
   ```



##########
dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/cases/WorkflowJavaTaskE2ETest.java:
##########
@@ -121,35 +247,47 @@ public static void cleanup() {
 
     @Test
     @Order(1)
-    void testCreateWorkflow() {
-        WorkflowDefinitionTab workflowDefinitionPage =
-                new ProjectPage(browser)
-                        .goTo(project)
-                        .goToTab(WorkflowDefinitionTab.class);
+    void testCreateFatWorkflow() {
+        FileManagePage file = new NavBarPage(browser)
+                .goToNav(ResourcePage.class)
+                .goToTab(FileManagePage.class)
+                .uploadFile(filePath + "/fat.jar");
+
+        WebDriverWait wait = WebDriverWaitFactory.createWebDriverWait(browser);
 
-        workflowDefinitionPage
-                .createWorkflow()
-                .<JavaTaskForm>addTask(WorkflowForm.TaskType.JAVA)
-                .script(javaContent)
+        wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//span[text()='fat.jar']")));
+
+        ProjectPage projectPage = new NavBarPage(browser)
+                .goToNav(ProjectPage.class);
+
+        wait.until(ExpectedConditions.visibilityOfAllElements(projectPage.projectList()));
+
+        WorkflowDefinitionTab workflowDefinitionPage = projectPage
+                .goTo(project)
+                .goToTab(WorkflowDefinitionTab.class);
+
+        WorkflowForm workflow1 = workflowDefinitionPage.createWorkflow();
+        workflow1.<JavaTaskForm>addTask(WorkflowForm.TaskType.JAVA)
+                .selectRunType("FAT_JAR")
+                .selectMainPackage("fat.jar")
+                .selectJavaResource("fat.jar")
                 .name("test-1")
-                .addParam("today", "${system.datetime}")
                 .selectEnv(environmentName)
                 .submit()
                 .submit()
                 .name(workflow)
-                .addGlobalParam("global_param", "hello world")
                 .submit();
 
         Awaitility.await().untilAsserted(() -> assertThat(workflowDefinitionPage.workflowList())
                 .as("Workflow list should contain newly-created workflow")
-                .anyMatch(
-                        it -> it.getText().contains(workflow)));
+                .anyMatch(it -> it.getText().contains(workflow)));
+
         workflowDefinitionPage.publish(workflow);
     }
 
     @Test
     @Order(30)
-    void testRunWorkflow() {
+    void testRunFatWorkflow() {

Review Comment:
   ```suggestion
       void testRunFatJarWorkflow() {
   ```



##########
dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/cases/WorkflowJavaTaskE2ETest.java:
##########
@@ -70,16 +97,110 @@ public class WorkflowJavaTaskE2ETest {
 
     private static final String environmentWorkerGroup = "default";
 
-    private static final String javaContent = "public class Test {" +
-            "    public static void main(String[] args) {" +
-            "        System.out.println(\"hello world\");" +
-            "    }" +
-            "}";
+    private static final String filePath = "/tmp";
 
     private static RemoteWebDriver browser;
 
+    private static void createJar(String className, String classFilePath, String entryName, String mainPackage,
+                                  String jarName) {
+
+        String jarFilePath = "/tmp/" + jarName;
+
+        Manifest manifest = new Manifest();
+        manifest.getMainAttributes().put(Attributes.Name.MANIFEST_VERSION, "1.0");
+        manifest.getMainAttributes().put(Attributes.Name.MAIN_CLASS, mainPackage);
+
+        try (
+                FileOutputStream fos = new FileOutputStream(jarFilePath);
+                JarOutputStream jos = new JarOutputStream(fos, manifest)) {
+            Path path = new File(classFilePath + className).toPath();
+            JarEntry entry = new JarEntry(entryName);
+            jos.putNextEntry(entry);
+            byte[] bytes = Files.readAllBytes(path);
+            jos.write(bytes, 0, bytes.length);
+            jos.closeEntry();
+        } catch (IOException e) {
+            log.error("create jar failed:", e);
+        }
+
+    }
+    private static void getJar() {

Review Comment:
   ```suggestion
       private static void createAndBuildJars() {
   ```



##########
dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/resources/common/Fat.java:
##########


Review Comment:
   Please put these file into `dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/resources/docker/java-task/Fat.java`



##########
dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/cases/WorkflowJavaTaskE2ETest.java:
##########
@@ -121,35 +247,47 @@ public static void cleanup() {
 
     @Test
     @Order(1)
-    void testCreateWorkflow() {
-        WorkflowDefinitionTab workflowDefinitionPage =
-                new ProjectPage(browser)
-                        .goTo(project)
-                        .goToTab(WorkflowDefinitionTab.class);
+    void testCreateFatWorkflow() {
+        FileManagePage file = new NavBarPage(browser)
+                .goToNav(ResourcePage.class)
+                .goToTab(FileManagePage.class)
+                .uploadFile(filePath + "/fat.jar");
+
+        WebDriverWait wait = WebDriverWaitFactory.createWebDriverWait(browser);
 
-        workflowDefinitionPage
-                .createWorkflow()
-                .<JavaTaskForm>addTask(WorkflowForm.TaskType.JAVA)
-                .script(javaContent)
+        wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//span[text()='fat.jar']")));
+
+        ProjectPage projectPage = new NavBarPage(browser)
+                .goToNav(ProjectPage.class);
+
+        wait.until(ExpectedConditions.visibilityOfAllElements(projectPage.projectList()));
+
+        WorkflowDefinitionTab workflowDefinitionPage = projectPage
+                .goTo(project)
+                .goToTab(WorkflowDefinitionTab.class);
+
+        WorkflowForm workflow1 = workflowDefinitionPage.createWorkflow();
+        workflow1.<JavaTaskForm>addTask(WorkflowForm.TaskType.JAVA)
+                .selectRunType("FAT_JAR")
+                .selectMainPackage("fat.jar")
+                .selectJavaResource("fat.jar")
                 .name("test-1")
-                .addParam("today", "${system.datetime}")
                 .selectEnv(environmentName)
                 .submit()
                 .submit()
                 .name(workflow)
-                .addGlobalParam("global_param", "hello world")
                 .submit();
 
         Awaitility.await().untilAsserted(() -> assertThat(workflowDefinitionPage.workflowList())
                 .as("Workflow list should contain newly-created workflow")
-                .anyMatch(
-                        it -> it.getText().contains(workflow)));
+                .anyMatch(it -> it.getText().contains(workflow)));
+
         workflowDefinitionPage.publish(workflow);
     }
 
     @Test
     @Order(30)
-    void testRunWorkflow() {
+    void testRunFatWorkflow() {

Review Comment:
   Please add normal jar test case too.



##########
dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/cases/WorkflowJavaTaskE2ETest.java:
##########
@@ -121,35 +247,47 @@ public static void cleanup() {
 
     @Test
     @Order(1)
-    void testCreateWorkflow() {
-        WorkflowDefinitionTab workflowDefinitionPage =
-                new ProjectPage(browser)
-                        .goTo(project)
-                        .goToTab(WorkflowDefinitionTab.class);
+    void testCreateFatWorkflow() {

Review Comment:
   ```suggestion
       void testCreateFatJarWorkflow() {
   ```



##########
dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/project/workflow/task/JavaTaskForm.java:
##########
@@ -17,27 +17,124 @@
 
 package org.apache.dolphinscheduler.e2e.pages.project.workflow.task;
 
-import org.apache.dolphinscheduler.e2e.pages.common.CodeEditor;
+import org.apache.dolphinscheduler.e2e.core.WebDriverWaitFactory;
 import org.apache.dolphinscheduler.e2e.pages.project.workflow.WorkflowForm;
 
+import java.util.List;
+
+import lombok.Getter;
+
+import org.openqa.selenium.By;
+import org.openqa.selenium.JavascriptExecutor;
+import org.openqa.selenium.Keys;
 import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.support.FindBy;
+import org.openqa.selenium.support.FindBys;
+import org.openqa.selenium.support.PageFactory;
+import org.openqa.selenium.support.ui.ExpectedConditions;
+import org.openqa.selenium.support.ui.WebDriverWait;
 
+@Getter
 public class JavaTaskForm extends TaskNodeForm {
 
-    private CodeEditor codeEditor;
-
     private WebDriver driver;
 
+    @FindBys({
+            @FindBy(className = "resource-select"),
+            @FindBy(className = "n-base-selection"),
+    })
+    private WebElement selectResource;
+
+    @FindBys({
+
+            @FindBy(className = "n-tree-select"),
+            @FindBy(className = "n-base-selection"),
+    })
+    private WebElement selectMainPackage;
+
+    @FindBys({
+            @FindBy(xpath = "//div[contains(@class,'n-form-item') and .//span[text()='Run Type']]"),
+            @FindBy(className = "n-select"),
+            @FindBy(className = "n-base-selection")
+
+    })
+    private WebElement selectRunType;
+
     public JavaTaskForm(WorkflowForm parent) {
         super(parent);
 
-        this.codeEditor = new CodeEditor(parent.driver());
-
         this.driver = parent.driver();
+
+        PageFactory.initElements(driver, this);
     }
 
-    public JavaTaskForm script(String script) {
-        codeEditor.content(script);
+    public JavaTaskForm selectJavaResource(String resourceName) {
+        WebDriverWait wait = WebDriverWaitFactory.createWebDriverWait(driver());
+        wait.until(ExpectedConditions.elementToBeClickable(selectResource));
+        ((JavascriptExecutor) driver).executeScript("arguments[0].scrollIntoView(true); arguments[0].click();",
+                selectResource);
+        By optionsLocator = By.className("n-tree-node-content__text");
+        wait.until(ExpectedConditions.visibilityOfElementLocated(optionsLocator));
+
+        List<WebElement> options = driver.findElements(optionsLocator);
+        boolean found = false;
+        for (WebElement option : options) {
+            if (option.getText().trim().startsWith(resourceName)) {
+                ((JavascriptExecutor) driver).executeScript("arguments[0].scrollIntoView(true); arguments[0].click();",
+                        option);
+                found = true;
+                break;
+            }
+        }
+
+        if (!found) {
+            throw new RuntimeException("Cannot Found: " + resourceName);

Review Comment:
   ```suggestion
               throw new RuntimeException("File " + resourceName + " can not be found.");
   ```



##########
dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/cases/WorkflowJavaTaskE2ETest.java:
##########
@@ -163,17 +301,21 @@ void testRunWorkflow() {
                 .run(workflow)
                 .submit();
 
-        Awaitility.await().untilAsserted(() -> {
-            browser.navigate().refresh();
+        Awaitility.await()
+                .atMost(Duration.ofMinutes(5))

Review Comment:
   ```suggestion
   ```
   
   The default timeout is 2 minutes is enough.



##########
dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/cases/WorkflowJavaTaskE2ETest.java:
##########
@@ -70,16 +97,110 @@ public class WorkflowJavaTaskE2ETest {
 
     private static final String environmentWorkerGroup = "default";
 
-    private static final String javaContent = "public class Test {" +
-            "    public static void main(String[] args) {" +
-            "        System.out.println(\"hello world\");" +
-            "    }" +
-            "}";
+    private static final String filePath = "/tmp";
 
     private static RemoteWebDriver browser;
 
+    private static void createJar(String className, String classFilePath, String entryName, String mainPackage,
+                                  String jarName) {
+
+        String jarFilePath = "/tmp/" + jarName;

Review Comment:
   Using `Constants.HOST_TMP_PATH` instead.



##########
dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/cases/WorkflowJavaTaskE2ETest.java:
##########
@@ -70,16 +97,110 @@ public class WorkflowJavaTaskE2ETest {
 
     private static final String environmentWorkerGroup = "default";
 
-    private static final String javaContent = "public class Test {" +
-            "    public static void main(String[] args) {" +
-            "        System.out.println(\"hello world\");" +
-            "    }" +
-            "}";
+    private static final String filePath = "/tmp";
 
     private static RemoteWebDriver browser;
 
+    private static void createJar(String className, String classFilePath, String entryName, String mainPackage,
+                                  String jarName) {
+
+        String jarFilePath = "/tmp/" + jarName;
+
+        Manifest manifest = new Manifest();
+        manifest.getMainAttributes().put(Attributes.Name.MANIFEST_VERSION, "1.0");
+        manifest.getMainAttributes().put(Attributes.Name.MAIN_CLASS, mainPackage);
+
+        try (
+                FileOutputStream fos = new FileOutputStream(jarFilePath);
+                JarOutputStream jos = new JarOutputStream(fos, manifest)) {
+            Path path = new File(classFilePath + className).toPath();
+            JarEntry entry = new JarEntry(entryName);
+            jos.putNextEntry(entry);
+            byte[] bytes = Files.readAllBytes(path);
+            jos.write(bytes, 0, bytes.length);
+            jos.closeEntry();
+        } catch (IOException e) {
+            log.error("create jar failed:", e);
+        }
+
+    }
+    private static void getJar() {
+        String classPath = "/tmp/common/";
+        compileJavaFile("common/Fat.java");
+        compileJavaFile("common/Normal1.java");
+        compileJavaFile("common/Normal2.java");
+        createJar("Fat.class", classPath,
+                "common/Fat.class",
+                "common.Fat",
+                "fat.jar");
+        createJar("Normal1.class",
+                classPath,
+                "common/Normal1.class",
+                "common.Normal1",
+                "normal1.jar");
+        createJar("Normal2.class",
+                classPath,
+                "common/Normal2.class",
+                "common.Normal2",
+                "normal2.jar");
+
+    }
+
+    public static void compileJavaFile(String sourceFilePath) {
+
+        JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
+        if (compiler == null) {
+            log.error("Cannot find the system Java compiler.", new IllegalStateException());
+        }
+
+        ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+        URL resourceUrl = classLoader.getResource(sourceFilePath);
+        String absolutePath = "";
+
+        try {
+            File resourceFile = new File(resourceUrl.toURI());
+            absolutePath = resourceFile.getAbsolutePath();
+        } catch (Exception e) {
+            log.error(" java file cannot find:", e);
+        }
+
+        String outputDirPath = "/tmp";
+
+        try (StandardJavaFileManager fileManager = compiler.getStandardFileManager(null, null, null)) {
+
+            File sourceFile = new File(absolutePath);
+            if (!sourceFile.exists()) {
+                log.error("java file not exist", new IllegalArgumentException());
+            }
+
+            Iterable<? extends JavaFileObject> compilationUnits =
+                    fileManager.getJavaFileObjectsFromFiles(Arrays.asList(sourceFile));
+
+            List<String> options = Arrays.asList(
+                    "--release", "8",
+                    "-d", outputDirPath);
+
+            JavaCompiler.CompilationTask task = compiler.getTask(
+                    null,
+                    fileManager,
+                    null,
+                    options,
+                    null,
+                    compilationUnits);
+
+            boolean success = task.call();
+
+            if (!success) {
+                throw new RuntimeException("Compilation failed.");
+            }
+        } catch (IOException e) {
+            log.error("compile java file failed:", e);

Review Comment:
   Same here.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [DSIP-27][Task Plugin] Some improvements of JAVA task plugin [dolphinscheduler]

Posted by "ailiujiarui (via GitHub)" <gi...@apache.org>.
ailiujiarui commented on code in PR #16542:
URL: https://github.com/apache/dolphinscheduler/pull/16542#discussion_r1828916084


##########
dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/cases/WorkflowJavaTaskE2ETest.java:
##########
@@ -121,35 +247,47 @@ public static void cleanup() {
 
     @Test
     @Order(1)
-    void testCreateWorkflow() {
-        WorkflowDefinitionTab workflowDefinitionPage =
-                new ProjectPage(browser)
-                        .goTo(project)
-                        .goToTab(WorkflowDefinitionTab.class);
+    void testCreateFatWorkflow() {
+        FileManagePage file = new NavBarPage(browser)
+                .goToNav(ResourcePage.class)
+                .goToTab(FileManagePage.class)
+                .uploadFile(filePath + "/fat.jar");
+
+        WebDriverWait wait = WebDriverWaitFactory.createWebDriverWait(browser);
 
-        workflowDefinitionPage
-                .createWorkflow()
-                .<JavaTaskForm>addTask(WorkflowForm.TaskType.JAVA)
-                .script(javaContent)
+        wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//span[text()='fat.jar']")));
+
+        ProjectPage projectPage = new NavBarPage(browser)
+                .goToNav(ProjectPage.class);
+
+        wait.until(ExpectedConditions.visibilityOfAllElements(projectPage.projectList()));
+
+        WorkflowDefinitionTab workflowDefinitionPage = projectPage
+                .goTo(project)
+                .goToTab(WorkflowDefinitionTab.class);
+
+        WorkflowForm workflow1 = workflowDefinitionPage.createWorkflow();
+        workflow1.<JavaTaskForm>addTask(WorkflowForm.TaskType.JAVA)
+                .selectRunType("FAT_JAR")
+                .selectMainPackage("fat.jar")
+                .selectJavaResource("fat.jar")
                 .name("test-1")
-                .addParam("today", "${system.datetime}")
                 .selectEnv(environmentName)
                 .submit()
                 .submit()
                 .name(workflow)
-                .addGlobalParam("global_param", "hello world")
                 .submit();
 
         Awaitility.await().untilAsserted(() -> assertThat(workflowDefinitionPage.workflowList())
                 .as("Workflow list should contain newly-created workflow")
-                .anyMatch(
-                        it -> it.getText().contains(workflow)));
+                .anyMatch(it -> it.getText().contains(workflow)));
+
         workflowDefinitionPage.publish(workflow);
     }
 
     @Test
     @Order(30)
-    void testRunWorkflow() {
+    void testRunFatWorkflow() {

Review Comment:
   Has been modified



##########
dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/cases/WorkflowJavaTaskE2ETest.java:
##########
@@ -163,17 +301,21 @@ void testRunWorkflow() {
                 .run(workflow)
                 .submit();
 
-        Awaitility.await().untilAsserted(() -> {
-            browser.navigate().refresh();
+        Awaitility.await()
+                .atMost(Duration.ofMinutes(5))

Review Comment:
   Has been modified



##########
dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/project/workflow/task/JavaTaskForm.java:
##########
@@ -17,27 +17,124 @@
 
 package org.apache.dolphinscheduler.e2e.pages.project.workflow.task;
 
-import org.apache.dolphinscheduler.e2e.pages.common.CodeEditor;
+import org.apache.dolphinscheduler.e2e.core.WebDriverWaitFactory;
 import org.apache.dolphinscheduler.e2e.pages.project.workflow.WorkflowForm;
 
+import java.util.List;
+
+import lombok.Getter;
+
+import org.openqa.selenium.By;
+import org.openqa.selenium.JavascriptExecutor;
+import org.openqa.selenium.Keys;
 import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.support.FindBy;
+import org.openqa.selenium.support.FindBys;
+import org.openqa.selenium.support.PageFactory;
+import org.openqa.selenium.support.ui.ExpectedConditions;
+import org.openqa.selenium.support.ui.WebDriverWait;
 
+@Getter
 public class JavaTaskForm extends TaskNodeForm {
 
-    private CodeEditor codeEditor;
-
     private WebDriver driver;
 
+    @FindBys({
+            @FindBy(className = "resource-select"),
+            @FindBy(className = "n-base-selection"),
+    })
+    private WebElement selectResource;
+
+    @FindBys({
+
+            @FindBy(className = "n-tree-select"),
+            @FindBy(className = "n-base-selection"),
+    })
+    private WebElement selectMainPackage;
+
+    @FindBys({
+            @FindBy(xpath = "//div[contains(@class,'n-form-item') and .//span[text()='Run Type']]"),
+            @FindBy(className = "n-select"),
+            @FindBy(className = "n-base-selection")
+
+    })
+    private WebElement selectRunType;
+
     public JavaTaskForm(WorkflowForm parent) {
         super(parent);
 
-        this.codeEditor = new CodeEditor(parent.driver());
-
         this.driver = parent.driver();
+
+        PageFactory.initElements(driver, this);
     }
 
-    public JavaTaskForm script(String script) {
-        codeEditor.content(script);
+    public JavaTaskForm selectJavaResource(String resourceName) {
+        WebDriverWait wait = WebDriverWaitFactory.createWebDriverWait(driver());
+        wait.until(ExpectedConditions.elementToBeClickable(selectResource));
+        ((JavascriptExecutor) driver).executeScript("arguments[0].scrollIntoView(true); arguments[0].click();",
+                selectResource);
+        By optionsLocator = By.className("n-tree-node-content__text");
+        wait.until(ExpectedConditions.visibilityOfElementLocated(optionsLocator));
+
+        List<WebElement> options = driver.findElements(optionsLocator);
+        boolean found = false;
+        for (WebElement option : options) {
+            if (option.getText().trim().startsWith(resourceName)) {
+                ((JavascriptExecutor) driver).executeScript("arguments[0].scrollIntoView(true); arguments[0].click();",
+                        option);
+                found = true;
+                break;
+            }
+        }
+
+        if (!found) {
+            throw new RuntimeException("Cannot Found: " + resourceName);

Review Comment:
   Has been modified



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [DSIP-27][Task Plugin] Some improvements of JAVA task plugin [dolphinscheduler]

Posted by "ailiujiarui (via GitHub)" <gi...@apache.org>.
ailiujiarui commented on PR #16542:
URL: https://github.com/apache/dolphinscheduler/pull/16542#issuecomment-2481851426

   > There are some CI failed. Please check it. @ailiujiarui
   
   The bug has been fixed


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [DSIP-27][Task Plugin] Some improvements of JAVA task plugin [dolphinscheduler]

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #16542:
URL: https://github.com/apache/dolphinscheduler/pull/16542#issuecomment-2482524465

   Please retry analysis of this Pull-Request directly on SonarQube Cloud


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [DSIP-27][Task Plugin] Update the JAVA task [dolphinscheduler]

Posted by "fuchanghai (via GitHub)" <gi...@apache.org>.
fuchanghai commented on code in PR #16542:
URL: https://github.com/apache/dolphinscheduler/pull/16542#discussion_r1742912529


##########
dolphinscheduler-task-plugin/dolphinscheduler-task-java/src/main/java/org/apache/dolphinscheduler/plugin/task/java/JavaParameters.java:
##########
@@ -67,11 +60,12 @@ public class JavaParameters extends AbstractParameters {
     /**
      * Check that the parameters are valid
      *
-     * @returnboolean
+     * @return boolean
      */
     @Override
     public boolean checkParameters() {

Review Comment:
   i think ``` StringUtils.isNotEmpty(runType)``` is enough



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [DSIP-27][Task Plugin] Some improvements of JAVA task plugin [dolphinscheduler]

Posted by "SbloodyS (via GitHub)" <gi...@apache.org>.
SbloodyS commented on code in PR #16542:
URL: https://github.com/apache/dolphinscheduler/pull/16542#discussion_r1809736309


##########
dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/cases/WorkflowJavaTaskE2ETest.java:
##########
@@ -97,6 +100,11 @@ public static void setup() {
         userPage.update(user, user, email, phone, tenant)
                 .goToNav(ProjectPage.class)
                 .create(project);
+
+        ProjectPage projectPage = new ProjectPage(browser);
+        Awaitility.await().untilAsserted(() -> assertThat(projectPage.projectList())
+                .as("项目列表应包含新创建的项目")

Review Comment:
   Please using english.



##########
dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/project/workflow/task/JavaTaskForm.java:
##########
@@ -17,27 +17,111 @@
 
 package org.apache.dolphinscheduler.e2e.pages.project.workflow.task;
 
-import org.apache.dolphinscheduler.e2e.pages.common.CodeEditor;
 import org.apache.dolphinscheduler.e2e.pages.project.workflow.WorkflowForm;
 
+import java.time.Duration;
+import java.util.List;
+
+import lombok.Getter;
+
+import org.openqa.selenium.By;
+import org.openqa.selenium.JavascriptExecutor;
+import org.openqa.selenium.Keys;
 import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.support.FindBy;
+import org.openqa.selenium.support.PageFactory;
+import org.openqa.selenium.support.ui.ExpectedConditions;
+import org.openqa.selenium.support.ui.WebDriverWait;
 
+@Getter
 public class JavaTaskForm extends TaskNodeForm {
 
-    private CodeEditor codeEditor;
-
     private WebDriver driver;
 
+    @FindBy(xpath = "//label[span[text()='Run Type']]/following-sibling::div//div[contains(@class, 'n-base-selection')]")
+    private WebElement selectRunType;
+
+    @FindBy(xpath = "//label[span[text()='Main Package']]/following-sibling::div//div[contains(@class, 'n-base-selection-label')]")
+    private WebElement selectMainPackage;
+
+    @FindBy(xpath = "//div[@class='n-form-item-blank']//div[contains(@class, 'n-base-selection--multiple')]//div[contains(@class, 'n-base-selection-tags') and @tabindex='0']")

Review Comment:
   Same here.



##########
dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/project/workflow/task/JavaTaskForm.java:
##########
@@ -17,27 +17,111 @@
 
 package org.apache.dolphinscheduler.e2e.pages.project.workflow.task;
 
-import org.apache.dolphinscheduler.e2e.pages.common.CodeEditor;
 import org.apache.dolphinscheduler.e2e.pages.project.workflow.WorkflowForm;
 
+import java.time.Duration;
+import java.util.List;
+
+import lombok.Getter;
+
+import org.openqa.selenium.By;
+import org.openqa.selenium.JavascriptExecutor;
+import org.openqa.selenium.Keys;
 import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.support.FindBy;
+import org.openqa.selenium.support.PageFactory;
+import org.openqa.selenium.support.ui.ExpectedConditions;
+import org.openqa.selenium.support.ui.WebDriverWait;
 
+@Getter
 public class JavaTaskForm extends TaskNodeForm {
 
-    private CodeEditor codeEditor;
-
     private WebDriver driver;
 
+    @FindBy(xpath = "//label[span[text()='Run Type']]/following-sibling::div//div[contains(@class, 'n-base-selection')]")
+    private WebElement selectRunType;
+
+    @FindBy(xpath = "//label[span[text()='Main Package']]/following-sibling::div//div[contains(@class, 'n-base-selection-label')]")
+    private WebElement selectMainPackage;
+
+    @FindBy(xpath = "//div[@class='n-form-item-blank']//div[contains(@class, 'n-base-selection--multiple')]//div[contains(@class, 'n-base-selection-tags') and @tabindex='0']")
+    private WebElement selectResource;
+
     public JavaTaskForm(WorkflowForm parent) {
         super(parent);
 
-        this.codeEditor = new CodeEditor(parent.driver());
-
         this.driver = parent.driver();
+
+        PageFactory.initElements(driver, this);
     }
 
-    public JavaTaskForm script(String script) {
-        codeEditor.content(script);
+    public TaskNodeForm selectResource(String resourceName) {
+        WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(60));
+        wait.until(ExpectedConditions.elementToBeClickable(selectResource));
+        ((JavascriptExecutor) driver).executeScript("arguments[0].scrollIntoView(true); arguments[0].click();",
+                selectResource);
+        By optionsLocator = By.className("n-tree-node-content__text");
+        wait.until(ExpectedConditions.visibilityOfElementLocated(optionsLocator));
+
+        List<WebElement> options = driver.findElements(optionsLocator);
+        boolean found = false;
+        for (WebElement option : options) {
+            if (option.getText().trim().startsWith(resourceName)) {
+                ((JavascriptExecutor) driver).executeScript("arguments[0].scrollIntoView(true); arguments[0].click();",
+                        option);
+                found = true;
+                break;
+            }
+        }
+
+        if (!found) {
+            throw new RuntimeException("Cannot Found: " + resourceName);
+        }
+
+        driver.switchTo().activeElement().sendKeys(Keys.ESCAPE);
         return this;
     }
+
+    public JavaTaskForm selectRunType(String runType) {
+        WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(60)); // 增加等待时间

Review Comment:
   ```suggestion
           WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(60));
   ```



##########
dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/cases/WorkflowJavaTaskE2ETest.java:
##########
@@ -163,17 +183,112 @@ void testRunWorkflow() {
                 .run(workflow)
                 .submit();
 
-        Awaitility.await().untilAsserted(() -> {
-            browser.navigate().refresh();
+        Awaitility.await()
+                .atMost(Duration.ofMinutes(5))
+                .untilAsserted(() -> {
+                    browser.navigate().refresh();
+
+                    final WorkflowInstanceTab.Row row = projectPage
+                            .goToTab(WorkflowInstanceTab.class)
+                            .instances()
+                            .iterator()
+                            .next();
 
-            final WorkflowInstanceTab.Row row = projectPage
-                    .goToTab(WorkflowInstanceTab.class)
-                    .instances()
-                    .iterator()
-                    .next();
+                    assertThat(row.isSuccess()).isTrue();
+                    assertThat(row.executionTime()).isEqualTo(1);
+                });
 
-            assertThat(row.isSuccess()).isTrue();
-            assertThat(row.executionTime()).isEqualTo(1);
-        });
     }
+
+    @Test
+    @Order(60)
+    void testCreateNormalWorkflow() {
+        FileManagePage file = new NavBarPage(browser)
+                .goToNav(ResourcePage.class)
+                .goToTab(FileManagePage.class)
+                .uploadFile(filePath + "/normal2.jar");
+
+        WebDriverWait wait = WebDriverWaitFactory.createWebDriverWait(browser);
+
+        wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//span[text()='normal2.jar']")));
+
+        file.uploadFile(filePath + "/normal1.jar");
+
+        wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//span[text()='normal1.jar']")));
+
+        ProjectPage projectPage = new NavBarPage(browser)
+                .goToNav(ProjectPage.class);
+
+        wait.until(ExpectedConditions.visibilityOfAllElements(projectPage.projectList()));
+
+        WorkflowDefinitionTab workflowDefinitionPage = projectPage
+                .goTo(project)
+                .goToTab(WorkflowDefinitionTab.class);
+
+        workflowDefinitionPage.createWorkflow()
+                .<JavaTaskForm>addTask(WorkflowForm.TaskType.JAVA)
+                .selectRunType("NORMAL_JAR")
+                .selectMainPackage("normal1.jar")
+                .selectResource("normal1.jar")
+                .selectResource("normal2.jar")
+                .name("test-2")
+                .selectEnv(environmentName)
+                .submit()
+                .submit()
+                .name(workflow2)
+                .submit();
+
+        Awaitility.await().untilAsserted(() -> assertThat(workflowDefinitionPage.workflowList())
+                .as("Workflow list should contain newly-created workflow")
+                .anyMatch(it -> it.getText().contains(workflow2)));
+
+        workflowDefinitionPage.publish(workflow2);
+    }
+
+    @Test
+    @Order(90)
+    void testRunNormalWorkflow() {
+        final ProjectDetailPage projectPage =
+                new ProjectPage(browser)
+                        .goToNav(ProjectPage.class)
+                        .goTo(project);
+
+        projectPage
+                .goToTab(WorkflowInstanceTab.class)
+                .deleteAll();
+        projectPage
+                .goToTab(WorkflowDefinitionTab.class)
+                .run(workflow2)
+                .submit();
+
+        Awaitility.await()
+                .atMost(Duration.ofMinutes(5))
+                .untilAsserted(() -> {
+                    browser.navigate().refresh();
+
+                    final WorkflowInstanceTab.Row row = projectPage
+                            .goToTab(WorkflowInstanceTab.class)
+                            .instances()
+                            .iterator()
+                            .next();
+
+                    assertThat(row.isSuccess()).isTrue();
+                    assertThat(row.executionTime()).isEqualTo(1);
+                });
+        /*
+         * Awaitility.await() .atMost(Duration.ofMinutes(5)) .untilAsserted(() -> { browser.navigate().refresh();
+         * 
+         * final WorkflowInstanceTab workflowInstanceTab = projectPage.goToTab(WorkflowInstanceTab.class);
+         * 
+         * List<WorkflowInstanceTab.Row> instances = workflowInstanceTab.instances();
+         * 
+         * if (instances.isEmpty()) { throw new RuntimeException("No workflow instances found"); }
+         * 
+         * WorkflowInstanceTab.Row row = instances.get(0);
+         * 
+         * assertThat(row.isSuccess()).isTrue(); assertThat(row.executionTime()).isEqualTo(1); });
+         */

Review Comment:
   Avoid unnessnary comment. Remove this.



##########
dolphinscheduler-task-plugin/dolphinscheduler-task-java/src/main/java/org/apache/dolphinscheduler/plugin/task/java/JavaTask.java:
##########
@@ -150,43 +132,48 @@ public void handle(TaskCallBack taskCallBack) throws TaskException {
     }
 
     /**
-     * Construct a shell command for the java Run mode
+     * Construct a shell command for the java -jar Run mode
      *
      * @return String
-     * @throws Exception
      **/
-    protected String buildJavaCommand() throws Exception {
+    protected String buildJarCommand() {
+        ResourceContext resourceContext = taskRequest.getResourceContext();
+        String mainJarAbsolutePathInLocal = resourceContext
+                .getResourceItem(javaParameters.getMainJar().getResourceName())
+                .getResourceAbsolutePathInLocal();
         StringBuilder builder = new StringBuilder();
-        String sourceCode = buildJavaSourceContent();
-        builder.append(buildJavaCompileCommand(sourceCode))
-                .append(";")
-                .append(getJavaCommandPath())
+        builder.append(getJavaCommandPath())
                 .append("java").append(" ")
-                .append(buildResourcePath())
-                .append(" ")
-                .append(getPublicClassName(sourceCode))
-                .append(" ")
+                .append(buildResourcePath()).append(" ")
+                .append("-jar").append(" ")
+                .append(mainJarAbsolutePathInLocal).append(" ")
                 .append(javaParameters.getMainArgs().trim()).append(" ")
                 .append(javaParameters.getJvmArgs().trim());
         return builder.toString();
     }
 
     /**
-     * Construct a shell command for the java -jar Run mode
+     * Construct a shell command for the java -cp run mode
      *
      * @return String
      **/
-    protected String buildJarCommand() {
+    protected String buildNormalJarCommand() {
         ResourceContext resourceContext = taskRequest.getResourceContext();
-        String mainJarAbsolutePathInLocal = resourceContext
-                .getResourceItem(javaParameters.getMainJar().getResourceName())
+        String mainJarAbsolutePathInLocal = resourceContext.getResourceItem(
+                javaParameters.getMainJar()
+                        .getResourceName())
                 .getResourceAbsolutePathInLocal();
+        String mainJarName = null;
+        try {
+            mainJarName = MainClassExtractor.getMainClassName(mainJarAbsolutePathInLocal);
+        } catch (Exception e) {
+            e.printStackTrace();

Review Comment:
   ```suggestion
               logger.error("get mainJarName failed:", e);
   ```



##########
dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/project/workflow/task/JavaTaskForm.java:
##########
@@ -17,27 +17,111 @@
 
 package org.apache.dolphinscheduler.e2e.pages.project.workflow.task;
 
-import org.apache.dolphinscheduler.e2e.pages.common.CodeEditor;
 import org.apache.dolphinscheduler.e2e.pages.project.workflow.WorkflowForm;
 
+import java.time.Duration;
+import java.util.List;
+
+import lombok.Getter;
+
+import org.openqa.selenium.By;
+import org.openqa.selenium.JavascriptExecutor;
+import org.openqa.selenium.Keys;
 import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.support.FindBy;
+import org.openqa.selenium.support.PageFactory;
+import org.openqa.selenium.support.ui.ExpectedConditions;
+import org.openqa.selenium.support.ui.WebDriverWait;
 
+@Getter
 public class JavaTaskForm extends TaskNodeForm {
 
-    private CodeEditor codeEditor;
-
     private WebDriver driver;
 
+    @FindBy(xpath = "//label[span[text()='Run Type']]/following-sibling::div//div[contains(@class, 'n-base-selection')]")
+    private WebElement selectRunType;
+
+    @FindBy(xpath = "//label[span[text()='Main Package']]/following-sibling::div//div[contains(@class, 'n-base-selection-label')]")
+    private WebElement selectMainPackage;
+
+    @FindBy(xpath = "//div[@class='n-form-item-blank']//div[contains(@class, 'n-base-selection--multiple')]//div[contains(@class, 'n-base-selection-tags') and @tabindex='0']")
+    private WebElement selectResource;
+
     public JavaTaskForm(WorkflowForm parent) {
         super(parent);
 
-        this.codeEditor = new CodeEditor(parent.driver());
-
         this.driver = parent.driver();
+
+        PageFactory.initElements(driver, this);
     }
 
-    public JavaTaskForm script(String script) {
-        codeEditor.content(script);
+    public TaskNodeForm selectResource(String resourceName) {
+        WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(60));

Review Comment:
   Please using `WebDriverWaitFactory.createWebDriverWait(page.driver())` instead.



##########
dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/resources/fat.jar:
##########


Review Comment:
   You should create a folder like `dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/resources/docker/java-task` and put all these jars into it. And mount it into ds's docker image. Otherwise the test would fail.
   
   In addition, You should add some docs of the content of these three jars content for others to understand.



##########
dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/project/workflow/task/JavaTaskForm.java:
##########
@@ -17,27 +17,111 @@
 
 package org.apache.dolphinscheduler.e2e.pages.project.workflow.task;
 
-import org.apache.dolphinscheduler.e2e.pages.common.CodeEditor;
 import org.apache.dolphinscheduler.e2e.pages.project.workflow.WorkflowForm;
 
+import java.time.Duration;
+import java.util.List;
+
+import lombok.Getter;
+
+import org.openqa.selenium.By;
+import org.openqa.selenium.JavascriptExecutor;
+import org.openqa.selenium.Keys;
 import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.support.FindBy;
+import org.openqa.selenium.support.PageFactory;
+import org.openqa.selenium.support.ui.ExpectedConditions;
+import org.openqa.selenium.support.ui.WebDriverWait;
 
+@Getter
 public class JavaTaskForm extends TaskNodeForm {
 
-    private CodeEditor codeEditor;
-
     private WebDriver driver;
 
+    @FindBy(xpath = "//label[span[text()='Run Type']]/following-sibling::div//div[contains(@class, 'n-base-selection')]")
+    private WebElement selectRunType;
+
+    @FindBy(xpath = "//label[span[text()='Main Package']]/following-sibling::div//div[contains(@class, 'n-base-selection-label')]")

Review Comment:
   Same here.



##########
dolphinscheduler-task-plugin/dolphinscheduler-task-java/src/main/java/org/apache/dolphinscheduler/plugin/task/java/JavaTask.java:
##########
@@ -150,43 +132,48 @@ public void handle(TaskCallBack taskCallBack) throws TaskException {
     }
 
     /**
-     * Construct a shell command for the java Run mode
+     * Construct a shell command for the java -jar Run mode
      *
      * @return String
-     * @throws Exception
      **/
-    protected String buildJavaCommand() throws Exception {
+    protected String buildJarCommand() {
+        ResourceContext resourceContext = taskRequest.getResourceContext();
+        String mainJarAbsolutePathInLocal = resourceContext
+                .getResourceItem(javaParameters.getMainJar().getResourceName())
+                .getResourceAbsolutePathInLocal();
         StringBuilder builder = new StringBuilder();
-        String sourceCode = buildJavaSourceContent();
-        builder.append(buildJavaCompileCommand(sourceCode))
-                .append(";")
-                .append(getJavaCommandPath())
+        builder.append(getJavaCommandPath())
                 .append("java").append(" ")
-                .append(buildResourcePath())
-                .append(" ")
-                .append(getPublicClassName(sourceCode))
-                .append(" ")
+                .append(buildResourcePath()).append(" ")
+                .append("-jar").append(" ")
+                .append(mainJarAbsolutePathInLocal).append(" ")

Review Comment:
   Using `Constants.SPACE` instead of this.



##########
dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/project/workflow/task/JavaTaskForm.java:
##########
@@ -17,27 +17,111 @@
 
 package org.apache.dolphinscheduler.e2e.pages.project.workflow.task;
 
-import org.apache.dolphinscheduler.e2e.pages.common.CodeEditor;
 import org.apache.dolphinscheduler.e2e.pages.project.workflow.WorkflowForm;
 
+import java.time.Duration;
+import java.util.List;
+
+import lombok.Getter;
+
+import org.openqa.selenium.By;
+import org.openqa.selenium.JavascriptExecutor;
+import org.openqa.selenium.Keys;
 import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.support.FindBy;
+import org.openqa.selenium.support.PageFactory;
+import org.openqa.selenium.support.ui.ExpectedConditions;
+import org.openqa.selenium.support.ui.WebDriverWait;
 
+@Getter
 public class JavaTaskForm extends TaskNodeForm {
 
-    private CodeEditor codeEditor;
-
     private WebDriver driver;
 
+    @FindBy(xpath = "//label[span[text()='Run Type']]/following-sibling::div//div[contains(@class, 'n-base-selection')]")

Review Comment:
   This xpath is too extensive and unstable, please add class name to the button before using it.



##########
dolphinscheduler-task-plugin/dolphinscheduler-task-java/src/main/java/org/apache/dolphinscheduler/plugin/task/java/JavaTask.java:
##########
@@ -150,43 +132,48 @@ public void handle(TaskCallBack taskCallBack) throws TaskException {
     }
 
     /**
-     * Construct a shell command for the java Run mode
+     * Construct a shell command for the java -jar Run mode
      *
      * @return String
-     * @throws Exception
      **/
-    protected String buildJavaCommand() throws Exception {
+    protected String buildJarCommand() {
+        ResourceContext resourceContext = taskRequest.getResourceContext();
+        String mainJarAbsolutePathInLocal = resourceContext
+                .getResourceItem(javaParameters.getMainJar().getResourceName())
+                .getResourceAbsolutePathInLocal();
         StringBuilder builder = new StringBuilder();
-        String sourceCode = buildJavaSourceContent();
-        builder.append(buildJavaCompileCommand(sourceCode))
-                .append(";")
-                .append(getJavaCommandPath())
+        builder.append(getJavaCommandPath())
                 .append("java").append(" ")
-                .append(buildResourcePath())
-                .append(" ")
-                .append(getPublicClassName(sourceCode))
-                .append(" ")
+                .append(buildResourcePath()).append(" ")
+                .append("-jar").append(" ")
+                .append(mainJarAbsolutePathInLocal).append(" ")
                 .append(javaParameters.getMainArgs().trim()).append(" ")
                 .append(javaParameters.getJvmArgs().trim());
         return builder.toString();
     }
 
     /**
-     * Construct a shell command for the java -jar Run mode
+     * Construct a shell command for the java -cp run mode
      *
      * @return String
      **/
-    protected String buildJarCommand() {
+    protected String buildNormalJarCommand() {
         ResourceContext resourceContext = taskRequest.getResourceContext();
-        String mainJarAbsolutePathInLocal = resourceContext
-                .getResourceItem(javaParameters.getMainJar().getResourceName())
+        String mainJarAbsolutePathInLocal = resourceContext.getResourceItem(
+                javaParameters.getMainJar()
+                        .getResourceName())
                 .getResourceAbsolutePathInLocal();
+        String mainJarName = null;
+        try {
+            mainJarName = MainClassExtractor.getMainClassName(mainJarAbsolutePathInLocal);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
         StringBuilder builder = new StringBuilder();
         builder.append(getJavaCommandPath())
                 .append("java").append(" ")
                 .append(buildResourcePath()).append(" ")
-                .append("-jar").append(" ")
-                .append(mainJarAbsolutePathInLocal).append(" ")
+                .append(mainJarName).append(" ")

Review Comment:
   Same here.



##########
dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/project/workflow/task/JavaTaskForm.java:
##########
@@ -17,27 +17,111 @@
 
 package org.apache.dolphinscheduler.e2e.pages.project.workflow.task;
 
-import org.apache.dolphinscheduler.e2e.pages.common.CodeEditor;
 import org.apache.dolphinscheduler.e2e.pages.project.workflow.WorkflowForm;
 
+import java.time.Duration;
+import java.util.List;
+
+import lombok.Getter;
+
+import org.openqa.selenium.By;
+import org.openqa.selenium.JavascriptExecutor;
+import org.openqa.selenium.Keys;
 import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.support.FindBy;
+import org.openqa.selenium.support.PageFactory;
+import org.openqa.selenium.support.ui.ExpectedConditions;
+import org.openqa.selenium.support.ui.WebDriverWait;
 
+@Getter
 public class JavaTaskForm extends TaskNodeForm {
 
-    private CodeEditor codeEditor;
-
     private WebDriver driver;
 
+    @FindBy(xpath = "//label[span[text()='Run Type']]/following-sibling::div//div[contains(@class, 'n-base-selection')]")
+    private WebElement selectRunType;
+
+    @FindBy(xpath = "//label[span[text()='Main Package']]/following-sibling::div//div[contains(@class, 'n-base-selection-label')]")
+    private WebElement selectMainPackage;
+
+    @FindBy(xpath = "//div[@class='n-form-item-blank']//div[contains(@class, 'n-base-selection--multiple')]//div[contains(@class, 'n-base-selection-tags') and @tabindex='0']")
+    private WebElement selectResource;
+
     public JavaTaskForm(WorkflowForm parent) {
         super(parent);
 
-        this.codeEditor = new CodeEditor(parent.driver());
-
         this.driver = parent.driver();
+
+        PageFactory.initElements(driver, this);
     }
 
-    public JavaTaskForm script(String script) {
-        codeEditor.content(script);
+    public TaskNodeForm selectResource(String resourceName) {
+        WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(60));
+        wait.until(ExpectedConditions.elementToBeClickable(selectResource));
+        ((JavascriptExecutor) driver).executeScript("arguments[0].scrollIntoView(true); arguments[0].click();",
+                selectResource);
+        By optionsLocator = By.className("n-tree-node-content__text");
+        wait.until(ExpectedConditions.visibilityOfElementLocated(optionsLocator));
+
+        List<WebElement> options = driver.findElements(optionsLocator);
+        boolean found = false;
+        for (WebElement option : options) {
+            if (option.getText().trim().startsWith(resourceName)) {
+                ((JavascriptExecutor) driver).executeScript("arguments[0].scrollIntoView(true); arguments[0].click();",
+                        option);
+                found = true;
+                break;
+            }
+        }
+
+        if (!found) {
+            throw new RuntimeException("Cannot Found: " + resourceName);
+        }
+
+        driver.switchTo().activeElement().sendKeys(Keys.ESCAPE);
         return this;
     }
+
+    public JavaTaskForm selectRunType(String runType) {
+        WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(60)); // 增加等待时间

Review Comment:
   Same here.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [DSIP-27][Task Plugin] Some improvements of JAVA task plugin [dolphinscheduler]

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #16542:
URL: https://github.com/apache/dolphinscheduler/pull/16542#issuecomment-2434165982

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16542) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 New issues](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=16542&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=16542&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=16542&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=16542&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=16542&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16542)
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [DSIP-27][Task Plugin] Some improvements of JAVA task plugin [dolphinscheduler]

Posted by "Gallardot (via GitHub)" <gi...@apache.org>.
Gallardot commented on PR #16542:
URL: https://github.com/apache/dolphinscheduler/pull/16542#issuecomment-2441159034

   > Please don't add `.jar` in the source code, the `.jar` file will be excluded in src, these means the e2e will not be executed after release.
   
   +1.  I suggest adding the source code of the test jar to e2e module as a submodule, and compiling the corresponding jar through `mvn package` for e2e to test


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [DSIP-27][Task Plugin] Some improvements of JAVA task plugin [dolphinscheduler]

Posted by "ailiujiarui (via GitHub)" <gi...@apache.org>.
ailiujiarui commented on code in PR #16542:
URL: https://github.com/apache/dolphinscheduler/pull/16542#discussion_r1814068808


##########
dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/cases/WorkflowJavaTaskE2ETest.java:
##########
@@ -97,6 +100,11 @@ public static void setup() {
         userPage.update(user, user, email, phone, tenant)
                 .goToNav(ProjectPage.class)
                 .create(project);
+
+        ProjectPage projectPage = new ProjectPage(browser);
+        Awaitility.await().untilAsserted(() -> assertThat(projectPage.projectList())
+                .as("项目列表应包含新创建的项目")

Review Comment:
   modified.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [DSIP-27][Task Plugin] Some improvements of JAVA task plugin [dolphinscheduler]

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #16542:
URL: https://github.com/apache/dolphinscheduler/pull/16542#issuecomment-2439927316

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16542) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 New issues](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=16542&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=16542&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=16542&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=16542&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=16542&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16542)
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [DSIP-27][Task Plugin] Some improvements of JAVA task plugin [dolphinscheduler]

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #16542:
URL: https://github.com/apache/dolphinscheduler/pull/16542#issuecomment-2439926998

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16542) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 New issues](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=16542&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=16542&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=16542&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=16542&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=16542&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16542)
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [DSIP-27][Task Plugin] Some improvements of JAVA task plugin [dolphinscheduler]

Posted by "boring-cyborg[bot] (via GitHub)" <gi...@apache.org>.
boring-cyborg[bot] commented on PR #16542:
URL: https://github.com/apache/dolphinscheduler/pull/16542#issuecomment-2526809430

   Awesome work, congrats on your first merged pull request!
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [DSIP-27][Task Plugin] Some improvements of JAVA task plugin [dolphinscheduler]

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #16542:
URL: https://github.com/apache/dolphinscheduler/pull/16542#issuecomment-2484525514

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16542) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [1 New issue](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=16542&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=16542&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=16542&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [86.7% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=16542&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=16542&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16542)
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [DSIP-27][Task Plugin] Some improvements of JAVA task plugin [dolphinscheduler]

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #16542:
URL: https://github.com/apache/dolphinscheduler/pull/16542#issuecomment-2484527037

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16542) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [1 New issue](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=16542&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=16542&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=16542&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [86.7% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=16542&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=16542&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16542)
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [DSIP-27][Task Plugin] Some improvements of JAVA task plugin [dolphinscheduler]

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #16542:
URL: https://github.com/apache/dolphinscheduler/pull/16542#issuecomment-2481888603

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16542) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 New issues](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=16542&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=16542&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=16542&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=16542&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=16542&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16542)
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [DSIP-27][Task Plugin] Some improvements of JAVA task plugin [dolphinscheduler]

Posted by "SbloodyS (via GitHub)" <gi...@apache.org>.
SbloodyS commented on PR #16542:
URL: https://github.com/apache/dolphinscheduler/pull/16542#issuecomment-2477868185

   There are some CI failed. Please check it @ailiujiarui 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [DSIP-27][Task Plugin] Some improvements of JAVA task plugin [dolphinscheduler]

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #16542:
URL: https://github.com/apache/dolphinscheduler/pull/16542#issuecomment-2525090440

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16542) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [1 New issue](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=16542&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=16542&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=16542&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [75.6% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=16542&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=16542&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16542)
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [DSIP-27][Task Plugin] Some improvements of JAVA task plugin [dolphinscheduler]

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #16542:
URL: https://github.com/apache/dolphinscheduler/pull/16542#issuecomment-2525755339

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16542) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [1 New issue](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=16542&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=16542&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=16542&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [75.6% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=16542&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=16542&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16542)
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [DSIP-27][Task Plugin] Some improvements of JAVA task plugin [dolphinscheduler]

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #16542:
URL: https://github.com/apache/dolphinscheduler/pull/16542#issuecomment-2525755614

   Please retry analysis of this Pull-Request directly on SonarQube Cloud


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [DSIP-27][Task Plugin] Some improvements of JAVA task plugin [dolphinscheduler]

Posted by "ruanwenjun (via GitHub)" <gi...@apache.org>.
ruanwenjun commented on code in PR #16542:
URL: https://github.com/apache/dolphinscheduler/pull/16542#discussion_r1861862197


##########
docs/docs/zh/guide/task/java.md:
##########
@@ -22,25 +22,39 @@
 | 模块路径     | 开启使用JAVA9+的模块化特性,把所有资源放入--module-path中,要求您的worker中的JDK版本支持模块化 |
 | 主程序参数    | 作为普通Java程序main方法入口参数                                          |
 | 虚拟机参数    | 配置启动虚拟机参数                                                     |
-| 脚本       | 若使用JAVA运行类型则需要编写JAVA代码。代码中必须存在public类,不用写package语句            |
+| 主程序包     | 选择要运行程序的主程序包                                                  |
 | 资源       | 可以是外部JAR包也可以是其他资源文件,它们都会被加入到类路径或模块路径中,您可以在自己的JAVA脚本中轻松获取      |
 
 ## 任务样例
 
-java任务类型有两种运行模式,这里以JAVA模式为例进行演示。
+java任务类型有两种运行模式,这里进行分别进行演示。
 
 主要配置参数如下:
 
 - 运行类型
 - 模块路径
 - 主程序参数
 - 虚拟机参数
-- 脚本文件
+- 主程序包
+- 资源文件
 
-![java_task](../../../../img/tasks/demo/java_task02.png)
+如图所示
+
+- FAT_JAR类型
+
+![java_task](../../../../img/tasks/demo/java_fat.png)
+
+`FAT_JAR`即`uber-jar`,依赖和代码都在同一个`jar`中,只需选择这一个`jar`即可
+
+- NORMAL_JAR类型
+
+![java_task](../../../../img/tasks/demo/java_normal.png)
+
+`normal1.jar`是程序运行的入口,`normal2.jar`是所需的依赖,需要用主程序包指定程序的入口,并且在资源文件中选择所有依赖和程序入口的`jar`文件,才能正确运行
 
 ## 注意事项
 
-使用JAVA运行类型时代码中必须存在public类,可以不写package语句
+1. 使用`FAT_JAR`运行类型必须选择主程序包,使用和对应的资源文件,否则任务会直接失败
+2. 使用`NORMAL_JAR`运行类型必须选择主程序包和对应的资源文件,否则任务会直接失败。主程序包决定程序从哪里开始运行,选择资源文件之后,运行程序时,资源文件会以`-cp`的方式进行调用

Review Comment:
   Can we simplify this? The normal jar should provide main class, fat jar don't need to provide main class.



##########
dolphinscheduler-task-plugin/dolphinscheduler-task-java/src/main/java/org/apache/dolphinscheduler/plugin/task/java/JavaParameters.java:
##########
@@ -67,11 +62,11 @@ public class JavaParameters extends AbstractParameters {
     /**
      * Check that the parameters are valid
      *
-     * @returnboolean
+     * @return boolean
      */
     @Override
     public boolean checkParameters() {
-        return runType != null && (StringUtils.isNotBlank(rawScript) || mainJar != null);
+        return StringUtils.isNotEmpty(runType);

Review Comment:
   You don't need to check other args? e.g. `mainJar`



##########
dolphinscheduler-task-plugin/dolphinscheduler-task-java/src/main/java/org/apache/dolphinscheduler/plugin/task/java/JavaTask.java:
##########
@@ -150,44 +133,45 @@ public void handle(TaskCallBack taskCallBack) throws TaskException {
     }
 
     /**
-     * Construct a shell command for the java Run mode
+     * Construct a shell command for the java -jar Run mode
      *
      * @return String
-     * @throws Exception
      **/
-    protected String buildJavaCommand() throws Exception {
+    protected String buildJarCommand() {
+        ResourceContext resourceContext = taskRequest.getResourceContext();
+        String mainJarAbsolutePathInLocal = resourceContext
+                .getResourceItem(javaParameters.getMainJar().getResourceName())
+                .getResourceAbsolutePathInLocal();
         StringBuilder builder = new StringBuilder();
-        String sourceCode = buildJavaSourceContent();
-        builder.append(buildJavaCompileCommand(sourceCode))
-                .append(";")
-                .append(getJavaCommandPath())
-                .append("java").append(" ")
-                .append(buildResourcePath())
-                .append(" ")
-                .append(getPublicClassName(sourceCode))
-                .append(" ")
-                .append(javaParameters.getMainArgs().trim()).append(" ")
+        builder.append(getJavaCommandPath())
+                .append("java").append(Constants.SPACE)
+                .append(buildResourcePath()).append(Constants.SPACE)
+                .append("-jar").append(Constants.SPACE)
+                .append(mainJarAbsolutePathInLocal).append(Constants.SPACE)
+                .append(javaParameters.getMainArgs().trim()).append(Constants.SPACE)
                 .append(javaParameters.getJvmArgs().trim());
         return builder.toString();
     }
 
     /**
-     * Construct a shell command for the java -jar Run mode
+     * Construct a shell command for the java -cp run mode
      *
      * @return String
      **/
-    protected String buildJarCommand() {
+    protected String buildNormalJarCommand() {
         ResourceContext resourceContext = taskRequest.getResourceContext();
-        String mainJarAbsolutePathInLocal = resourceContext
-                .getResourceItem(javaParameters.getMainJar().getResourceName())
+        String mainJarAbsolutePathInLocal = resourceContext.getResourceItem(
+                javaParameters.getMainJar()
+                        .getResourceName())
                 .getResourceAbsolutePathInLocal();
+        String mainJarName = MainClassExtractor.getMainClassName(mainJarAbsolutePathInLocal);

Review Comment:
   Let user provide the entry class.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [DSIP-27][Task Plugin] Some improvements of JAVA task plugin [dolphinscheduler]

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #16542:
URL: https://github.com/apache/dolphinscheduler/pull/16542#issuecomment-2440673393

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16542) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 New issues](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=16542&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=16542&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=16542&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=16542&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=16542&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16542)
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [DSIP-27][Task Plugin] Some improvements of JAVA task plugin [dolphinscheduler]

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #16542:
URL: https://github.com/apache/dolphinscheduler/pull/16542#issuecomment-2440670487

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16542) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 New issues](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=16542&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=16542&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=16542&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=16542&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=16542&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16542)
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [DSIP-27][Task Plugin] Some improvements of JAVA task plugin [dolphinscheduler]

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #16542:
URL: https://github.com/apache/dolphinscheduler/pull/16542#issuecomment-2461758853

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16542) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 New issues](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=16542&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=16542&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=16542&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [80.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=16542&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=16542&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16542)
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [DSIP-27][Task Plugin] Some improvements of JAVA task plugin [dolphinscheduler]

Posted by "ailiujiarui (via GitHub)" <gi...@apache.org>.
ailiujiarui commented on PR #16542:
URL: https://github.com/apache/dolphinscheduler/pull/16542#issuecomment-2426185840

   > Please change the docs too.
   docs has been updated


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [DSIP-27][Task Plugin] Some improvements of JAVA task plugin [dolphinscheduler]

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #16542:
URL: https://github.com/apache/dolphinscheduler/pull/16542#issuecomment-2436981696

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16542) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 New issues](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=16542&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=16542&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=16542&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=16542&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=16542&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16542)
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [DSIP-27][Task Plugin] Some improvements of JAVA task plugin [dolphinscheduler]

Posted by "ailiujiarui (via GitHub)" <gi...@apache.org>.
ailiujiarui commented on PR #16542:
URL: https://github.com/apache/dolphinscheduler/pull/16542#issuecomment-2443770782

   > > > Please don't add `.jar` in the source code, the `.jar` file will be excluded in src, these means the e2e will not be executed after release.请不要在源码中添加 `.jar`,`.jar` 文件将被排除在 src 中,这意味着 e2e 发布后不会执行。
   > > 
   > > 
   > > +1. I suggest adding the source code of the test jar to e2e module as a submodule, and compiling the corresponding jar through `mvn package` for e2e to test+1.我建议将测试 jar 的源码作为子模块添加到 e2e 模块中,并通过 `mvn 包`编译相应的 jar 供 e2e 测试
   > > cc:  抄送:@ailiujiarui @SbloodyS @ruanwenjun
   > 
   > Agreed. 同意。
   
   I first tried placing the three classes fat, normal1, and normal2 in the common package under e2e-case, then compiled and packaged them into JAR files through code to provide for other workflows. However, the problem arose because the worker uses Java 8, while e2etest uses Java 11. The JAR packaged under the e2e directory couldn't be executed by the worker, throwing an error due to a higher version. I then tried moving common to the resources package under e2e-case and created a shell workflow to compile these three classes using the worker and output them to /tmp. The code then packages them into a JAR, but the current issue is that it keeps reporting that it can't find [Fat.class ](https://fat.class/)under /tmp, resulting in an empty JAR. I don't know what the reason is.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [DSIP-27][Task Plugin] Some improvements of JAVA task plugin [dolphinscheduler]

Posted by "ailiujiarui (via GitHub)" <gi...@apache.org>.
ailiujiarui commented on PR #16542:
URL: https://github.com/apache/dolphinscheduler/pull/16542#issuecomment-2408802814

   > 请将这些更改添加到文档中。
   Document has been updated.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [DSIP-27][Task Plugin] Some improvements of JAVA task plugin [dolphinscheduler]

Posted by "ailiujiarui (via GitHub)" <gi...@apache.org>.
ailiujiarui commented on code in PR #16542:
URL: https://github.com/apache/dolphinscheduler/pull/16542#discussion_r1828916549


##########
dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/resources/common/Fat.java:
##########


Review Comment:
   Has been modified



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [DSIP-27][Task Plugin] Some improvements of JAVA task plugin [dolphinscheduler]

Posted by "SbloodyS (via GitHub)" <gi...@apache.org>.
SbloodyS commented on PR #16542:
URL: https://github.com/apache/dolphinscheduler/pull/16542#issuecomment-2487722614

   > > There are some CI failed. Please check it. @ailiujiarui
   > 
   > The bug has been fixed
   
   The `WorkflowJavaTaskE2ETest` still failed.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [DSIP-27][Task Plugin] Some improvements of JAVA task plugin [dolphinscheduler]

Posted by "ailiujiarui (via GitHub)" <gi...@apache.org>.
ailiujiarui commented on code in PR #16542:
URL: https://github.com/apache/dolphinscheduler/pull/16542#discussion_r1862898174


##########
dolphinscheduler-task-plugin/dolphinscheduler-task-java/src/main/java/org/apache/dolphinscheduler/plugin/task/java/JavaTask.java:
##########
@@ -150,44 +133,45 @@ public void handle(TaskCallBack taskCallBack) throws TaskException {
     }
 
     /**
-     * Construct a shell command for the java Run mode
+     * Construct a shell command for the java -jar Run mode
      *
      * @return String
-     * @throws Exception
      **/
-    protected String buildJavaCommand() throws Exception {
+    protected String buildJarCommand() {
+        ResourceContext resourceContext = taskRequest.getResourceContext();
+        String mainJarAbsolutePathInLocal = resourceContext
+                .getResourceItem(javaParameters.getMainJar().getResourceName())
+                .getResourceAbsolutePathInLocal();
         StringBuilder builder = new StringBuilder();
-        String sourceCode = buildJavaSourceContent();
-        builder.append(buildJavaCompileCommand(sourceCode))
-                .append(";")
-                .append(getJavaCommandPath())
-                .append("java").append(" ")
-                .append(buildResourcePath())
-                .append(" ")
-                .append(getPublicClassName(sourceCode))
-                .append(" ")
-                .append(javaParameters.getMainArgs().trim()).append(" ")
+        builder.append(getJavaCommandPath())
+                .append("java").append(Constants.SPACE)
+                .append(buildResourcePath()).append(Constants.SPACE)
+                .append("-jar").append(Constants.SPACE)
+                .append(mainJarAbsolutePathInLocal).append(Constants.SPACE)
+                .append(javaParameters.getMainArgs().trim()).append(Constants.SPACE)
                 .append(javaParameters.getJvmArgs().trim());
         return builder.toString();
     }
 
     /**
-     * Construct a shell command for the java -jar Run mode
+     * Construct a shell command for the java -cp run mode
      *
      * @return String
      **/
-    protected String buildJarCommand() {
+    protected String buildNormalJarCommand() {
         ResourceContext resourceContext = taskRequest.getResourceContext();
-        String mainJarAbsolutePathInLocal = resourceContext
-                .getResourceItem(javaParameters.getMainJar().getResourceName())
+        String mainJarAbsolutePathInLocal = resourceContext.getResourceItem(
+                javaParameters.getMainJar()
+                        .getResourceName())
                 .getResourceAbsolutePathInLocal();
+        String mainJarName = MainClassExtractor.getMainClassName(mainJarAbsolutePathInLocal);

Review Comment:
   Do you mean that users should input the main class name themselves? Currently, the method reads the main class from the JAR's META-INF file. I believe this approach eliminates the need for configuration steps, allowing users to simply select the JAR and run it directly. Could you please explain why users should be required to input the main class name themselves?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [DSIP-27][Task Plugin] Some improvements of JAVA task plugin [dolphinscheduler]

Posted by "ailiujiarui (via GitHub)" <gi...@apache.org>.
ailiujiarui commented on code in PR #16542:
URL: https://github.com/apache/dolphinscheduler/pull/16542#discussion_r1862898174


##########
dolphinscheduler-task-plugin/dolphinscheduler-task-java/src/main/java/org/apache/dolphinscheduler/plugin/task/java/JavaTask.java:
##########
@@ -150,44 +133,45 @@ public void handle(TaskCallBack taskCallBack) throws TaskException {
     }
 
     /**
-     * Construct a shell command for the java Run mode
+     * Construct a shell command for the java -jar Run mode
      *
      * @return String
-     * @throws Exception
      **/
-    protected String buildJavaCommand() throws Exception {
+    protected String buildJarCommand() {
+        ResourceContext resourceContext = taskRequest.getResourceContext();
+        String mainJarAbsolutePathInLocal = resourceContext
+                .getResourceItem(javaParameters.getMainJar().getResourceName())
+                .getResourceAbsolutePathInLocal();
         StringBuilder builder = new StringBuilder();
-        String sourceCode = buildJavaSourceContent();
-        builder.append(buildJavaCompileCommand(sourceCode))
-                .append(";")
-                .append(getJavaCommandPath())
-                .append("java").append(" ")
-                .append(buildResourcePath())
-                .append(" ")
-                .append(getPublicClassName(sourceCode))
-                .append(" ")
-                .append(javaParameters.getMainArgs().trim()).append(" ")
+        builder.append(getJavaCommandPath())
+                .append("java").append(Constants.SPACE)
+                .append(buildResourcePath()).append(Constants.SPACE)
+                .append("-jar").append(Constants.SPACE)
+                .append(mainJarAbsolutePathInLocal).append(Constants.SPACE)
+                .append(javaParameters.getMainArgs().trim()).append(Constants.SPACE)
                 .append(javaParameters.getJvmArgs().trim());
         return builder.toString();
     }
 
     /**
-     * Construct a shell command for the java -jar Run mode
+     * Construct a shell command for the java -cp run mode
      *
      * @return String
      **/
-    protected String buildJarCommand() {
+    protected String buildNormalJarCommand() {
         ResourceContext resourceContext = taskRequest.getResourceContext();
-        String mainJarAbsolutePathInLocal = resourceContext
-                .getResourceItem(javaParameters.getMainJar().getResourceName())
+        String mainJarAbsolutePathInLocal = resourceContext.getResourceItem(
+                javaParameters.getMainJar()
+                        .getResourceName())
                 .getResourceAbsolutePathInLocal();
+        String mainJarName = MainClassExtractor.getMainClassName(mainJarAbsolutePathInLocal);

Review Comment:
   Do you mean that users should input the main class name themselves? Currently, the method reads the main class from the JAR's META-INF file. I believe this approach eliminates the need for configuration steps, allowing users to simply select the JAR and run it directly. Could you please explain why users should be required to input the main class name themselves?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [DSIP-27][Task Plugin] Some improvements of JAVA task plugin [dolphinscheduler]

Posted by "ailiujiarui (via GitHub)" <gi...@apache.org>.
ailiujiarui commented on PR #16542:
URL: https://github.com/apache/dolphinscheduler/pull/16542#issuecomment-2524958963

   Requires Approval @ruanwenjun 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [DSIP-27][Task Plugin] Some improvements of JAVA task plugin [dolphinscheduler]

Posted by "ailiujiarui (via GitHub)" <gi...@apache.org>.
ailiujiarui commented on code in PR #16542:
URL: https://github.com/apache/dolphinscheduler/pull/16542#discussion_r1811610562


##########
dolphinscheduler-task-plugin/dolphinscheduler-task-java/src/main/java/org/apache/dolphinscheduler/plugin/task/java/JavaTask.java:
##########
@@ -150,43 +132,48 @@ public void handle(TaskCallBack taskCallBack) throws TaskException {
     }
 
     /**
-     * Construct a shell command for the java Run mode
+     * Construct a shell command for the java -jar Run mode
      *
      * @return String
-     * @throws Exception
      **/
-    protected String buildJavaCommand() throws Exception {
+    protected String buildJarCommand() {
+        ResourceContext resourceContext = taskRequest.getResourceContext();
+        String mainJarAbsolutePathInLocal = resourceContext
+                .getResourceItem(javaParameters.getMainJar().getResourceName())
+                .getResourceAbsolutePathInLocal();
         StringBuilder builder = new StringBuilder();
-        String sourceCode = buildJavaSourceContent();
-        builder.append(buildJavaCompileCommand(sourceCode))
-                .append(";")
-                .append(getJavaCommandPath())
+        builder.append(getJavaCommandPath())
                 .append("java").append(" ")
-                .append(buildResourcePath())
-                .append(" ")
-                .append(getPublicClassName(sourceCode))
-                .append(" ")
+                .append(buildResourcePath()).append(" ")
+                .append("-jar").append(" ")
+                .append(mainJarAbsolutePathInLocal).append(" ")
                 .append(javaParameters.getMainArgs().trim()).append(" ")
                 .append(javaParameters.getJvmArgs().trim());
         return builder.toString();
     }
 
     /**
-     * Construct a shell command for the java -jar Run mode
+     * Construct a shell command for the java -cp run mode
      *
      * @return String
      **/
-    protected String buildJarCommand() {
+    protected String buildNormalJarCommand() {
         ResourceContext resourceContext = taskRequest.getResourceContext();
-        String mainJarAbsolutePathInLocal = resourceContext
-                .getResourceItem(javaParameters.getMainJar().getResourceName())
+        String mainJarAbsolutePathInLocal = resourceContext.getResourceItem(
+                javaParameters.getMainJar()
+                        .getResourceName())
                 .getResourceAbsolutePathInLocal();
+        String mainJarName = null;
+        try {
+            mainJarName = MainClassExtractor.getMainClassName(mainJarAbsolutePathInLocal);
+        } catch (Exception e) {
+            e.printStackTrace();

Review Comment:
   Already modified in MainClassExtractor.java and removed the try-catch here.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [DSIP-27][Task Plugin] Some improvements of JAVA task plugin [dolphinscheduler]

Posted by "ailiujiarui (via GitHub)" <gi...@apache.org>.
ailiujiarui commented on code in PR #16542:
URL: https://github.com/apache/dolphinscheduler/pull/16542#discussion_r1814074747


##########
dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/project/workflow/task/JavaTaskForm.java:
##########
@@ -17,27 +17,111 @@
 
 package org.apache.dolphinscheduler.e2e.pages.project.workflow.task;
 
-import org.apache.dolphinscheduler.e2e.pages.common.CodeEditor;
 import org.apache.dolphinscheduler.e2e.pages.project.workflow.WorkflowForm;
 
+import java.time.Duration;
+import java.util.List;
+
+import lombok.Getter;
+
+import org.openqa.selenium.By;
+import org.openqa.selenium.JavascriptExecutor;
+import org.openqa.selenium.Keys;
 import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.support.FindBy;
+import org.openqa.selenium.support.PageFactory;
+import org.openqa.selenium.support.ui.ExpectedConditions;
+import org.openqa.selenium.support.ui.WebDriverWait;
 
+@Getter
 public class JavaTaskForm extends TaskNodeForm {
 
-    private CodeEditor codeEditor;
-
     private WebDriver driver;
 
+    @FindBy(xpath = "//label[span[text()='Run Type']]/following-sibling::div//div[contains(@class, 'n-base-selection')]")
+    private WebElement selectRunType;
+
+    @FindBy(xpath = "//label[span[text()='Main Package']]/following-sibling::div//div[contains(@class, 'n-base-selection-label')]")
+    private WebElement selectMainPackage;
+
+    @FindBy(xpath = "//div[@class='n-form-item-blank']//div[contains(@class, 'n-base-selection--multiple')]//div[contains(@class, 'n-base-selection-tags') and @tabindex='0']")
+    private WebElement selectResource;
+
     public JavaTaskForm(WorkflowForm parent) {
         super(parent);
 
-        this.codeEditor = new CodeEditor(parent.driver());
-
         this.driver = parent.driver();
+
+        PageFactory.initElements(driver, this);
     }
 
-    public JavaTaskForm script(String script) {
-        codeEditor.content(script);
+    public TaskNodeForm selectResource(String resourceName) {
+        WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(60));
+        wait.until(ExpectedConditions.elementToBeClickable(selectResource));
+        ((JavascriptExecutor) driver).executeScript("arguments[0].scrollIntoView(true); arguments[0].click();",
+                selectResource);
+        By optionsLocator = By.className("n-tree-node-content__text");
+        wait.until(ExpectedConditions.visibilityOfElementLocated(optionsLocator));
+
+        List<WebElement> options = driver.findElements(optionsLocator);
+        boolean found = false;
+        for (WebElement option : options) {
+            if (option.getText().trim().startsWith(resourceName)) {
+                ((JavascriptExecutor) driver).executeScript("arguments[0].scrollIntoView(true); arguments[0].click();",
+                        option);
+                found = true;
+                break;
+            }
+        }
+
+        if (!found) {
+            throw new RuntimeException("Cannot Found: " + resourceName);
+        }
+
+        driver.switchTo().activeElement().sendKeys(Keys.ESCAPE);
         return this;
     }
+
+    public JavaTaskForm selectRunType(String runType) {
+        WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(60)); // 增加等待时间

Review Comment:
   The code has been modified



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [DSIP-27][Task Plugin] Some improvements of JAVA task plugin [dolphinscheduler]

Posted by "ailiujiarui (via GitHub)" <gi...@apache.org>.
ailiujiarui commented on code in PR #16542:
URL: https://github.com/apache/dolphinscheduler/pull/16542#discussion_r1814073493


##########
dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/project/workflow/task/JavaTaskForm.java:
##########
@@ -17,27 +17,111 @@
 
 package org.apache.dolphinscheduler.e2e.pages.project.workflow.task;
 
-import org.apache.dolphinscheduler.e2e.pages.common.CodeEditor;
 import org.apache.dolphinscheduler.e2e.pages.project.workflow.WorkflowForm;
 
+import java.time.Duration;
+import java.util.List;
+
+import lombok.Getter;
+
+import org.openqa.selenium.By;
+import org.openqa.selenium.JavascriptExecutor;
+import org.openqa.selenium.Keys;
 import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.support.FindBy;
+import org.openqa.selenium.support.PageFactory;
+import org.openqa.selenium.support.ui.ExpectedConditions;
+import org.openqa.selenium.support.ui.WebDriverWait;
 
+@Getter
 public class JavaTaskForm extends TaskNodeForm {
 
-    private CodeEditor codeEditor;
-
     private WebDriver driver;
 
+    @FindBy(xpath = "//label[span[text()='Run Type']]/following-sibling::div//div[contains(@class, 'n-base-selection')]")
+    private WebElement selectRunType;
+
+    @FindBy(xpath = "//label[span[text()='Main Package']]/following-sibling::div//div[contains(@class, 'n-base-selection-label')]")

Review Comment:
   Change to using @FindBys with class name.



##########
dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/project/workflow/task/JavaTaskForm.java:
##########
@@ -17,27 +17,111 @@
 
 package org.apache.dolphinscheduler.e2e.pages.project.workflow.task;
 
-import org.apache.dolphinscheduler.e2e.pages.common.CodeEditor;
 import org.apache.dolphinscheduler.e2e.pages.project.workflow.WorkflowForm;
 
+import java.time.Duration;
+import java.util.List;
+
+import lombok.Getter;
+
+import org.openqa.selenium.By;
+import org.openqa.selenium.JavascriptExecutor;
+import org.openqa.selenium.Keys;
 import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.support.FindBy;
+import org.openqa.selenium.support.PageFactory;
+import org.openqa.selenium.support.ui.ExpectedConditions;
+import org.openqa.selenium.support.ui.WebDriverWait;
 
+@Getter
 public class JavaTaskForm extends TaskNodeForm {
 
-    private CodeEditor codeEditor;
-
     private WebDriver driver;
 
+    @FindBy(xpath = "//label[span[text()='Run Type']]/following-sibling::div//div[contains(@class, 'n-base-selection')]")
+    private WebElement selectRunType;
+
+    @FindBy(xpath = "//label[span[text()='Main Package']]/following-sibling::div//div[contains(@class, 'n-base-selection-label')]")
+    private WebElement selectMainPackage;
+
+    @FindBy(xpath = "//div[@class='n-form-item-blank']//div[contains(@class, 'n-base-selection--multiple')]//div[contains(@class, 'n-base-selection-tags') and @tabindex='0']")

Review Comment:
   Change to using @FindBys with class name.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [DSIP-27][Task Plugin] Some improvements of JAVA task plugin [dolphinscheduler]

Posted by "ailiujiarui (via GitHub)" <gi...@apache.org>.
ailiujiarui commented on code in PR #16542:
URL: https://github.com/apache/dolphinscheduler/pull/16542#discussion_r1814157882


##########
dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/resources/fat.jar:
##########


Review Comment:
   The files have been mounted to the image



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [DSIP-27][Task Plugin] Some improvements of JAVA task plugin [dolphinscheduler]

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #16542:
URL: https://github.com/apache/dolphinscheduler/pull/16542#issuecomment-2436984409

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16542) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 New issues](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=16542&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=16542&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=16542&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=16542&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=16542&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16542)
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [DSIP-27][Task Plugin] Some improvements of JAVA task plugin [dolphinscheduler]

Posted by "SbloodyS (via GitHub)" <gi...@apache.org>.
SbloodyS commented on PR #16542:
URL: https://github.com/apache/dolphinscheduler/pull/16542#issuecomment-2441423161

   > > Please don't add `.jar` in the source code, the `.jar` file will be excluded in src, these means the e2e will not be executed after release.
   > 
   > +1. I suggest adding the source code of the test jar to e2e module as a submodule, and compiling the corresponding jar through `mvn package` for e2e to test
   > 
   > cc: @ailiujiarui @SbloodyS @ruanwenjun
   
   Agreed.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [DSIP-27][Task Plugin] Some improvements of JAVA task plugin [dolphinscheduler]

Posted by "ailiujiarui (via GitHub)" <gi...@apache.org>.
ailiujiarui commented on code in PR #16542:
URL: https://github.com/apache/dolphinscheduler/pull/16542#discussion_r1777087687


##########
.github/workflows/e2e.yml:
##########
@@ -124,8 +124,6 @@ jobs:
             class: org.apache.dolphinscheduler.e2e.cases.WorkflowE2ETest
           - name: WorkflowHttpTaskE2ETest
             class: org.apache.dolphinscheduler.e2e.cases.WorkflowHttpTaskE2ETest
-          - name: WorkflowJavaTaskE2ETest
-            class: org.apache.dolphinscheduler.e2e.cases.WorkflowJavaTaskE2ETest

Review Comment:
   Since the original workflowJavaTaskE2ETest was used to test Java code types under Java task types, and this feature has been removed, this test is no longer needed.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [DSIP-27][Task Plugin] Some improvements of JAVA task plugin [dolphinscheduler]

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #16542:
URL: https://github.com/apache/dolphinscheduler/pull/16542#issuecomment-2489928910

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16542) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [1 New issue](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=16542&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=16542&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=16542&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [86.7% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=16542&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=16542&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16542)
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [DSIP-27][Task Plugin] Update the JAVA task [dolphinscheduler]

Posted by "SbloodyS (via GitHub)" <gi...@apache.org>.
SbloodyS commented on code in PR #16542:
URL: https://github.com/apache/dolphinscheduler/pull/16542#discussion_r1744688531


##########
dolphinscheduler-task-plugin/dolphinscheduler-task-java/src/main/java/org/apache/dolphinscheduler/plugin/task/java/JavaConstants.java:
##########
@@ -29,14 +29,14 @@ private JavaConstants() {
     public static final String JAVA_HOME_VAR = "${JAVA_HOME}";
 
     /**
-     * this constant represents the use of the java command to run a task
+     * This constant represents the use of the java -jar command to run a task
      **/
-    public static final String RUN_TYPE_JAVA = "JAVA";
+    public static final String RUN_TYPE_FAT_JAR = "FATJAR";
 
     /**
-     * this constant represents the use of the java -jar command to run a task
+     * This constant represents the use of the java -cp command to run a task
      **/
-    public static final String RUN_TYPE_JAR = "JAR";
+    public static final String RUN_TYPE_NORMAL_JAR = "NORMALJAR";

Review Comment:
   Can we replace `FATJAR` to `FAT_JAR` for better readability? Same as `NORMALJAR`.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [DSIP-27][Task Plugin] Update the JAVA task [dolphinscheduler]

Posted by "ailiujiarui (via GitHub)" <gi...@apache.org>.
ailiujiarui commented on code in PR #16542:
URL: https://github.com/apache/dolphinscheduler/pull/16542#discussion_r1744703612


##########
dolphinscheduler-task-plugin/dolphinscheduler-task-java/src/main/java/org/apache/dolphinscheduler/plugin/task/java/JavaConstants.java:
##########
@@ -29,14 +29,14 @@ private JavaConstants() {
     public static final String JAVA_HOME_VAR = "${JAVA_HOME}";
 
     /**
-     * this constant represents the use of the java command to run a task
+     * This constant represents the use of the java -jar command to run a task
      **/
-    public static final String RUN_TYPE_JAVA = "JAVA";
+    public static final String RUN_TYPE_FAT_JAR = "FATJAR";
 
     /**
-     * this constant represents the use of the java -jar command to run a task
+     * This constant represents the use of the java -cp command to run a task
      **/
-    public static final String RUN_TYPE_JAR = "JAR";
+    public static final String RUN_TYPE_NORMAL_JAR = "NORMALJAR";

Review Comment:
   All relevant document modifications have been completed.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [DSIP-27][Task Plugin] Some improvements of JAVA task plugin [dolphinscheduler]

Posted by "ailiujiarui (via GitHub)" <gi...@apache.org>.
ailiujiarui commented on code in PR #16542:
URL: https://github.com/apache/dolphinscheduler/pull/16542#discussion_r1811609348


##########
dolphinscheduler-task-plugin/dolphinscheduler-task-java/src/main/java/org/apache/dolphinscheduler/plugin/task/java/JavaTask.java:
##########
@@ -150,43 +132,48 @@ public void handle(TaskCallBack taskCallBack) throws TaskException {
     }
 
     /**
-     * Construct a shell command for the java Run mode
+     * Construct a shell command for the java -jar Run mode
      *
      * @return String
-     * @throws Exception
      **/
-    protected String buildJavaCommand() throws Exception {
+    protected String buildJarCommand() {
+        ResourceContext resourceContext = taskRequest.getResourceContext();
+        String mainJarAbsolutePathInLocal = resourceContext
+                .getResourceItem(javaParameters.getMainJar().getResourceName())
+                .getResourceAbsolutePathInLocal();
         StringBuilder builder = new StringBuilder();
-        String sourceCode = buildJavaSourceContent();
-        builder.append(buildJavaCompileCommand(sourceCode))
-                .append(";")
-                .append(getJavaCommandPath())
+        builder.append(getJavaCommandPath())
                 .append("java").append(" ")
-                .append(buildResourcePath())
-                .append(" ")
-                .append(getPublicClassName(sourceCode))
-                .append(" ")
+                .append(buildResourcePath()).append(" ")
+                .append("-jar").append(" ")
+                .append(mainJarAbsolutePathInLocal).append(" ")
                 .append(javaParameters.getMainArgs().trim()).append(" ")
                 .append(javaParameters.getJvmArgs().trim());
         return builder.toString();
     }
 
     /**
-     * Construct a shell command for the java -jar Run mode
+     * Construct a shell command for the java -cp run mode
      *
      * @return String
      **/
-    protected String buildJarCommand() {
+    protected String buildNormalJarCommand() {
         ResourceContext resourceContext = taskRequest.getResourceContext();
-        String mainJarAbsolutePathInLocal = resourceContext
-                .getResourceItem(javaParameters.getMainJar().getResourceName())
+        String mainJarAbsolutePathInLocal = resourceContext.getResourceItem(
+                javaParameters.getMainJar()
+                        .getResourceName())
                 .getResourceAbsolutePathInLocal();
+        String mainJarName = null;
+        try {
+            mainJarName = MainClassExtractor.getMainClassName(mainJarAbsolutePathInLocal);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
         StringBuilder builder = new StringBuilder();
         builder.append(getJavaCommandPath())
                 .append("java").append(" ")
                 .append(buildResourcePath()).append(" ")
-                .append("-jar").append(" ")
-                .append(mainJarAbsolutePathInLocal).append(" ")
+                .append(mainJarName).append(" ")

Review Comment:
   Updated



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [DSIP-27][Task Plugin] Some improvements of JAVA task plugin [dolphinscheduler]

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #16542:
URL: https://github.com/apache/dolphinscheduler/pull/16542#issuecomment-2430724723

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16542) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 New issues](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=16542&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=16542&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=16542&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=16542&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=16542&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16542)
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [DSIP-27][Task Plugin] Some improvements of JAVA task plugin [dolphinscheduler]

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #16542:
URL: https://github.com/apache/dolphinscheduler/pull/16542#issuecomment-2430725657

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16542) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 New issues](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=16542&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=16542&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=16542&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=16542&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=16542&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16542)
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [DSIP-27][Task Plugin] Some improvements of JAVA task plugin [dolphinscheduler]

Posted by "ailiujiarui (via GitHub)" <gi...@apache.org>.
ailiujiarui commented on code in PR #16542:
URL: https://github.com/apache/dolphinscheduler/pull/16542#discussion_r1824621098


##########
dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/resources/fat.jar:
##########


Review Comment:
   I implemented a strategy where the source code is compiled and packaged into a JAR file during the application's runtime. This approach eliminates the necessity of mounting files within the image.
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [DSIP-27][Task Plugin] Some improvements of JAVA task plugin [dolphinscheduler]

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #16542:
URL: https://github.com/apache/dolphinscheduler/pull/16542#issuecomment-2434165551

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16542) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 New issues](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=16542&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=16542&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=16542&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=16542&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=16542&metric=new_duplicated_lines_density&view=list)  
     
   [See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16542)
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [DSIP-27][Task Plugin] Some improvements of JAVA task plugin [dolphinscheduler]

Posted by "ailiujiarui (via GitHub)" <gi...@apache.org>.
ailiujiarui commented on code in PR #16542:
URL: https://github.com/apache/dolphinscheduler/pull/16542#discussion_r1814071222


##########
dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/cases/WorkflowJavaTaskE2ETest.java:
##########
@@ -163,17 +183,112 @@ void testRunWorkflow() {
                 .run(workflow)
                 .submit();
 
-        Awaitility.await().untilAsserted(() -> {
-            browser.navigate().refresh();
+        Awaitility.await()
+                .atMost(Duration.ofMinutes(5))
+                .untilAsserted(() -> {
+                    browser.navigate().refresh();
+
+                    final WorkflowInstanceTab.Row row = projectPage
+                            .goToTab(WorkflowInstanceTab.class)
+                            .instances()
+                            .iterator()
+                            .next();
 
-            final WorkflowInstanceTab.Row row = projectPage
-                    .goToTab(WorkflowInstanceTab.class)
-                    .instances()
-                    .iterator()
-                    .next();
+                    assertThat(row.isSuccess()).isTrue();
+                    assertThat(row.executionTime()).isEqualTo(1);
+                });
 
-            assertThat(row.isSuccess()).isTrue();
-            assertThat(row.executionTime()).isEqualTo(1);
-        });
     }
+
+    @Test
+    @Order(60)
+    void testCreateNormalWorkflow() {
+        FileManagePage file = new NavBarPage(browser)
+                .goToNav(ResourcePage.class)
+                .goToTab(FileManagePage.class)
+                .uploadFile(filePath + "/normal2.jar");
+
+        WebDriverWait wait = WebDriverWaitFactory.createWebDriverWait(browser);
+
+        wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//span[text()='normal2.jar']")));
+
+        file.uploadFile(filePath + "/normal1.jar");
+
+        wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//span[text()='normal1.jar']")));
+
+        ProjectPage projectPage = new NavBarPage(browser)
+                .goToNav(ProjectPage.class);
+
+        wait.until(ExpectedConditions.visibilityOfAllElements(projectPage.projectList()));
+
+        WorkflowDefinitionTab workflowDefinitionPage = projectPage
+                .goTo(project)
+                .goToTab(WorkflowDefinitionTab.class);
+
+        workflowDefinitionPage.createWorkflow()
+                .<JavaTaskForm>addTask(WorkflowForm.TaskType.JAVA)
+                .selectRunType("NORMAL_JAR")
+                .selectMainPackage("normal1.jar")
+                .selectResource("normal1.jar")
+                .selectResource("normal2.jar")
+                .name("test-2")
+                .selectEnv(environmentName)
+                .submit()
+                .submit()
+                .name(workflow2)
+                .submit();
+
+        Awaitility.await().untilAsserted(() -> assertThat(workflowDefinitionPage.workflowList())
+                .as("Workflow list should contain newly-created workflow")
+                .anyMatch(it -> it.getText().contains(workflow2)));
+
+        workflowDefinitionPage.publish(workflow2);
+    }
+
+    @Test
+    @Order(90)
+    void testRunNormalWorkflow() {
+        final ProjectDetailPage projectPage =
+                new ProjectPage(browser)
+                        .goToNav(ProjectPage.class)
+                        .goTo(project);
+
+        projectPage
+                .goToTab(WorkflowInstanceTab.class)
+                .deleteAll();
+        projectPage
+                .goToTab(WorkflowDefinitionTab.class)
+                .run(workflow2)
+                .submit();
+
+        Awaitility.await()
+                .atMost(Duration.ofMinutes(5))
+                .untilAsserted(() -> {
+                    browser.navigate().refresh();
+
+                    final WorkflowInstanceTab.Row row = projectPage
+                            .goToTab(WorkflowInstanceTab.class)
+                            .instances()
+                            .iterator()
+                            .next();
+
+                    assertThat(row.isSuccess()).isTrue();
+                    assertThat(row.executionTime()).isEqualTo(1);
+                });
+        /*
+         * Awaitility.await() .atMost(Duration.ofMinutes(5)) .untilAsserted(() -> { browser.navigate().refresh();
+         * 
+         * final WorkflowInstanceTab workflowInstanceTab = projectPage.goToTab(WorkflowInstanceTab.class);
+         * 
+         * List<WorkflowInstanceTab.Row> instances = workflowInstanceTab.instances();
+         * 
+         * if (instances.isEmpty()) { throw new RuntimeException("No workflow instances found"); }
+         * 
+         * WorkflowInstanceTab.Row row = instances.get(0);
+         * 
+         * assertThat(row.isSuccess()).isTrue(); assertThat(row.executionTime()).isEqualTo(1); });
+         */

Review Comment:
   The comment has been removed



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [DSIP-27][Task Plugin] Some improvements of JAVA task plugin [dolphinscheduler]

Posted by "ailiujiarui (via GitHub)" <gi...@apache.org>.
ailiujiarui commented on code in PR #16542:
URL: https://github.com/apache/dolphinscheduler/pull/16542#discussion_r1814074886


##########
dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/project/workflow/task/JavaTaskForm.java:
##########
@@ -17,27 +17,111 @@
 
 package org.apache.dolphinscheduler.e2e.pages.project.workflow.task;
 
-import org.apache.dolphinscheduler.e2e.pages.common.CodeEditor;
 import org.apache.dolphinscheduler.e2e.pages.project.workflow.WorkflowForm;
 
+import java.time.Duration;
+import java.util.List;
+
+import lombok.Getter;
+
+import org.openqa.selenium.By;
+import org.openqa.selenium.JavascriptExecutor;
+import org.openqa.selenium.Keys;
 import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.support.FindBy;
+import org.openqa.selenium.support.PageFactory;
+import org.openqa.selenium.support.ui.ExpectedConditions;
+import org.openqa.selenium.support.ui.WebDriverWait;
 
+@Getter
 public class JavaTaskForm extends TaskNodeForm {
 
-    private CodeEditor codeEditor;
-
     private WebDriver driver;
 
+    @FindBy(xpath = "//label[span[text()='Run Type']]/following-sibling::div//div[contains(@class, 'n-base-selection')]")
+    private WebElement selectRunType;
+
+    @FindBy(xpath = "//label[span[text()='Main Package']]/following-sibling::div//div[contains(@class, 'n-base-selection-label')]")
+    private WebElement selectMainPackage;
+
+    @FindBy(xpath = "//div[@class='n-form-item-blank']//div[contains(@class, 'n-base-selection--multiple')]//div[contains(@class, 'n-base-selection-tags') and @tabindex='0']")
+    private WebElement selectResource;
+
     public JavaTaskForm(WorkflowForm parent) {
         super(parent);
 
-        this.codeEditor = new CodeEditor(parent.driver());
-
         this.driver = parent.driver();
+
+        PageFactory.initElements(driver, this);
     }
 
-    public JavaTaskForm script(String script) {
-        codeEditor.content(script);
+    public TaskNodeForm selectResource(String resourceName) {
+        WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(60));

Review Comment:
   The code has been modified



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [DSIP-27][Task Plugin] Some improvements of JAVA task plugin [dolphinscheduler]

Posted by "ailiujiarui (via GitHub)" <gi...@apache.org>.
ailiujiarui commented on code in PR #16542:
URL: https://github.com/apache/dolphinscheduler/pull/16542#discussion_r1814073238


##########
dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/pages/project/workflow/task/JavaTaskForm.java:
##########
@@ -17,27 +17,111 @@
 
 package org.apache.dolphinscheduler.e2e.pages.project.workflow.task;
 
-import org.apache.dolphinscheduler.e2e.pages.common.CodeEditor;
 import org.apache.dolphinscheduler.e2e.pages.project.workflow.WorkflowForm;
 
+import java.time.Duration;
+import java.util.List;
+
+import lombok.Getter;
+
+import org.openqa.selenium.By;
+import org.openqa.selenium.JavascriptExecutor;
+import org.openqa.selenium.Keys;
 import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.support.FindBy;
+import org.openqa.selenium.support.PageFactory;
+import org.openqa.selenium.support.ui.ExpectedConditions;
+import org.openqa.selenium.support.ui.WebDriverWait;
 
+@Getter
 public class JavaTaskForm extends TaskNodeForm {
 
-    private CodeEditor codeEditor;
-
     private WebDriver driver;
 
+    @FindBy(xpath = "//label[span[text()='Run Type']]/following-sibling::div//div[contains(@class, 'n-base-selection')]")

Review Comment:
   Change to using @FindBys with class name.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [DSIP-27][Task Plugin] Some improvements of JAVA task plugin [dolphinscheduler]

Posted by "SbloodyS (via GitHub)" <gi...@apache.org>.
SbloodyS commented on code in PR #16542:
URL: https://github.com/apache/dolphinscheduler/pull/16542#discussion_r1839145272


##########
docs/docs/zh/guide/task/java.md:
##########
@@ -22,25 +22,38 @@
 | 模块路径     | 开启使用JAVA9+的模块化特性,把所有资源放入--module-path中,要求您的worker中的JDK版本支持模块化 |
 | 主程序参数    | 作为普通Java程序main方法入口参数                                          |
 | 虚拟机参数    | 配置启动虚拟机参数                                                     |
-| 脚本       | 若使用JAVA运行类型则需要编写JAVA代码。代码中必须存在public类,不用写package语句            |
+| 主程序包     | 选择要运行程序的主程序包                                                  |
 | 资源       | 可以是外部JAR包也可以是其他资源文件,它们都会被加入到类路径或模块路径中,您可以在自己的JAVA脚本中轻松获取      |
 
 ## 任务样例
 
-java任务类型有两种运行模式,这里以JAVA模式为例进行演示。
+java任务类型有两种运行模式,这里进行分别进行演示。
 
 主要配置参数如下:
 
 - 运行类型
 - 模块路径
 - 主程序参数
 - 虚拟机参数
-- 脚本文件
+- 主程序包
+- 资源文件
 
-![java_task](../../../../img/tasks/demo/java_task02.png)
+如图所示
+
+- FAT_JAR类型
+
+![java_task](../../../../img/tasks/demo/java_fat.png)
+
+因为fat类型的jar,依赖和代码都在同一个jar中,则只需选择这一个jar即可
+
+- NORMAL_JAR类型
+
+![java_task](../../../../img/tasks/demo/java_normal.png)
+
+normal1.jar是程序运行的入口,normal2.jar是所需的依赖,需要用主程序包指定程序的入口,并且在资源文件中选择所有依赖和程序入口jar文件,才能正确运行
 
 ## 注意事项
 
-使用JAVA运行类型时代码中必须存在public类,可以不写package语句
+使用这两种运行类型,都必须选择主程序包和对应的资源文件,否则任务会直接失败。因为主程序包是选择程序从哪里开始运行,资源文件选择文件之后,运行程序时,资源文件才能被加入其中

Review Comment:
   ```suggestion
   1. 使用`FAT_JAR`运行类型必须选择主程序包,使用和对应的资源文件,否则任务会直接失败
   2. 使用`NORMAL_JAR`运行类型必须选择主程序包和对应的资源文件,否则任务会直接失败。主程序包决定程序从哪里开始运行,选择资源文件之后,运行程序时,资源文件会以`-cp`的方式进行调用
   ```



##########
dolphinscheduler-task-plugin/dolphinscheduler-task-java/src/main/java/org/apache/dolphinscheduler/plugin/task/java/MainClassExtractor.java:
##########
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.dolphinscheduler.plugin.task.java;
+
+import java.io.File;
+import java.util.jar.JarFile;
+import java.util.jar.Manifest;
+
+import lombok.extern.slf4j.Slf4j;
+
+@Slf4j
+public class MainClassExtractor {
+
+    private MainClassExtractor() {
+    }
+    public static String getMainClassName(String jarFilePath) {
+        String mainClassName = null;
+        try (JarFile jarFile = new JarFile(new File(jarFilePath))) {
+
+            Manifest manifest = jarFile.getManifest();
+            mainClassName = manifest.getMainAttributes().getValue("Main-Class");
+
+        } catch (Exception e) {
+            log.error("get mainJarName failed:", e);

Review Comment:
   We should stop the task thread and exit here if meets exception.



##########
docs/docs/zh/guide/task/java.md:
##########
@@ -22,25 +22,38 @@
 | 模块路径     | 开启使用JAVA9+的模块化特性,把所有资源放入--module-path中,要求您的worker中的JDK版本支持模块化 |
 | 主程序参数    | 作为普通Java程序main方法入口参数                                          |
 | 虚拟机参数    | 配置启动虚拟机参数                                                     |
-| 脚本       | 若使用JAVA运行类型则需要编写JAVA代码。代码中必须存在public类,不用写package语句            |
+| 主程序包     | 选择要运行程序的主程序包                                                  |
 | 资源       | 可以是外部JAR包也可以是其他资源文件,它们都会被加入到类路径或模块路径中,您可以在自己的JAVA脚本中轻松获取      |
 
 ## 任务样例
 
-java任务类型有两种运行模式,这里以JAVA模式为例进行演示。
+java任务类型有两种运行模式,这里进行分别进行演示。
 
 主要配置参数如下:
 
 - 运行类型
 - 模块路径
 - 主程序参数
 - 虚拟机参数
-- 脚本文件
+- 主程序包
+- 资源文件
 
-![java_task](../../../../img/tasks/demo/java_task02.png)
+如图所示
+
+- FAT_JAR类型
+
+![java_task](../../../../img/tasks/demo/java_fat.png)
+
+因为fat类型的jar,依赖和代码都在同一个jar中,则只需选择这一个jar即可

Review Comment:
   ```suggestion
   `FAT_JAR`即`uber-jar`,依赖和代码都在同一个`jar`中,只需选择这一个`jar`即可
   ```



##########
docs/docs/zh/guide/task/java.md:
##########
@@ -2,7 +2,7 @@
 
 ## 综述
 
-该节点用于执行 java 类型的任务,支持使用单文件和jar包作为程序入口。
+该节点用于执行 java 类型的任务,支持使用fat类型和normal类型的jar包作为程序入口。

Review Comment:
   Same as english.



##########
docs/docs/zh/guide/task/java.md:
##########
@@ -22,25 +22,38 @@
 | 模块路径     | 开启使用JAVA9+的模块化特性,把所有资源放入--module-path中,要求您的worker中的JDK版本支持模块化 |
 | 主程序参数    | 作为普通Java程序main方法入口参数                                          |
 | 虚拟机参数    | 配置启动虚拟机参数                                                     |
-| 脚本       | 若使用JAVA运行类型则需要编写JAVA代码。代码中必须存在public类,不用写package语句            |
+| 主程序包     | 选择要运行程序的主程序包                                                  |
 | 资源       | 可以是外部JAR包也可以是其他资源文件,它们都会被加入到类路径或模块路径中,您可以在自己的JAVA脚本中轻松获取      |
 
 ## 任务样例
 
-java任务类型有两种运行模式,这里以JAVA模式为例进行演示。
+java任务类型有两种运行模式,这里进行分别进行演示。
 
 主要配置参数如下:
 
 - 运行类型
 - 模块路径
 - 主程序参数
 - 虚拟机参数
-- 脚本文件
+- 主程序包
+- 资源文件
 
-![java_task](../../../../img/tasks/demo/java_task02.png)
+如图所示
+
+- FAT_JAR类型
+
+![java_task](../../../../img/tasks/demo/java_fat.png)
+
+因为fat类型的jar,依赖和代码都在同一个jar中,则只需选择这一个jar即可
+
+- NORMAL_JAR类型
+
+![java_task](../../../../img/tasks/demo/java_normal.png)
+
+normal1.jar是程序运行的入口,normal2.jar是所需的依赖,需要用主程序包指定程序的入口,并且在资源文件中选择所有依赖和程序入口jar文件,才能正确运行

Review Comment:
   Same as english.



##########
docs/docs/zh/guide/task/java.md:
##########
@@ -22,25 +22,38 @@
 | 模块路径     | 开启使用JAVA9+的模块化特性,把所有资源放入--module-path中,要求您的worker中的JDK版本支持模块化 |
 | 主程序参数    | 作为普通Java程序main方法入口参数                                          |
 | 虚拟机参数    | 配置启动虚拟机参数                                                     |
-| 脚本       | 若使用JAVA运行类型则需要编写JAVA代码。代码中必须存在public类,不用写package语句            |
+| 主程序包     | 选择要运行程序的主程序包                                                  |
 | 资源       | 可以是外部JAR包也可以是其他资源文件,它们都会被加入到类路径或模块路径中,您可以在自己的JAVA脚本中轻松获取      |
 
 ## 任务样例
 
-java任务类型有两种运行模式,这里以JAVA模式为例进行演示。
+java任务类型有两种运行模式,这里进行分别进行演示。
 
 主要配置参数如下:
 
 - 运行类型
 - 模块路径
 - 主程序参数
 - 虚拟机参数
-- 脚本文件
+- 主程序包
+- 资源文件
 
-![java_task](../../../../img/tasks/demo/java_task02.png)
+如图所示
+
+- FAT_JAR类型
+
+![java_task](../../../../img/tasks/demo/java_fat.png)
+
+因为fat类型的jar,依赖和代码都在同一个jar中,则只需选择这一个jar即可
+
+- NORMAL_JAR类型
+
+![java_task](../../../../img/tasks/demo/java_normal.png)
+
+normal1.jar是程序运行的入口,normal2.jar是所需的依赖,需要用主程序包指定程序的入口,并且在资源文件中选择所有依赖和程序入口jar文件,才能正确运行

Review Comment:
   ```suggestion
   `normal1.jar`是程序运行的入口,`normal2.jar`是所需的依赖,需要用主程序包指定程序的入口,并且在资源文件中选择所有依赖和程序入口的`jar`文件,才能正确运行
   ```



##########
docs/docs/zh/guide/task/java.md:
##########
@@ -2,7 +2,7 @@
 
 ## 综述
 
-该节点用于执行 java 类型的任务,支持使用单文件和jar包作为程序入口。
+该节点用于执行 java 类型的任务,支持使用fat类型和normal类型的jar包作为程序入口。

Review Comment:
   ```suggestion
   该节点用于执行`Java`类型的任务,支持使用`FAT_JAR`类型和`NORMAL_JAR`类型的`jar`包运行。
   ```



##########
docs/docs/zh/guide/task/java.md:
##########
@@ -22,25 +22,38 @@
 | 模块路径     | 开启使用JAVA9+的模块化特性,把所有资源放入--module-path中,要求您的worker中的JDK版本支持模块化 |
 | 主程序参数    | 作为普通Java程序main方法入口参数                                          |
 | 虚拟机参数    | 配置启动虚拟机参数                                                     |
-| 脚本       | 若使用JAVA运行类型则需要编写JAVA代码。代码中必须存在public类,不用写package语句            |
+| 主程序包     | 选择要运行程序的主程序包                                                  |
 | 资源       | 可以是外部JAR包也可以是其他资源文件,它们都会被加入到类路径或模块路径中,您可以在自己的JAVA脚本中轻松获取      |
 
 ## 任务样例
 
-java任务类型有两种运行模式,这里以JAVA模式为例进行演示。
+java任务类型有两种运行模式,这里进行分别进行演示。
 
 主要配置参数如下:
 
 - 运行类型
 - 模块路径
 - 主程序参数
 - 虚拟机参数
-- 脚本文件
+- 主程序包
+- 资源文件
 
-![java_task](../../../../img/tasks/demo/java_task02.png)
+如图所示
+
+- FAT_JAR类型
+
+![java_task](../../../../img/tasks/demo/java_fat.png)
+
+因为fat类型的jar,依赖和代码都在同一个jar中,则只需选择这一个jar即可

Review Comment:
   Same as english.



##########
docs/docs/zh/guide/task/java.md:
##########
@@ -22,25 +22,38 @@
 | 模块路径     | 开启使用JAVA9+的模块化特性,把所有资源放入--module-path中,要求您的worker中的JDK版本支持模块化 |
 | 主程序参数    | 作为普通Java程序main方法入口参数                                          |
 | 虚拟机参数    | 配置启动虚拟机参数                                                     |
-| 脚本       | 若使用JAVA运行类型则需要编写JAVA代码。代码中必须存在public类,不用写package语句            |
+| 主程序包     | 选择要运行程序的主程序包                                                  |
 | 资源       | 可以是外部JAR包也可以是其他资源文件,它们都会被加入到类路径或模块路径中,您可以在自己的JAVA脚本中轻松获取      |
 
 ## 任务样例
 
-java任务类型有两种运行模式,这里以JAVA模式为例进行演示。
+java任务类型有两种运行模式,这里进行分别进行演示。
 
 主要配置参数如下:
 
 - 运行类型
 - 模块路径
 - 主程序参数
 - 虚拟机参数
-- 脚本文件
+- 主程序包
+- 资源文件
 
-![java_task](../../../../img/tasks/demo/java_task02.png)
+如图所示
+
+- FAT_JAR类型
+
+![java_task](../../../../img/tasks/demo/java_fat.png)
+
+因为fat类型的jar,依赖和代码都在同一个jar中,则只需选择这一个jar即可
+
+- NORMAL_JAR类型
+
+![java_task](../../../../img/tasks/demo/java_normal.png)
+
+normal1.jar是程序运行的入口,normal2.jar是所需的依赖,需要用主程序包指定程序的入口,并且在资源文件中选择所有依赖和程序入口jar文件,才能正确运行
 
 ## 注意事项
 
-使用JAVA运行类型时代码中必须存在public类,可以不写package语句
+使用这两种运行类型,都必须选择主程序包和对应的资源文件,否则任务会直接失败。因为主程序包是选择程序从哪里开始运行,资源文件选择文件之后,运行程序时,资源文件才能被加入其中

Review Comment:
   Same as english.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [DSIP-27][Task Plugin] Some improvements of JAVA task plugin [dolphinscheduler]

Posted by "ailiujiarui (via GitHub)" <gi...@apache.org>.
ailiujiarui commented on code in PR #16542:
URL: https://github.com/apache/dolphinscheduler/pull/16542#discussion_r1839842572


##########
docs/docs/zh/guide/task/java.md:
##########
@@ -2,7 +2,7 @@
 
 ## 综述
 
-该节点用于执行 java 类型的任务,支持使用单文件和jar包作为程序入口。
+该节点用于执行 java 类型的任务,支持使用fat类型和normal类型的jar包作为程序入口。

Review Comment:
   The docs have updated



##########
docs/docs/zh/guide/task/java.md:
##########
@@ -22,25 +22,38 @@
 | 模块路径     | 开启使用JAVA9+的模块化特性,把所有资源放入--module-path中,要求您的worker中的JDK版本支持模块化 |
 | 主程序参数    | 作为普通Java程序main方法入口参数                                          |
 | 虚拟机参数    | 配置启动虚拟机参数                                                     |
-| 脚本       | 若使用JAVA运行类型则需要编写JAVA代码。代码中必须存在public类,不用写package语句            |
+| 主程序包     | 选择要运行程序的主程序包                                                  |
 | 资源       | 可以是外部JAR包也可以是其他资源文件,它们都会被加入到类路径或模块路径中,您可以在自己的JAVA脚本中轻松获取      |
 
 ## 任务样例
 
-java任务类型有两种运行模式,这里以JAVA模式为例进行演示。
+java任务类型有两种运行模式,这里进行分别进行演示。
 
 主要配置参数如下:
 
 - 运行类型
 - 模块路径
 - 主程序参数
 - 虚拟机参数
-- 脚本文件
+- 主程序包
+- 资源文件
 
-![java_task](../../../../img/tasks/demo/java_task02.png)
+如图所示
+
+- FAT_JAR类型
+
+![java_task](../../../../img/tasks/demo/java_fat.png)
+
+因为fat类型的jar,依赖和代码都在同一个jar中,则只需选择这一个jar即可

Review Comment:
   The docs have updated



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [DSIP-27][Task Plugin] Some improvements of JAVA task plugin [dolphinscheduler]

Posted by "sonarcloud[bot] (via GitHub)" <gi...@apache.org>.
sonarcloud[bot] commented on PR #16542:
URL: https://github.com/apache/dolphinscheduler/pull/16542#issuecomment-2408808065

   ## [![Quality Gate Failed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-failed-20px.png 'Quality Gate Failed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16542) **Quality Gate failed**  
   Failed conditions  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/failed-16px.png '') [E Reliability Rating on New Code](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16542) (required ≥ A)  
     
   [See analysis details on SonarCloud](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=16542)
   
   ##   
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/light_bulb-16px.png '') Catch issues before they fail your Quality Gate with our IDE extension ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/sonarlint-16px.png '') [SonarLint](https://www.sonarsource.com/products/sonarlint/features/connected-mode/?referrer=pull-request)
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [DSIP-27][Task Plugin] Some improvements of JAVA task plugin [dolphinscheduler]

Posted by "SbloodyS (via GitHub)" <gi...@apache.org>.
SbloodyS commented on PR #16542:
URL: https://github.com/apache/dolphinscheduler/pull/16542#issuecomment-2489930422

   > I've encountered a similar issue before as well. What worked for me was rerunning the entire test from the beginning, and that allowed it to pass successfully.
   
   You should check the error message of `java.lang.RuntimeException: No such package: normal1.jar
   	at org.apache.dolphinscheduler.e2e.cases.WorkflowJavaTaskE2ETest.testCreateNormalJarWorkflow(WorkflowJavaTaskE2ETest.java:341)`


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [DSIP-27][Task Plugin] Some improvements of JAVA task plugin [dolphinscheduler]

Posted by "ruanwenjun (via GitHub)" <gi...@apache.org>.
ruanwenjun commented on PR #16542:
URL: https://github.com/apache/dolphinscheduler/pull/16542#issuecomment-2526810233

   Merged into dev, will be released at 3.3.0, thanks for your PR, helps a lot. @ailiujiarui 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [DSIP-27][Task Plugin] Some improvements of JAVA task plugin [dolphinscheduler]

Posted by "ruanwenjun (via GitHub)" <gi...@apache.org>.
ruanwenjun merged PR #16542:
URL: https://github.com/apache/dolphinscheduler/pull/16542


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org