You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dolphinscheduler.apache.org by GitBox <gi...@apache.org> on 2022/06/30 04:06:50 UTC

[GitHub] [dolphinscheduler] 106umao opened a new pull request, #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

106umao opened a new pull request, #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689

   <!--Thanks very much for contributing to Apache DolphinScheduler. Please review https://dolphinscheduler.apache.org/en-us/community/development/pull-request.html before opening a pull request.-->
   
   This feature link to issue #10683 
   
   ## Purpose of the pull request
   
   <!--(For example: This pull request adds checkstyle plugin).-->
   
   ## Brief change log
   
   <!--*(for example:)*
     - *Add maven-checkstyle-plugin to root pom.xml*
   -->
   ## 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.* -->
   


-- 
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


[GitHub] [dolphinscheduler] Amy0104 commented on a diff in pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
Amy0104 commented on code in PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#discussion_r914440124


##########
dolphinscheduler-ui/src/locales/zh_CN/project.ts:
##########
@@ -284,6 +284,10 @@ export default {
     online: '已上线'
   },
   node: {
+    is_module_path: '模块路劲',
+    run_type: '运行类型',
+    jvm_args: '虚拟机参数',
+    jvm_args_tips: '请输入虚拟机参数',

Review Comment:
   It is better to keep these keys the same position as en_US.



##########
dolphinscheduler-ui/src/views/projects/task/components/node/fields/use-java-task-main-jar.ts:
##########
@@ -0,0 +1,80 @@
+/*
+ * 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.
+ */
+import { computed, ref, onMounted, watch } from 'vue'
+import { useI18n } from 'vue-i18n'
+import { queryResourceByProgramType } from '@/service/modules/resources'
+import { useTaskNodeStore } from '@/store/project/task-node'
+import utils from '@/utils'
+import type { IJsonItem, ProgramType, IMainJar } from '../types'
+
+export function useJavaTaskMainJar(model: { [field: string]: any }): IJsonItem {
+  const { t } = useI18n()
+  const mainJarOptions = ref([] as IMainJar[])
+  const taskStore = useTaskNodeStore()
+
+  const mainJarSpan = computed(() => (model.runType === 'JAVA' ? 0 : 24))
+  const getMainJars = async (programType: ProgramType) => {
+    const storeMainJar = taskStore.getMainJar(programType)
+    if (storeMainJar) {
+      mainJarOptions.value = storeMainJar
+      return
+    }
+    const res = await queryResourceByProgramType({
+      type: 'FILE',
+      programType
+    })
+    utils.removeUselessChildren(res)
+    mainJarOptions.value = res || []
+    taskStore.updateMainJar(programType, res)
+  }
+
+  onMounted(() => {
+    getMainJars(model.programType)
+  })
+
+  watch(
+    () => model.programType,
+    (value) => {
+        getMainJars(value)
+    }
+  )
+
+  return {
+    type: 'tree-select',
+    field: 'mainJar',
+    name: t('project.node.main_package'),
+    span: mainJarSpan,
+    props: {
+      cascade: true,
+      showPath: true,
+      checkStrategy: 'child',
+      placeholder: t('project.node.main_package_tips'),
+      keyField: 'id',
+      labelField: 'fullName'
+    },
+    validate: {
+      trigger: ['input', 'blur'],
+      required: true,
+      validator(validate: any, value: string) {
+        if (!value) {
+          return new Error(t('project.node.main_package_tips'))
+        }
+      }
+    },
+    options: mainJarOptions
+  }
+}

Review Comment:
   It seems that this hook is not used at all.



##########
dolphinscheduler-ui/src/views/projects/task/components/node/format-data.ts:
##########
@@ -35,6 +35,19 @@ export function formatParams(data: INodeData): {
   if (data.taskType === 'SUB_PROCESS') {
     taskParams.processDefinitionCode = data.processDefinitionCode
   }
+
+  if(data.taskType === 'JAVA'){
+    taskParams.runType = data.runType
+    taskParams.mainArgs = data.mainArgs
+    taskParams.jvmArgs = data.jvmArgs
+    taskParams.isModulePath = data.isModulePath
+    if(data.runType === 'JAR'){
+      if (data.mainJar) {
+        taskParams.mainJar = { id: data.mainJar }
+      }
+    }

Review Comment:
   it is better to change the two conditions into one parallel condition.



##########
dolphinscheduler-ui/src/locales/en_US/project.ts:
##########
@@ -126,7 +126,6 @@ export default {
     switch_version: 'Switch To This Version',
     confirm_switch_version: 'Confirm Switch To This Version?',
     current_version: 'Current Version',
-    run_type: 'Run Type',

Review Comment:
   The 'run_type' can not be removed, because it is used in workflow instance column.



##########
dolphinscheduler-ui/src/views/projects/task/components/node/fields/use-java.ts:
##########
@@ -0,0 +1,98 @@
+/*
+ * 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.
+ */
+import { computed } from 'vue'
+import { useI18n } from 'vue-i18n'
+import { useCustomParams, useResources ,useMainJar} from '.'
+import type { IJsonItem } from '../types'
+
+export function useJava(model: { [field: string]: any }): IJsonItem[] {
+  const { t } = useI18n()
+  const rawScriptSpan = computed(() => (model.runType === 'JAR' ? 0 : 24))
+  return [
+    {
+        type: 'select',
+        field: 'runType',
+        span: 12,
+        name: t('project.node.run_type'),
+        options: RUN_TYPES,
+        props: {
+          'on-update:value': () => {
+            // if(model.runType=='JAR'){
+            //     model.rawScript=''
+            // }else{
+            //     model.mainJar = null
+            //     model.rawScript=''
+            // }
+          }

Review Comment:
   It is better to remove the comment code.



-- 
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


[GitHub] [dolphinscheduler] sonarcloud[bot] commented on pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
sonarcloud[bot] commented on PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#issuecomment-1199792696

   SonarCloud Quality Gate failed.&nbsp; &nbsp; [![Quality Gate failed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/failed-16px.png 'Quality Gate failed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=10689)
   
   [![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png 'Bug')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG)  
   [![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png 'Vulnerability')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY)  
   [![Security Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png 'Security Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT)  
   [![Code Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png 'Code Smell')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL) [15 Code Smells](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL)
   
   [![0.4%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/0-16px.png '0.4%')](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_coverage&view=list) [0.4% Coverage](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_coverage&view=list)  
   [![1.9%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3-16px.png '1.9%')](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_duplicated_lines_density&view=list) [1.9% Duplication](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_duplicated_lines_density&view=list)
   
   


-- 
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


[GitHub] [dolphinscheduler] 106umao commented on a diff in pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
106umao commented on code in PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#discussion_r945299758


##########
dolphinscheduler-task-plugin/dolphinscheduler-task-java/src/main/java/org/apache/dolphinscheduler/plugin/task/java/JavaConstants.java:
##########
@@ -0,0 +1,67 @@
+/*
+ * 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;
+
+public class JavaConstants {
+
+    private JavaConstants() {
+        throw new IllegalStateException("Utility class");
+    }
+
+    /**
+     * The constants used to get the Java installation directory
+     **/
+    public static final String JAVA_HOME_VAR = "${JAVA_HOME}";
+
+    /**
+     * this constant represents the use of the java command to run a task
+     **/
+    public static final String RUN_TYPE_JAVA = "JAVA";
+
+    /**
+     * this constant represents the use of the java -jar command to run a task
+     **/
+    public static final String RUN_TYPE_JAR = "JAR";
+
+    /**
+     * This constant is the Classpath or module path delimiter for different operating systems
+     **/
+    public static final String PATH_SEPARATOR = System.getProperty("path.separator");
+
+    /**
+     * This constant is the file delimiter for different operating systems
+     **/
+    public static final String FILE_SEPARATOR = System.getProperty("file.separator");

Review Comment:
   thx



-- 
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


[GitHub] [dolphinscheduler] SbloodyS commented on pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
SbloodyS commented on PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#issuecomment-1193273727

   > Hi @zhuangchong @SbloodyS @Amy0104 please help me restart CI failed
   
   Merging the latest dev code can effectively reduce the probability of E2E failure.


-- 
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


[GitHub] [dolphinscheduler] sonarcloud[bot] commented on pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
sonarcloud[bot] commented on PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#issuecomment-1240255656

   SonarCloud Quality Gate failed.&nbsp; &nbsp; [![Quality Gate failed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/failed-16px.png 'Quality Gate failed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=10689)
   
   [![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png 'Bug')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG)  
   [![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png 'Vulnerability')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY)  
   [![Security Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png 'Security Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT)  
   [![Code Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png 'Code Smell')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL) [8 Code Smells](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL)
   
   [![0.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/0-16px.png '0.0%')](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_coverage&view=list) [0.0% Coverage](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_coverage&view=list)  
   [![2.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3-16px.png '2.0%')](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_duplicated_lines_density&view=list) [2.0% Duplication](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_duplicated_lines_density&view=list)
   
   


-- 
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


[GitHub] [dolphinscheduler] 106umao commented on a diff in pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
106umao commented on code in PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#discussion_r915808693


##########
dolphinscheduler-ui/src/views/projects/task/components/node/format-data.ts:
##########
@@ -35,6 +35,19 @@ export function formatParams(data: INodeData): {
   if (data.taskType === 'SUB_PROCESS') {
     taskParams.processDefinitionCode = data.processDefinitionCode
   }
+
+  if(data.taskType === 'JAVA'){
+    taskParams.runType = data.runType
+    taskParams.mainArgs = data.mainArgs
+    taskParams.jvmArgs = data.jvmArgs
+    taskParams.isModulePath = data.isModulePath
+    if(data.runType === 'JAR'){
+      if (data.mainJar) {
+        taskParams.mainJar = { id: data.mainJar }
+      }
+    }

Review Comment:
   thx, it is done



-- 
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


[GitHub] [dolphinscheduler] 106umao commented on pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
106umao commented on PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#issuecomment-1197827236

   > Backend part overall LGTM, it would be better if we could have those exceptions covered in UTs.
   
   thx, have done


-- 
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


[GitHub] [dolphinscheduler] sonarcloud[bot] commented on pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
sonarcloud[bot] commented on PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#issuecomment-1171017332

   SonarCloud Quality Gate failed.&nbsp; &nbsp; [![Quality Gate failed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/failed-16px.png 'Quality Gate failed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=10689)
   
   [![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png 'Bug')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG)  
   [![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png 'Vulnerability')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY)  
   [![Security Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png 'Security Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT) [![E](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/E-16px.png 'E')](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT) [1 Security Hotspot](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT)  
   [![Code Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png 'Code Smell')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL) [24 Code Smells](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL)
   
   [![0.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/0-16px.png '0.0%')](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_coverage&view=list) [0.0% Coverage](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_coverage&view=list)  
   [![2.1%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3-16px.png '2.1%')](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_duplicated_lines_density&view=list) [2.1% Duplication](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_duplicated_lines_density&view=list)
   
   


-- 
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


[GitHub] [dolphinscheduler] 106umao commented on a diff in pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
106umao commented on code in PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#discussion_r915819085


##########
dolphinscheduler-ui/src/locales/zh_CN/project.ts:
##########
@@ -284,6 +284,10 @@ export default {
     online: '已上线'
   },
   node: {
+    is_module_path: '模块路劲',
+    run_type: '运行类型',
+    jvm_args: '虚拟机参数',
+    jvm_args_tips: '请输入虚拟机参数',

Review Comment:
   thx, it is done



-- 
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


[GitHub] [dolphinscheduler] 106umao commented on a diff in pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
106umao commented on code in PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#discussion_r915854424


##########
dolphinscheduler-ui/src/views/projects/task/components/node/fields/use-java-task-main-jar.ts:
##########
@@ -0,0 +1,80 @@
+/*
+ * 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.
+ */
+import { computed, ref, onMounted, watch } from 'vue'
+import { useI18n } from 'vue-i18n'
+import { queryResourceByProgramType } from '@/service/modules/resources'
+import { useTaskNodeStore } from '@/store/project/task-node'
+import utils from '@/utils'
+import type { IJsonItem, ProgramType, IMainJar } from '../types'
+
+export function useJavaTaskMainJar(model: { [field: string]: any }): IJsonItem {
+  const { t } = useI18n()
+  const mainJarOptions = ref([] as IMainJar[])
+  const taskStore = useTaskNodeStore()
+
+  const mainJarSpan = computed(() => (model.runType === 'JAVA' ? 0 : 24))
+  const getMainJars = async (programType: ProgramType) => {
+    const storeMainJar = taskStore.getMainJar(programType)
+    if (storeMainJar) {
+      mainJarOptions.value = storeMainJar
+      return
+    }
+    const res = await queryResourceByProgramType({
+      type: 'FILE',
+      programType
+    })
+    utils.removeUselessChildren(res)
+    mainJarOptions.value = res || []
+    taskStore.updateMainJar(programType, res)
+  }
+
+  onMounted(() => {
+    getMainJars(model.programType)
+  })
+
+  watch(
+    () => model.programType,
+    (value) => {
+        getMainJars(value)
+    }
+  )
+
+  return {
+    type: 'tree-select',
+    field: 'mainJar',
+    name: t('project.node.main_package'),
+    span: mainJarSpan,
+    props: {
+      cascade: true,
+      showPath: true,
+      checkStrategy: 'child',
+      placeholder: t('project.node.main_package_tips'),
+      keyField: 'id',
+      labelField: 'fullName'
+    },
+    validate: {
+      trigger: ['input', 'blur'],
+      required: true,
+      validator(validate: any, value: string) {
+        if (!value) {
+          return new Error(t('project.node.main_package_tips'))
+        }
+      }
+    },
+    options: mainJarOptions
+  }
+}

Review Comment:
   thx, changes have been made to make Java tasks better code-isolated from other tasks



-- 
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


[GitHub] [dolphinscheduler] zhuangchong commented on pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
zhuangchong commented on PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#issuecomment-1208764933

   @SbloodyS @zhongjiajie @EricGao888 Please help with code review, 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


[GitHub] [dolphinscheduler] zhuangchong commented on pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
zhuangchong commented on PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#issuecomment-1189692705

   @zhongjiajie @SbloodyS @Amy0104 Please help code review. 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


[GitHub] [dolphinscheduler] ruanwenjun commented on a diff in pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
ruanwenjun commented on code in PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#discussion_r965439038


##########
pom.xml:
##########
@@ -261,6 +262,12 @@
                 <version>${project.version}</version>
             </dependency>
 
+            <dependency>
+                <groupId>mysql</groupId>
+                <artifactId>mysql-connector-java</artifactId>
+                <version>${mysql.connector.version}</version>
+            </dependency>
+

Review Comment:
   Please remove this dependency, we should already define this in dolphinscheduler-bom



-- 
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


[GitHub] [dolphinscheduler] sonarcloud[bot] commented on pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
sonarcloud[bot] commented on PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#issuecomment-1239772608

   SonarCloud Quality Gate failed.&nbsp; &nbsp; [![Quality Gate failed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/failed-16px.png 'Quality Gate failed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=10689)
   
   [![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png 'Bug')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG)  
   [![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png 'Vulnerability')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY)  
   [![Security Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png 'Security Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT)  
   [![Code Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png 'Code Smell')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL) [8 Code Smells](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL)
   
   [![0.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/0-16px.png '0.0%')](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_coverage&view=list) [0.0% Coverage](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_coverage&view=list)  
   [![2.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3-16px.png '2.0%')](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_duplicated_lines_density&view=list) [2.0% Duplication](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_duplicated_lines_density&view=list)
   
   


-- 
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


[GitHub] [dolphinscheduler] sonarcloud[bot] commented on pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
sonarcloud[bot] commented on PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#issuecomment-1200898459

   SonarCloud Quality Gate failed.&nbsp; &nbsp; [![Quality Gate failed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/failed-16px.png 'Quality Gate failed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=10689)
   
   [![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png 'Bug')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG)  
   [![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png 'Vulnerability')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY)  
   [![Security Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png 'Security Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT)  
   [![Code Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png 'Code Smell')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL) [15 Code Smells](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL)
   
   [![0.4%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/0-16px.png '0.4%')](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_coverage&view=list) [0.4% Coverage](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_coverage&view=list)  
   [![1.9%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3-16px.png '1.9%')](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_duplicated_lines_density&view=list) [1.9% Duplication](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_duplicated_lines_density&view=list)
   
   


-- 
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


[GitHub] [dolphinscheduler] sonarcloud[bot] commented on pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
sonarcloud[bot] commented on PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#issuecomment-1172855349

   SonarCloud Quality Gate failed.&nbsp; &nbsp; [![Quality Gate failed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/failed-16px.png 'Quality Gate failed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=10689)
   
   [![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png 'Bug')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG)  
   [![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png 'Vulnerability')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY)  
   [![Security Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png 'Security Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT) [![E](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/E-16px.png 'E')](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT) [1 Security Hotspot](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT)  
   [![Code Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png 'Code Smell')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL) [24 Code Smells](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL)
   
   [![0.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/0-16px.png '0.0%')](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_coverage&view=list) [0.0% Coverage](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_coverage&view=list)  
   [![2.1%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3-16px.png '2.1%')](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_duplicated_lines_density&view=list) [2.1% Duplication](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_duplicated_lines_density&view=list)
   
   


-- 
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


[GitHub] [dolphinscheduler] sonarcloud[bot] commented on pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
sonarcloud[bot] commented on PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#issuecomment-1171459940

   SonarCloud Quality Gate failed.&nbsp; &nbsp; [![Quality Gate failed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/failed-16px.png 'Quality Gate failed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=10689)
   
   [![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png 'Bug')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG)  
   [![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png 'Vulnerability')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY)  
   [![Security Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png 'Security Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT) [![E](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/E-16px.png 'E')](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT) [1 Security Hotspot](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT)  
   [![Code Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png 'Code Smell')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL) [24 Code Smells](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL)
   
   [![0.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/0-16px.png '0.0%')](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_coverage&view=list) [0.0% Coverage](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_coverage&view=list)  
   [![2.1%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3-16px.png '2.1%')](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_duplicated_lines_density&view=list) [2.1% Duplication](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_duplicated_lines_density&view=list)
   
   


-- 
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


[GitHub] [dolphinscheduler] sonarcloud[bot] commented on pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
sonarcloud[bot] commented on PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#issuecomment-1170795767

   SonarCloud Quality Gate failed.&nbsp; &nbsp; [![Quality Gate failed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/failed-16px.png 'Quality Gate failed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=10689)
   
   [![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png 'Bug')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG) [![C](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/C-16px.png 'C')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG) [1 Bug](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG)  
   [![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png 'Vulnerability')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY)  
   [![Security Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png 'Security Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT) [![E](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/E-16px.png 'E')](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT) [1 Security Hotspot](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT)  
   [![Code Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png 'Code Smell')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL) [24 Code Smells](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL)
   
   [![0.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/0-16px.png '0.0%')](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_coverage&view=list) [0.0% Coverage](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_coverage&view=list)  
   [![2.1%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3-16px.png '2.1%')](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_duplicated_lines_density&view=list) [2.1% Duplication](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_duplicated_lines_density&view=list)
   
   


-- 
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


[GitHub] [dolphinscheduler] pinkhello commented on pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
pinkhello commented on PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#issuecomment-1182908795

   OWASP Dependency Check  CI 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


[GitHub] [dolphinscheduler] zhuangchong commented on pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
zhuangchong commented on PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#issuecomment-1212688664

   > somebody can help me look on the docs dead link error: [✖] https://dolphinscheduler.apache.org/python/index.html → Status: 404
   
   Please merge the latest dev branch code.


-- 
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


[GitHub] [dolphinscheduler] pinkhello commented on pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
pinkhello commented on PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#issuecomment-1182908602

   SonarCloud CI 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


[GitHub] [dolphinscheduler] sonarcloud[bot] commented on pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
sonarcloud[bot] commented on PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#issuecomment-1170935334

   SonarCloud Quality Gate failed.&nbsp; &nbsp; [![Quality Gate failed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/failed-16px.png 'Quality Gate failed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=10689)
   
   [![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png 'Bug')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG)  
   [![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png 'Vulnerability')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY)  
   [![Security Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png 'Security Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT) [![E](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/E-16px.png 'E')](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT) [1 Security Hotspot](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT)  
   [![Code Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png 'Code Smell')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL) [24 Code Smells](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL)
   
   [![0.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/0-16px.png '0.0%')](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_coverage&view=list) [0.0% Coverage](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_coverage&view=list)  
   [![2.1%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3-16px.png '2.1%')](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_duplicated_lines_density&view=list) [2.1% Duplication](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_duplicated_lines_density&view=list)
   
   


-- 
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


[GitHub] [dolphinscheduler] EricGao888 commented on a diff in pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
EricGao888 commented on code in PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#discussion_r925755338


##########
dolphinscheduler-task-plugin/dolphinscheduler-task-java/src/main/java/org/apache/dolphinscheduler/plugin/task/java/JavaParameters.java:
##########
@@ -0,0 +1,64 @@
+/*
+ * 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 org.apache.dolphinscheduler.plugin.task.api.model.ResourceInfo;
+import org.apache.dolphinscheduler.plugin.task.api.parameters.AbstractParameters;
+
+import java.util.List;
+
+import lombok.Data;
+
+@Data

Review Comment:
   > SonarCloud Quality Gate failed.    [![Quality Gate failed](https://camo.githubusercontent.com/4ea51c1f64ee3746f631653a02ab678ca6a3efb5f5cb474402faed2e3dcf90b5/68747470733a2f2f736f6e6172736f757263652e6769746875622e696f2f736f6e6172636c6f75642d6769746875622d7374617469632d7265736f75726365732f76322f636865636b732f5175616c6974794761746542616467652f6661696c65642d313670782e706e67)](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=10689)
   > 
   > [![Bug](https://camo.githubusercontent.com/4c6102327f5a954f9c8acaf2e2714183157a9e41717b371b2cd585cf25057310/68747470733a2f2f736f6e6172736f757263652e6769746875622e696f2f736f6e6172636c6f75642d6769746875622d7374617469632d7265736f75726365732f76322f636f6d6d6f6e2f6275672d313670782e706e67)](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG) [![A](https://camo.githubusercontent.com/1cba125a897d7fa47033a3b3b2be2bbee680d34d4f004a215564659b853fb201/68747470733a2f2f736f6e6172736f757263652e6769746875622e696f2f736f6e6172636c6f75642d6769746875622d7374617469632d7265736f75726365732f76322f636865636b732f526174696e6742616467652f412d313670782e706e67)](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG) [![Vulnerability](https://camo.githubusercontent.com/3ba1ee49636ffc3427e
 38649a9f8a65ee392f28e8a662fcf96ce24cefbb520e9/68747470733a2f2f736f6e6172736f757263652e6769746875622e696f2f736f6e6172636c6f75642d6769746875622d7374617469632d7265736f75726365732f76322f636f6d6d6f6e2f76756c6e65726162696c6974792d313670782e706e67)](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY) [![A](https://camo.githubusercontent.com/1cba125a897d7fa47033a3b3b2be2bbee680d34d4f004a215564659b853fb201/68747470733a2f2f736f6e6172736f757263652e6769746875622e696f2f736f6e6172636c6f75642d6769746875622d7374617469632d7265736f75726365732f76322f636865636b732f526174696e6742616467652f412d313670782e706e67)](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY) [![Security Hotspot](https://camo.githubusercontent.com/fb735cbe76f8d5e1679c7
 6ce83b740ceb1eaf62de4f7bf88623dc9953261aff7/68747470733a2f2f736f6e6172736f757263652e6769746875622e696f2f736f6e6172636c6f75642d6769746875622d7374617469632d7265736f75726365732f76322f636f6d6d6f6e2f73656375726974795f686f7473706f742d313670782e706e67)](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT) [![A](https://camo.githubusercontent.com/1cba125a897d7fa47033a3b3b2be2bbee680d34d4f004a215564659b853fb201/68747470733a2f2f736f6e6172736f757263652e6769746875622e696f2f736f6e6172636c6f75642d6769746875622d7374617469632d7265736f75726365732f76322f636865636b732f526174696e6742616467652f412d313670782e706e67)](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT) [![Code Smell](https://camo.g
 ithubusercontent.com/8fe18b2dfb6f7d4e44582f281b29f617eb5ae07c248d2002ca586e91da219212/68747470733a2f2f736f6e6172736f757263652e6769746875622e696f2f736f6e6172636c6f75642d6769746875622d7374617469632d7265736f75726365732f76322f636f6d6d6f6e2f636f64655f736d656c6c2d313670782e706e67)](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL) [![A](https://camo.githubusercontent.com/1cba125a897d7fa47033a3b3b2be2bbee680d34d4f004a215564659b853fb201/68747470733a2f2f736f6e6172736f757263652e6769746875622e696f2f736f6e6172636c6f75642d6769746875622d7374617469632d7265736f75726365732f76322f636865636b732f526174696e6742616467652f412d313670782e706e67)](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL) [14 Code Smells](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL)
   > 
   > [![0.4%](https://camo.githubusercontent.com/3f04cff3eeef8477afe696ae55c570cbb6ed02f16152497c14251828329a3e91/68747470733a2f2f736f6e6172736f757263652e6769746875622e696f2f736f6e6172636c6f75642d6769746875622d7374617469632d7265736f75726365732f76322f636865636b732f436f76657261676543686172742f302d313670782e706e67)](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_coverage&view=list) [0.4% Coverage](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_coverage&view=list) [![2.2%](https://camo.githubusercontent.com/8047c63e1f9ed03f63001e1eadce4676bade3e0f83ec690a9c625287796248a6/68747470733a2f2f736f6e6172736f757263652e6769746875622e696f2f736f6e6172636c6f75642d6769746875622d7374617469632d7265736f75726365732f76322f636865636b732f4475706c69636174696f6e732f332d313670782e706e67)](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_duplicated_lines_density&vie
 w=list) [2.2% Duplication](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_duplicated_lines_density&view=list)
   
   After replacing `@Data`, I think `sonar analysis` will no more fail for low test coverage.



-- 
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


[GitHub] [dolphinscheduler] sonarcloud[bot] commented on pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
sonarcloud[bot] commented on PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#issuecomment-1240999339

   SonarCloud Quality Gate failed.&nbsp; &nbsp; [![Quality Gate failed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/failed-16px.png 'Quality Gate failed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=10689)
   
   [![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png 'Bug')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG)  
   [![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png 'Vulnerability')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY)  
   [![Security Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png 'Security Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT)  
   [![Code Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png 'Code Smell')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL) [8 Code Smells](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL)
   
   [![0.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/0-16px.png '0.0%')](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_coverage&view=list) [0.0% Coverage](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_coverage&view=list)  
   [![2.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3-16px.png '2.0%')](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_duplicated_lines_density&view=list) [2.0% Duplication](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_duplicated_lines_density&view=list)
   
   


-- 
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


[GitHub] [dolphinscheduler] 106umao commented on a diff in pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
106umao commented on code in PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#discussion_r930794179


##########
docs/docs/en/guide/task/java.md:
##########
@@ -0,0 +1,48 @@
+# Overview
+
+This node is used to perform java-type tasks and supports the use of single files and jar packages as program entries.
+
+# Create Tasks
+
+- Click on project management-> Project name-> workflow definition, click on the“Create workflow” button, go to the DAG edit page:
+
+- Drag the toolbar's Java task node to the palette.
+
+# Task Parameters
+| **Parameter** | **Description** |
+| ------- | ---------- |
+|Node Name|the name of the set task. The node name in a workflow definition is unique.
+|Run Flag|indicates whether the node is scheduled properly and, if it is not needed, turns on the kill switch.
+|Description|describes the functionality of the node.
+|Task Priority|when the number of worker threads is insufficient, the worker is executed according to the priority from high to low. When the priority is the same, the worker is executed according to the first in, first out principle.
+|Worker Group|The machine whose task is assigned to the Worker group executes, and selecting Default will randomly select a Worker machine to execute.
+|Environment Name|configure the environment in which the task runs.
+|Number Of Failed Retries|number of resubmitted tasks that failed, supported drop-down and hand-fill.
+|Failed Retry Interval|the interval between tasks that fail and are resubmitted, supported by drop-down and hand-fill.
+|Delayed Execution Time|the amount of time a task is delayed, in units.
+|Timeout Alarm|Check timeout warning, timeout failure, when the task exceeds the“Timeout length”, send a warning message and the task execution fails.
+|Module Path|turn on the use of Java 9 + 's modularity feature, put all resources into-module-path, and require that the JDK version in your worker support modularity.
+|Main Parameter|as a normal Java program main method entry parameter.
+|Java VM Parameters|configure startup virtual machine parameters.
+|Script|you need to write Java code if you use the Java run type. The public class must exist in the code without writing a package statement.
+|Resources|these can be external JAR packages or other resource files that are added to the Classpath or module path and can be easily retrieved in your JAVA script.
+|Custom parameter|a user-defined parameter that is part of HTTP and replaces the contents of the script with the ${ variable } .
+|Pre Tasks|selecting a pre-task for the current task sets the selected pre-task upstream of the current task.

Review Comment:
   thanks,  have 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


[GitHub] [dolphinscheduler] sonarcloud[bot] commented on pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
sonarcloud[bot] commented on PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#issuecomment-1214348229

   SonarCloud Quality Gate failed.&nbsp; &nbsp; [![Quality Gate failed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/failed-16px.png 'Quality Gate failed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=10689)
   
   [![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png 'Bug')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG)  
   [![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png 'Vulnerability')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY)  
   [![Security Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png 'Security Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT)  
   [![Code Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png 'Code Smell')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL) [12 Code Smells](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL)
   
   [![0.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/0-16px.png '0.0%')](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_coverage&view=list) [0.0% Coverage](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_coverage&view=list)  
   [![1.9%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3-16px.png '1.9%')](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_duplicated_lines_density&view=list) [1.9% Duplication](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_duplicated_lines_density&view=list)
   
   


-- 
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


[GitHub] [dolphinscheduler] sonarcloud[bot] commented on pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
sonarcloud[bot] commented on PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#issuecomment-1196708923

   SonarCloud Quality Gate failed.&nbsp; &nbsp; [![Quality Gate failed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/failed-16px.png 'Quality Gate failed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=10689)
   
   [![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png 'Bug')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG)  
   [![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png 'Vulnerability')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY)  
   [![Security Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png 'Security Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT)  
   [![Code Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png 'Code Smell')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL) [14 Code Smells](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL)
   
   [![0.4%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/0-16px.png '0.4%')](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_coverage&view=list) [0.4% Coverage](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_coverage&view=list)  
   [![1.9%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3-16px.png '1.9%')](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_duplicated_lines_density&view=list) [1.9% Duplication](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_duplicated_lines_density&view=list)
   
   


-- 
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


[GitHub] [dolphinscheduler] EricGao888 commented on pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
EricGao888 commented on PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#issuecomment-1197625284

   > Backend part overall LGTM, it would be better if we could have those exceptions covered in UTs.
   
   @SbloodyS Could u please take another look when available? 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


[GitHub] [dolphinscheduler] sonarcloud[bot] commented on pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
sonarcloud[bot] commented on PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#issuecomment-1201017722

   SonarCloud Quality Gate failed.&nbsp; &nbsp; [![Quality Gate failed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/failed-16px.png 'Quality Gate failed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=10689)
   
   [![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png 'Bug')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG)  
   [![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png 'Vulnerability')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY)  
   [![Security Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png 'Security Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT)  
   [![Code Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png 'Code Smell')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL) [15 Code Smells](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL)
   
   [![0.4%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/0-16px.png '0.4%')](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_coverage&view=list) [0.4% Coverage](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_coverage&view=list)  
   [![1.9%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3-16px.png '1.9%')](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_duplicated_lines_density&view=list) [1.9% Duplication](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_duplicated_lines_density&view=list)
   
   


-- 
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


[GitHub] [dolphinscheduler] 106umao commented on a diff in pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
106umao commented on code in PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#discussion_r945302289


##########
dolphinscheduler-task-plugin/dolphinscheduler-task-java/src/main/java/org/apache/dolphinscheduler/plugin/task/java/JavaTask.java:
##########
@@ -0,0 +1,422 @@
+/*
+ * 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 static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.SINGLE_SLASH;
+import static org.apache.dolphinscheduler.plugin.task.java.JavaConstants.JAVA_HOME_VAR;
+import static org.apache.dolphinscheduler.plugin.task.java.JavaConstants.PUBLIC_CLASS_NAME_REGEX;
+
+
+import org.apache.dolphinscheduler.plugin.task.api.AbstractTaskExecutor;
+import org.apache.dolphinscheduler.plugin.task.api.ShellCommandExecutor;
+import org.apache.dolphinscheduler.plugin.task.api.TaskConstants;
+import org.apache.dolphinscheduler.plugin.task.api.TaskException;
+import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext;
+import org.apache.dolphinscheduler.plugin.task.api.model.Property;
+import org.apache.dolphinscheduler.plugin.task.api.model.ResourceInfo;
+import org.apache.dolphinscheduler.plugin.task.api.model.TaskResponse;
+import org.apache.dolphinscheduler.plugin.task.api.parameters.AbstractParameters;
+import org.apache.dolphinscheduler.plugin.task.api.parser.ParamUtils;
+import org.apache.dolphinscheduler.plugin.task.api.parser.ParameterUtils;
+import org.apache.dolphinscheduler.plugin.task.api.utils.MapUtils;
+import org.apache.dolphinscheduler.plugin.task.java.exception.JavaSourceFileExistException;
+import org.apache.dolphinscheduler.plugin.task.java.exception.PublicClassNotFoundException;
+import org.apache.dolphinscheduler.plugin.task.java.exception.RunTypeNotFoundException;
+import org.apache.dolphinscheduler.spi.utils.JSONUtils;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.lang3.SystemUtils;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import com.google.common.base.Preconditions;
+
+/**
+ * java task
+ */
+public class JavaTask extends AbstractTaskExecutor {
+
+    /**
+     * Contains various parameters for this task
+     */
+    private JavaParameters javaParameters;
+
+    /**
+     * To run shell commands
+     */
+    private ShellCommandExecutor shellCommandExecutor;
+
+    /**
+     * task execution context
+     */
+    private TaskExecutionContext taskRequest;
+
+    /**
+     * class name regex pattern
+     */
+    private static final Pattern classNamePattern = Pattern.compile(PUBLIC_CLASS_NAME_REGEX);
+
+    /**
+     * @description: Construct a Java task
+     * @param: [org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext]
+     * @return: JavaTask
+     **/
+    public JavaTask(TaskExecutionContext taskRequest) {
+        super(taskRequest);
+        this.taskRequest = taskRequest;
+        this.shellCommandExecutor = new ShellCommandExecutor(this::logHandle,
+                taskRequest,
+                logger);
+    }
+
+    /**
+     * @description: Initializes a Java task
+     * @param: []
+     * @return: void
+     **/
+    @Override
+    public void init() {
+        logger.info("java task params {}", taskRequest.getTaskParams());
+        javaParameters = JSONUtils.parseObject(taskRequest.getTaskParams(), JavaParameters.class);
+        if (javaParameters == null || !javaParameters.checkParameters()) {
+            throw new TaskException("java task params is not valid");
+        }
+        if (javaParameters.getRunType().equals(JavaConstants.RUN_TYPE_JAR)) {
+            setMainJarName();
+        }
+    }
+
+    /**
+     * @description: Gets the Java source file that was initially processed
+     * @param: []
+     * @return: java.lang.String
+     **/
+    @Override
+    public String getPreScript() {
+        String rawJavaScript = javaParameters.getRawScript().replaceAll("\\r\\n", "\n");
+        try {
+            rawJavaScript = convertJavaSourceCodePlaceholders(rawJavaScript);
+        } catch (StringIndexOutOfBoundsException e) {
+            logger.error("setShareVar field format error, raw java script : {}", rawJavaScript);
+        }
+        return rawJavaScript;
+    }
+
+    /**
+     * @description: Execute Java tasks
+     * @param: []
+     * @return: void
+     **/
+    @Override
+    public void handle() throws Exception {
+        try {
+            // Step 1: judge if is java or jar run type.
+            // Step 2 case1: The jar run type builds the command directly, adding resource to the java -jar class when building the command
+            // Step 2 case2: The java run type, first replace the custom parameters, then compile the code, and then build the command will add resource
+            // Step 3: To run the command
+            String command = null;
+            switch (javaParameters.getRunType()) {
+                case JavaConstants.RUN_TYPE_JAVA:
+                    command = buildJavaCommand();
+                    break;
+                case JavaConstants.RUN_TYPE_JAR:
+                    command = buildJarCommand();
+                    break;
+                default:
+                    throw new RunTypeNotFoundException("run type is required, but it is null now.");
+            }
+            Preconditions.checkNotNull(command, "command not be null.");
+            TaskResponse taskResponse = shellCommandExecutor.run(command);
+            logger.info("java task run result : {}", taskResponse);
+            setExitStatusCode(taskResponse.getExitStatusCode());
+            setAppIds(taskResponse.getAppIds());
+            setProcessId(taskResponse.getProcessId());
+            setVarPool(shellCommandExecutor.getVarPool());
+        } catch (InterruptedException e) {
+            logger.error("java task interrupted ", e);
+            setExitStatusCode(TaskConstants.EXIT_CODE_FAILURE);
+            Thread.currentThread().interrupt();
+        } catch (RunTypeNotFoundException e) {
+            logger.error(e.getMessage());
+            setExitStatusCode(TaskConstants.EXIT_CODE_FAILURE);
+            throw e;
+        } catch (Exception e) {
+            logger.error("java task failed ", e);
+            setExitStatusCode(TaskConstants.EXIT_CODE_FAILURE);
+            throw new TaskException("run java task error", e);
+        }
+    }
+
+    /**
+     * @description: Construct a shell command for the java Run mode
+     * @param: []
+     * @return: java.lang.String
+     **/
+    protected String buildJavaCommand() throws Exception {
+        String sourceCode = buildJavaSourceContent();
+        String className = compilerRawScript(sourceCode);
+        StringBuilder builder = new StringBuilder();
+        builder.append(getJavaCommandPath())
+                .append("java").append(" ")
+                .append(buildResourcePath())
+                .append(" ")
+                .append(className).append(" ")
+                .append(javaParameters.getMainArgs().trim()).append(" ")
+                .append(javaParameters.getJvmArgs().trim());
+        return builder.toString();
+    }
+
+    private void setMainJarName() {
+        ResourceInfo mainJar = javaParameters.getMainJar();
+        String resourceName = getResourceNameOfMainJar(mainJar);
+        mainJar.setRes(resourceName);
+        javaParameters.setMainJar(mainJar);
+    }
+
+    /**
+     * @description: Construct a shell command for the java -jar Run mode
+     * @param: []
+     * @return: java.lang.String
+     **/
+    protected String buildJarCommand() {
+        String fullName = javaParameters.getMainJar().getResourceName();
+        String mainJarName = fullName.substring(0, fullName.lastIndexOf('.'));
+        mainJarName = mainJarName.substring(mainJarName.lastIndexOf('.') + 1) + ".jar";
+        StringBuilder builder = new StringBuilder();
+        builder.append(getJavaCommandPath())
+                .append("java").append(" ")
+                .append(buildResourcePath()).append(" ")
+                .append("-jar").append(" ")
+                .append(taskRequest.getExecutePath())
+                .append(mainJarName).append(" ")
+                .append(javaParameters.getMainArgs().trim()).append(" ")
+                .append(javaParameters.getJvmArgs().trim());
+        return builder.toString();
+    }
+
+    private String getResourceNameOfMainJar(ResourceInfo mainJar) {
+        if (null == mainJar) {
+            throw new RuntimeException("The jar for the task is required.");
+        }
+        return mainJar.getId() == 0
+                ? mainJar.getRes()
+                // when update resource maybe has error
+                : mainJar.getResourceName().replaceFirst(SINGLE_SLASH, "");
+    }
+
+    @Override
+    public void cancelApplication(boolean cancelApplication) throws Exception {
+        // cancel process
+        shellCommandExecutor.cancelApplication();
+    }
+
+    @Override
+    public AbstractParameters getParameters() {
+        return javaParameters;
+    }
+
+    /**
+     * @description: Replaces placeholders such as local variables in source files
+     * @param: [java.lang.String]
+     * @return: java.lang.String
+     **/
+    protected static String convertJavaSourceCodePlaceholders(String rawScript) throws StringIndexOutOfBoundsException {

Review Comment:
   Maybe. I haven't tried



-- 
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


[GitHub] [dolphinscheduler] sonarcloud[bot] commented on pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
sonarcloud[bot] commented on PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#issuecomment-1200898300

   SonarCloud Quality Gate failed.&nbsp; &nbsp; [![Quality Gate failed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/failed-16px.png 'Quality Gate failed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=10689)
   
   [![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png 'Bug')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG)  
   [![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png 'Vulnerability')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY)  
   [![Security Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png 'Security Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT)  
   [![Code Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png 'Code Smell')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL) [15 Code Smells](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL)
   
   [![0.4%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/0-16px.png '0.4%')](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_coverage&view=list) [0.4% Coverage](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_coverage&view=list)  
   [![1.9%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3-16px.png '1.9%')](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_duplicated_lines_density&view=list) [1.9% Duplication](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_duplicated_lines_density&view=list)
   
   


-- 
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


[GitHub] [dolphinscheduler] EricGao888 commented on a diff in pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
EricGao888 commented on code in PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#discussion_r925755338


##########
dolphinscheduler-task-plugin/dolphinscheduler-task-java/src/main/java/org/apache/dolphinscheduler/plugin/task/java/JavaParameters.java:
##########
@@ -0,0 +1,64 @@
+/*
+ * 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 org.apache.dolphinscheduler.plugin.task.api.model.ResourceInfo;
+import org.apache.dolphinscheduler.plugin.task.api.parameters.AbstractParameters;
+
+import java.util.List;
+
+import lombok.Data;
+
+@Data

Review Comment:
   > SonarCloud Quality Gate failed.    [![Quality Gate failed](https://camo.githubusercontent.com/4ea51c1f64ee3746f631653a02ab678ca6a3efb5f5cb474402faed2e3dcf90b5/68747470733a2f2f736f6e6172736f757263652e6769746875622e696f2f736f6e6172636c6f75642d6769746875622d7374617469632d7265736f75726365732f76322f636865636b732f5175616c6974794761746542616467652f6661696c65642d313670782e706e67)](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=10689)
   > 
   > [![Bug](https://camo.githubusercontent.com/4c6102327f5a954f9c8acaf2e2714183157a9e41717b371b2cd585cf25057310/68747470733a2f2f736f6e6172736f757263652e6769746875622e696f2f736f6e6172636c6f75642d6769746875622d7374617469632d7265736f75726365732f76322f636f6d6d6f6e2f6275672d313670782e706e67)](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG) [![A](https://camo.githubusercontent.com/1cba125a897d7fa47033a3b3b2be2bbee680d34d4f004a215564659b853fb201/68747470733a2f2f736f6e6172736f757263652e6769746875622e696f2f736f6e6172636c6f75642d6769746875622d7374617469632d7265736f75726365732f76322f636865636b732f526174696e6742616467652f412d313670782e706e67)](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG) [![Vulnerability](https://camo.githubusercontent.com/3ba1ee49636ffc3427e
 38649a9f8a65ee392f28e8a662fcf96ce24cefbb520e9/68747470733a2f2f736f6e6172736f757263652e6769746875622e696f2f736f6e6172636c6f75642d6769746875622d7374617469632d7265736f75726365732f76322f636f6d6d6f6e2f76756c6e65726162696c6974792d313670782e706e67)](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY) [![A](https://camo.githubusercontent.com/1cba125a897d7fa47033a3b3b2be2bbee680d34d4f004a215564659b853fb201/68747470733a2f2f736f6e6172736f757263652e6769746875622e696f2f736f6e6172636c6f75642d6769746875622d7374617469632d7265736f75726365732f76322f636865636b732f526174696e6742616467652f412d313670782e706e67)](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY) [![Security Hotspot](https://camo.githubusercontent.com/fb735cbe76f8d5e1679c7
 6ce83b740ceb1eaf62de4f7bf88623dc9953261aff7/68747470733a2f2f736f6e6172736f757263652e6769746875622e696f2f736f6e6172636c6f75642d6769746875622d7374617469632d7265736f75726365732f76322f636f6d6d6f6e2f73656375726974795f686f7473706f742d313670782e706e67)](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT) [![A](https://camo.githubusercontent.com/1cba125a897d7fa47033a3b3b2be2bbee680d34d4f004a215564659b853fb201/68747470733a2f2f736f6e6172736f757263652e6769746875622e696f2f736f6e6172636c6f75642d6769746875622d7374617469632d7265736f75726365732f76322f636865636b732f526174696e6742616467652f412d313670782e706e67)](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT) [![Code Smell](https://camo.g
 ithubusercontent.com/8fe18b2dfb6f7d4e44582f281b29f617eb5ae07c248d2002ca586e91da219212/68747470733a2f2f736f6e6172736f757263652e6769746875622e696f2f736f6e6172636c6f75642d6769746875622d7374617469632d7265736f75726365732f76322f636f6d6d6f6e2f636f64655f736d656c6c2d313670782e706e67)](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL) [![A](https://camo.githubusercontent.com/1cba125a897d7fa47033a3b3b2be2bbee680d34d4f004a215564659b853fb201/68747470733a2f2f736f6e6172736f757263652e6769746875622e696f2f736f6e6172636c6f75642d6769746875622d7374617469632d7265736f75726365732f76322f636865636b732f526174696e6742616467652f412d313670782e706e67)](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL) [14 Code Smells](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL)
   > 
   > [![0.4%](https://camo.githubusercontent.com/3f04cff3eeef8477afe696ae55c570cbb6ed02f16152497c14251828329a3e91/68747470733a2f2f736f6e6172736f757263652e6769746875622e696f2f736f6e6172636c6f75642d6769746875622d7374617469632d7265736f75726365732f76322f636865636b732f436f76657261676543686172742f302d313670782e706e67)](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_coverage&view=list) [0.4% Coverage](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_coverage&view=list) [![2.2%](https://camo.githubusercontent.com/8047c63e1f9ed03f63001e1eadce4676bade3e0f83ec690a9c625287796248a6/68747470733a2f2f736f6e6172736f757263652e6769746875622e696f2f736f6e6172636c6f75642d6769746875622d7374617469632d7265736f75726365732f76322f636865636b732f4475706c69636174696f6e732f332d313670782e706e67)](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_duplicated_lines_density&vie
 w=list) [2.2% Duplication](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_duplicated_lines_density&view=list)
   
   After replacing `@Data`, I think `sonar analysis` will no more fail because of low test coverage.



-- 
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


[GitHub] [dolphinscheduler] sonarcloud[bot] commented on pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
sonarcloud[bot] commented on PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#issuecomment-1211810594

   SonarCloud Quality Gate failed.&nbsp; &nbsp; [![Quality Gate failed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/failed-16px.png 'Quality Gate failed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=10689)
   
   [![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png 'Bug')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG)  
   [![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png 'Vulnerability')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY)  
   [![Security Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png 'Security Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT)  
   [![Code Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png 'Code Smell')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL) [13 Code Smells](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL)
   
   [![0.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/0-16px.png '0.0%')](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_coverage&view=list) [0.0% Coverage](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_coverage&view=list)  
   [![1.9%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3-16px.png '1.9%')](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_duplicated_lines_density&view=list) [1.9% Duplication](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_duplicated_lines_density&view=list)
   
   


-- 
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


[GitHub] [dolphinscheduler] 106umao commented on a diff in pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
106umao commented on code in PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#discussion_r945312221


##########
dolphinscheduler-task-plugin/dolphinscheduler-task-java/src/main/java/org/apache/dolphinscheduler/plugin/task/java/JavaTask.java:
##########
@@ -0,0 +1,422 @@
+/*
+ * 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 static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.SINGLE_SLASH;
+import static org.apache.dolphinscheduler.plugin.task.java.JavaConstants.JAVA_HOME_VAR;
+import static org.apache.dolphinscheduler.plugin.task.java.JavaConstants.PUBLIC_CLASS_NAME_REGEX;
+
+
+import org.apache.dolphinscheduler.plugin.task.api.AbstractTaskExecutor;
+import org.apache.dolphinscheduler.plugin.task.api.ShellCommandExecutor;
+import org.apache.dolphinscheduler.plugin.task.api.TaskConstants;
+import org.apache.dolphinscheduler.plugin.task.api.TaskException;
+import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext;
+import org.apache.dolphinscheduler.plugin.task.api.model.Property;
+import org.apache.dolphinscheduler.plugin.task.api.model.ResourceInfo;
+import org.apache.dolphinscheduler.plugin.task.api.model.TaskResponse;
+import org.apache.dolphinscheduler.plugin.task.api.parameters.AbstractParameters;
+import org.apache.dolphinscheduler.plugin.task.api.parser.ParamUtils;
+import org.apache.dolphinscheduler.plugin.task.api.parser.ParameterUtils;
+import org.apache.dolphinscheduler.plugin.task.api.utils.MapUtils;
+import org.apache.dolphinscheduler.plugin.task.java.exception.JavaSourceFileExistException;
+import org.apache.dolphinscheduler.plugin.task.java.exception.PublicClassNotFoundException;
+import org.apache.dolphinscheduler.plugin.task.java.exception.RunTypeNotFoundException;
+import org.apache.dolphinscheduler.spi.utils.JSONUtils;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.lang3.SystemUtils;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import com.google.common.base.Preconditions;
+
+/**
+ * java task
+ */
+public class JavaTask extends AbstractTaskExecutor {
+
+    /**
+     * Contains various parameters for this task
+     */
+    private JavaParameters javaParameters;
+
+    /**
+     * To run shell commands
+     */
+    private ShellCommandExecutor shellCommandExecutor;
+
+    /**
+     * task execution context
+     */
+    private TaskExecutionContext taskRequest;
+
+    /**
+     * class name regex pattern
+     */
+    private static final Pattern classNamePattern = Pattern.compile(PUBLIC_CLASS_NAME_REGEX);
+
+    /**
+     * @description: Construct a Java task
+     * @param: [org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext]
+     * @return: JavaTask
+     **/
+    public JavaTask(TaskExecutionContext taskRequest) {
+        super(taskRequest);
+        this.taskRequest = taskRequest;
+        this.shellCommandExecutor = new ShellCommandExecutor(this::logHandle,
+                taskRequest,
+                logger);
+    }
+
+    /**
+     * @description: Initializes a Java task
+     * @param: []
+     * @return: void
+     **/
+    @Override
+    public void init() {
+        logger.info("java task params {}", taskRequest.getTaskParams());
+        javaParameters = JSONUtils.parseObject(taskRequest.getTaskParams(), JavaParameters.class);
+        if (javaParameters == null || !javaParameters.checkParameters()) {
+            throw new TaskException("java task params is not valid");
+        }
+        if (javaParameters.getRunType().equals(JavaConstants.RUN_TYPE_JAR)) {
+            setMainJarName();
+        }
+    }
+
+    /**
+     * @description: Gets the Java source file that was initially processed
+     * @param: []
+     * @return: java.lang.String
+     **/
+    @Override
+    public String getPreScript() {
+        String rawJavaScript = javaParameters.getRawScript().replaceAll("\\r\\n", "\n");
+        try {
+            rawJavaScript = convertJavaSourceCodePlaceholders(rawJavaScript);
+        } catch (StringIndexOutOfBoundsException e) {
+            logger.error("setShareVar field format error, raw java script : {}", rawJavaScript);
+        }
+        return rawJavaScript;
+    }
+
+    /**
+     * @description: Execute Java tasks
+     * @param: []
+     * @return: void
+     **/
+    @Override
+    public void handle() throws Exception {
+        try {
+            // Step 1: judge if is java or jar run type.
+            // Step 2 case1: The jar run type builds the command directly, adding resource to the java -jar class when building the command
+            // Step 2 case2: The java run type, first replace the custom parameters, then compile the code, and then build the command will add resource
+            // Step 3: To run the command
+            String command = null;
+            switch (javaParameters.getRunType()) {
+                case JavaConstants.RUN_TYPE_JAVA:
+                    command = buildJavaCommand();
+                    break;
+                case JavaConstants.RUN_TYPE_JAR:
+                    command = buildJarCommand();
+                    break;
+                default:
+                    throw new RunTypeNotFoundException("run type is required, but it is null now.");
+            }
+            Preconditions.checkNotNull(command, "command not be null.");
+            TaskResponse taskResponse = shellCommandExecutor.run(command);
+            logger.info("java task run result : {}", taskResponse);
+            setExitStatusCode(taskResponse.getExitStatusCode());
+            setAppIds(taskResponse.getAppIds());
+            setProcessId(taskResponse.getProcessId());
+            setVarPool(shellCommandExecutor.getVarPool());
+        } catch (InterruptedException e) {
+            logger.error("java task interrupted ", e);
+            setExitStatusCode(TaskConstants.EXIT_CODE_FAILURE);
+            Thread.currentThread().interrupt();
+        } catch (RunTypeNotFoundException e) {
+            logger.error(e.getMessage());
+            setExitStatusCode(TaskConstants.EXIT_CODE_FAILURE);
+            throw e;
+        } catch (Exception e) {
+            logger.error("java task failed ", e);
+            setExitStatusCode(TaskConstants.EXIT_CODE_FAILURE);
+            throw new TaskException("run java task error", e);
+        }
+    }
+
+    /**
+     * @description: Construct a shell command for the java Run mode
+     * @param: []
+     * @return: java.lang.String
+     **/
+    protected String buildJavaCommand() throws Exception {
+        String sourceCode = buildJavaSourceContent();
+        String className = compilerRawScript(sourceCode);
+        StringBuilder builder = new StringBuilder();
+        builder.append(getJavaCommandPath())
+                .append("java").append(" ")
+                .append(buildResourcePath())
+                .append(" ")
+                .append(className).append(" ")
+                .append(javaParameters.getMainArgs().trim()).append(" ")
+                .append(javaParameters.getJvmArgs().trim());
+        return builder.toString();
+    }
+
+    private void setMainJarName() {
+        ResourceInfo mainJar = javaParameters.getMainJar();
+        String resourceName = getResourceNameOfMainJar(mainJar);
+        mainJar.setRes(resourceName);
+        javaParameters.setMainJar(mainJar);
+    }
+
+    /**
+     * @description: Construct a shell command for the java -jar Run mode
+     * @param: []
+     * @return: java.lang.String
+     **/
+    protected String buildJarCommand() {
+        String fullName = javaParameters.getMainJar().getResourceName();
+        String mainJarName = fullName.substring(0, fullName.lastIndexOf('.'));
+        mainJarName = mainJarName.substring(mainJarName.lastIndexOf('.') + 1) + ".jar";
+        StringBuilder builder = new StringBuilder();
+        builder.append(getJavaCommandPath())
+                .append("java").append(" ")
+                .append(buildResourcePath()).append(" ")
+                .append("-jar").append(" ")
+                .append(taskRequest.getExecutePath())
+                .append(mainJarName).append(" ")
+                .append(javaParameters.getMainArgs().trim()).append(" ")
+                .append(javaParameters.getJvmArgs().trim());
+        return builder.toString();
+    }
+
+    private String getResourceNameOfMainJar(ResourceInfo mainJar) {
+        if (null == mainJar) {
+            throw new RuntimeException("The jar for the task is required.");
+        }
+        return mainJar.getId() == 0
+                ? mainJar.getRes()
+                // when update resource maybe has error
+                : mainJar.getResourceName().replaceFirst(SINGLE_SLASH, "");
+    }
+
+    @Override
+    public void cancelApplication(boolean cancelApplication) throws Exception {
+        // cancel process
+        shellCommandExecutor.cancelApplication();
+    }
+
+    @Override
+    public AbstractParameters getParameters() {
+        return javaParameters;
+    }
+
+    /**
+     * @description: Replaces placeholders such as local variables in source files
+     * @param: [java.lang.String]
+     * @return: java.lang.String
+     **/
+    protected static String convertJavaSourceCodePlaceholders(String rawScript) throws StringIndexOutOfBoundsException {
+        int len = "${setShareVar(${".length();
+        int scriptStart = 0;
+        while ((scriptStart = rawScript.indexOf("${setShareVar(${", scriptStart)) != -1) {
+            int start = -1;
+            int end = rawScript.indexOf('}', scriptStart + len);
+            String prop = rawScript.substring(scriptStart + len, end);
+
+            start = rawScript.indexOf(',', end);
+            end = rawScript.indexOf(')', start);
+
+            String value = rawScript.substring(start + 1, end);
+
+            start = rawScript.indexOf('}', start) + 1;
+            end = rawScript.length();
+
+            String replaceScript = String.format("print(\"${{setValue({},{})}}\".format(\"%s\",%s))", prop, value);
+
+            rawScript = rawScript.substring(0, scriptStart) + replaceScript + rawScript.substring(start, end);
+
+            scriptStart += replaceScript.length();
+        }
+        return rawScript;
+    }
+
+    /**
+     * @description: Creates a Java source file when it does not exist
+     * @param: [java.lang.String, java.lang.String]
+     * @return: java.lang.String
+     **/
+    protected void createJavaSourceFileIfNotExists(String sourceCode, String fileName) throws IOException {
+        logger.info("tenantCode: {}, task dir:{}", taskRequest.getTenantCode(), taskRequest.getExecutePath());
+
+        if (!Files.exists(Paths.get(fileName))) {
+            logger.info("generate java source file: {}", fileName);
+
+            StringBuilder sb = new StringBuilder();
+            sb.append(sourceCode);
+            logger.info(sb.toString());
+
+            // write data to file
+            FileUtils.writeStringToFile(new File(fileName),
+                    sb.toString(),
+                    StandardCharsets.UTF_8);
+        } else {
+            throw new JavaSourceFileExistException("java source file exists, please report an issue on official.");
+        }
+    }
+
+    /**
+     * @description: Construct the full path name of the Java source file from the temporary execution path of the task
+     * @param: []
+     * @return: java.lang.String
+     **/
+    protected String buildJavaSourceCodeFileFullName(String publicClassName) {
+        return String.format(JavaConstants.JAVA_SOURCE_CODE_NAME_TEMPLATE, taskRequest.getExecutePath(), publicClassName);
+    }
+
+    /**
+     * @description: Construct a Classpath or module path based on isModulePath
+     * @param: []
+     * @return: java.lang.String
+     **/
+    protected String buildResourcePath() {
+        StringBuilder builder = new StringBuilder();
+        if (javaParameters.isModulePath()) {
+            builder.append("--module-path");
+        } else {
+            builder.append("--class-path");
+        }
+        builder.append(" ").append(JavaConstants.CLASSPATH_CURRENT_DIR)
+                .append(JavaConstants.PATH_SEPARATOR)
+                .append(taskRequest.getExecutePath());
+        for (ResourceInfo info : javaParameters.getResourceFilesList()) {
+            builder.append(JavaConstants.PATH_SEPARATOR);
+            builder.append(taskRequest.getExecutePath())
+                    .append(info.getResourceName());
+        }
+        return builder.toString();
+    }
+
+    /**
+     * @description: Compile the Java source file
+     * @param: [java.lang.String]
+     * @return: java.lang.String
+     **/
+    protected String compilerRawScript(String sourceCode) throws IOException, InterruptedException {
+        String publicClassName = getPublicClassName(sourceCode);
+        String fileName =  buildJavaSourceCodeFileFullName(publicClassName);
+        createJavaSourceFileIfNotExists(sourceCode, fileName);
+        String compileCommand = buildJavaCompileCommand(fileName, sourceCode);
+        Preconditions.checkNotNull(compileCommand, "command not be null.");
+        TaskResponse compileResponse = shellCommandExecutor.run(compileCommand);
+        // must drop the command file ,if do not ,the next command will not run. because be limited the ShellCommandExecutor's create file rules
+        dropShellCommandFile();

Review Comment:
   thx, It is a bit strange to have two processes running, I will optimize to run in one process



-- 
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


[GitHub] [dolphinscheduler] sonarcloud[bot] commented on pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
sonarcloud[bot] commented on PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#issuecomment-1175305165

   SonarCloud Quality Gate failed.&nbsp; &nbsp; [![Quality Gate failed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/failed-16px.png 'Quality Gate failed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=10689)
   
   [![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png 'Bug')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG)  
   [![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png 'Vulnerability')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY)  
   [![Security Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png 'Security Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT) [![E](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/E-16px.png 'E')](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT) [1 Security Hotspot](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT)  
   [![Code Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png 'Code Smell')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL) [24 Code Smells](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL)
   
   [![0.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/0-16px.png '0.0%')](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_coverage&view=list) [0.0% Coverage](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_coverage&view=list)  
   [![2.1%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3-16px.png '2.1%')](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_duplicated_lines_density&view=list) [2.1% Duplication](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_duplicated_lines_density&view=list)
   
   


-- 
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


[GitHub] [dolphinscheduler] 106umao commented on a diff in pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
106umao commented on code in PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#discussion_r928153102


##########
dolphinscheduler-task-plugin/dolphinscheduler-task-java/src/main/java/org/apache/dolphinscheduler/plugin/task/java/JavaTask.java:
##########
@@ -0,0 +1,348 @@
+/*
+ * 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 static org.apache.dolphinscheduler.plugin.task.java.JavaConstants.PUBLIC_CLASS_NAME_REGEX;
+
+import org.apache.dolphinscheduler.plugin.task.api.AbstractTaskExecutor;
+import org.apache.dolphinscheduler.plugin.task.api.ShellCommandExecutor;
+import org.apache.dolphinscheduler.plugin.task.api.TaskConstants;
+import org.apache.dolphinscheduler.plugin.task.api.TaskException;
+import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext;
+import org.apache.dolphinscheduler.plugin.task.api.model.Property;
+import org.apache.dolphinscheduler.plugin.task.api.model.ResourceInfo;
+import org.apache.dolphinscheduler.plugin.task.api.model.TaskResponse;
+import org.apache.dolphinscheduler.plugin.task.api.parameters.AbstractParameters;
+import org.apache.dolphinscheduler.plugin.task.api.parser.ParamUtils;
+import org.apache.dolphinscheduler.plugin.task.api.parser.ParameterUtils;
+import org.apache.dolphinscheduler.plugin.task.api.utils.MapUtils;
+import org.apache.dolphinscheduler.plugin.task.java.exception.JavaSourceFileExistException;
+import org.apache.dolphinscheduler.plugin.task.java.exception.PublicClassNotFoundException;
+import org.apache.dolphinscheduler.plugin.task.java.exception.RunTypeNotFoundException;
+import org.apache.dolphinscheduler.spi.utils.JSONUtils;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.lang3.SystemUtils;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import com.google.common.base.Preconditions;
+
+/**
+ * java task
+ */
+public class JavaTask extends AbstractTaskExecutor {
+
+    /**
+     * java parameters
+     */
+    private JavaParameters javaParameters;
+
+    /**
+     * shell command executor
+     */
+    private ShellCommandExecutor shellCommandExecutor;
+
+    /**
+     * task execution context
+     */
+    private TaskExecutionContext taskRequest;
+
+    private static final Pattern classNamePattern = Pattern.compile(PUBLIC_CLASS_NAME_REGEX);
+
+    /**
+     * constructor
+     *
+     * @param taskRequest taskRequest
+     */
+    public JavaTask(TaskExecutionContext taskRequest) {
+        super(taskRequest);
+        this.taskRequest = taskRequest;
+        this.shellCommandExecutor = new ShellCommandExecutor(this::logHandle,
+                taskRequest,
+                logger);
+    }
+
+    @Override
+    public void init() {
+        logger.info("java task params {}", taskRequest.getTaskParams());
+        javaParameters = JSONUtils.parseObject(taskRequest.getTaskParams(), JavaParameters.class);
+        if (javaParameters == null || !javaParameters.checkParameters()) {
+            throw new TaskException("java task params is not valid");
+        }
+        if (javaParameters.getRunType().equals(JavaConstants.RUN_TYPE_JAR)) {
+            setMainJarName();
+        }
+    }
+
+    @Override
+    public String getPreScript() {
+        String rawJavaScript = javaParameters.getRawScript().replaceAll("\\r\\n", "\n");
+        try {
+            rawJavaScript = convertJavaSourceCodePlaceholders(rawJavaScript);
+        } catch (StringIndexOutOfBoundsException e) {
+            logger.error("setShareVar field format error, raw java script : {}", rawJavaScript);
+        }
+        return rawJavaScript;
+    }
+
+    @Override
+    public void handle() throws Exception {
+        try {
+            // Step 1 judge if is java or jar run type.
+            // The  jar run type builds the command directly, adding resource to the java -jar class when building the command
+            // The java run type, first replace the custom parameters, then compile the code, and then build the command will add resource
+            // To run the coma
+            String command = null;
+            switch (javaParameters.getRunType()) {
+                case JavaConstants.RUN_TYPE_JAVA:
+                    command = buildJavaCommand();
+                    break;
+                case JavaConstants.RUN_TYPE_JAR:
+                    command = buildJarCommand();
+                    break;
+                default:
+                    throw new RunTypeNotFoundException("run type is required, but it is null now.");
+            }
+            Preconditions.checkNotNull(command, "command not be null.");
+            TaskResponse taskResponse = shellCommandExecutor.run(command);
+            logger.info("java task run result : " + taskResponse);
+            setExitStatusCode(taskResponse.getExitStatusCode());
+            setAppIds(taskResponse.getAppIds());
+            setProcessId(taskResponse.getProcessId());
+            setVarPool(shellCommandExecutor.getVarPool());
+        } catch (InterruptedException e) {
+            logger.error("java task interrupted ", e);
+            setExitStatusCode(TaskConstants.EXIT_CODE_FAILURE);
+            Thread.currentThread().interrupt();
+        } catch (Exception e) {
+            logger.error("java task failed ", e);
+            setExitStatusCode(TaskConstants.EXIT_CODE_FAILURE);
+            throw new TaskException("run java task error", e);
+        }
+    }
+
+    protected String buildJavaCommand() throws Exception {
+        String sourceCode = buildJavaSourceContent();
+        String className = compilerRawScript(sourceCode);
+        StringBuilder builder = new StringBuilder();
+        builder.append(getJavaHomeBinAbsolutePath())
+                .append("java").append(" ")
+                .append(buildResourcePath())
+                .append(" ")
+                .append(className).append(" ")
+                .append(javaParameters.getMainArgs().trim()).append(" ")
+                .append(javaParameters.getJvmArgs().trim());
+        return builder.toString();
+    }
+
+    private void setMainJarName() {
+        ResourceInfo mainJar = javaParameters.getMainJar();
+        String resourceName = getResourceNameOfMainJar(mainJar);
+        mainJar.setRes(resourceName);
+        javaParameters.setMainJar(mainJar);
+    }
+
+    private String getResourceNameOfMainJar(ResourceInfo mainJar) {
+        if (null == mainJar) {
+            throw new RuntimeException("The jar for the task is required.");
+        }
+
+        return mainJar.getId() == 0
+                ? mainJar.getRes()
+                // when update resource maybe has error
+                : mainJar.getResourceName().replaceFirst("/", "");
+    }
+
+    protected String buildJarCommand() {
+        String fullName = javaParameters.getMainJar().getResourceName();
+        String mainJarName = fullName.substring(0, fullName.lastIndexOf('.'));
+        mainJarName = mainJarName.substring(mainJarName.lastIndexOf('.') + 1) + ".jar";
+        StringBuilder builder = new StringBuilder();
+        builder.append(getJavaHomeBinAbsolutePath())
+                .append("java").append(" ")
+                .append(buildResourcePath()).append(" ")
+                .append("-jar").append(" ")
+                .append(taskRequest.getExecutePath())
+                .append(mainJarName).append(" ")
+                .append(javaParameters.getMainArgs().trim()).append(" ")
+                .append(javaParameters.getJvmArgs().trim());
+        return builder.toString();
+    }
+    
+    @Override
+    public void cancelApplication(boolean cancelApplication) throws Exception {
+        // cancel process
+        shellCommandExecutor.cancelApplication();
+    }
+
+    @Override
+    public AbstractParameters getParameters() {
+        return javaParameters;
+    }
+
+    /**
+     * convertJavaScriptPlaceholders
+     *
+     * @param rawScript rawScript
+     * @return String
+     * @throws StringIndexOutOfBoundsException StringIndexOutOfBoundsException
+     */
+    protected static String convertJavaSourceCodePlaceholders(String rawScript) throws StringIndexOutOfBoundsException {
+        int len = "${setShareVar(${".length();
+        int scriptStart = 0;
+        while ((scriptStart = rawScript.indexOf("${setShareVar(${", scriptStart)) != -1) {
+            int start = -1;
+            int end = rawScript.indexOf('}', scriptStart + len);
+            String prop = rawScript.substring(scriptStart + len, end);
+
+            start = rawScript.indexOf(',', end);
+            end = rawScript.indexOf(')', start);
+
+            String value = rawScript.substring(start + 1, end);
+
+            start = rawScript.indexOf('}', start) + 1;
+            end = rawScript.length();
+
+            String replaceScript = String.format("print(\"${{setValue({},{})}}\".format(\"%s\",%s))", prop, value);
+
+            rawScript = rawScript.substring(0, scriptStart) + replaceScript + rawScript.substring(start, end);
+
+            scriptStart += replaceScript.length();
+        }
+        return rawScript;
+    }
+
+    protected void createJavaSourceFileIfNotExists(String sourceCode, String fileName) throws IOException {
+        logger.info("tenantCode :{}, task dir:{}", taskRequest.getTenantCode(), taskRequest.getExecutePath());
+
+        if (!Files.exists(Paths.get(fileName))) {
+            logger.info("generate java source file:{}", fileName);
+
+            StringBuilder sb = new StringBuilder();
+            sb.append(sourceCode);
+            logger.info(sb.toString());
+
+            // write data to file
+            FileUtils.writeStringToFile(new File(fileName),
+                    sb.toString(),
+                    StandardCharsets.UTF_8);
+        } else {
+            throw new JavaSourceFileExistException("java source file exists, please report an issue on official.");
+        }
+    }
+
+    protected String buildJavaSourceCodeFileFullName(String publicClassName) {
+        return String.format(JavaConstants.JAVA_SOURCE_CODE_NAME_TEMPLATE, taskRequest.getExecutePath(), publicClassName);
+    }
+
+    protected String buildResourcePath() {
+        StringBuilder builder = new StringBuilder();
+        if (javaParameters.isModulePath()) {
+            builder.append("--module-path");
+        } else {
+            builder.append("--class-path");
+        }
+        builder.append(" ").append(JavaConstants.CLASSPATH_CURRENT_DIR)
+                .append(JavaConstants.PATH_SEPARATOR)
+                .append(taskRequest.getExecutePath());
+        for (ResourceInfo info : javaParameters.getResourceFilesList()) {
+            builder.append(JavaConstants.PATH_SEPARATOR);
+            builder.append(taskRequest.getExecutePath())
+                    .append(info.getResourceName());
+        }
+        return builder.toString();
+    }
+
+    protected String compilerRawScript(String sourceCode) throws IOException, InterruptedException {
+        String publicClassName = getPublicClassName(sourceCode);
+        String fileName =  buildJavaSourceCodeFileFullName(publicClassName);
+        createJavaSourceFileIfNotExists(sourceCode, fileName);
+        String compileCommand = buildJavaCompileCommand(fileName, sourceCode);
+        Preconditions.checkNotNull(compileCommand, "command not be null.");
+        TaskResponse compileResponse = shellCommandExecutor.run(compileCommand);
+        // must drop the command file ,if do not ,the next command will not run. because be limited the ShellCommandExecutor's create file rules
+        dropShellCommandFile();
+        shellCommandExecutor = new ShellCommandExecutor(this::logHandle,
+                taskRequest,
+                logger);
+        logger.info("java task code compile result : " + compileResponse);
+        return publicClassName;
+    }
+
+    private void dropShellCommandFile() throws IOException {
+        String commandFilePath = String.format("%s/%s.%s"
+                , taskRequest.getExecutePath()
+                , taskRequest.getTaskAppId()
+                , SystemUtils.IS_OS_WINDOWS ? "bat" : "command");
+        Path path = Paths.get(commandFilePath);
+        if (Files.exists(path)) {
+            Files.delete(path);
+        }
+    }
+
+    protected String buildJavaCompileCommand(String fileName, String sourceCode) throws IOException {
+
+        StringBuilder compilerCommand = new StringBuilder()
+                .append(getJavaHomeBinAbsolutePath())
+                .append("javac").append(" ")
+                .append(buildResourcePath()).append(" ")
+                .append(fileName);
+        return compilerCommand.toString();
+    }
+
+    protected String buildJavaSourceContent() {
+        String rawJavaScript = javaParameters.getRawScript().replaceAll("\\r\\n", "\n");
+        // replace placeholder
+
+        Map<String, Property> paramsMap = taskRequest.getPrepareParamsMap();
+        if (MapUtils.isEmpty(paramsMap)) {
+            paramsMap = new HashMap<>();
+        }
+        if (MapUtils.isNotEmpty(taskRequest.getParamsMap())) {
+            paramsMap.putAll(taskRequest.getParamsMap());
+        }
+        rawJavaScript = ParameterUtils.convertParameterPlaceholders(rawJavaScript, ParamUtils.convert(paramsMap));
+        logger.info("raw java script : {}", javaParameters.getRawScript());
+        return rawJavaScript;
+    }
+
+    private String getJavaHomeBinAbsolutePath() {
+        String javaHomeAbsolutePath = System.getenv(JavaConstants.JAVA_HOME);

Review Comment:
   Hi @SbloodyS 
   thank you, I have modified for it now , PTAL.



-- 
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


[GitHub] [dolphinscheduler] 106umao commented on a diff in pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
106umao commented on code in PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#discussion_r965025951


##########
dolphinscheduler-ui/src/views/projects/task/components/node/fields/use-java.ts:
##########
@@ -0,0 +1,86 @@
+/*
+ * 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.
+ */
+import { computed } from 'vue'
+import { useI18n } from 'vue-i18n'
+import { useCustomParams, useResources ,useJavaTaskMainJar} from '.'
+import type { IJsonItem } from '../types'
+
+export function useJava(model: { [field: string]: any }): IJsonItem[] {
+  const { t } = useI18n()
+  const rawScriptSpan = computed(() => (model.runType === 'JAR' ? 0 : 24))
+  return [
+    {
+        type: 'select',
+        field: 'runType',
+        span: 12,
+        name: t('project.node.run_type'),
+        options: RUN_TYPES,
+        value: model.runType
+      },
+      {
+          type: 'switch',
+          field: 'isModulePath',
+          span: 24,
+          name: t('project.node.is_module_path'),
+          value: model.isModulePath
+      },
+      {
+        type: 'input',
+        field: 'mainArgs',
+        name: t('project.node.main_arguments'),
+        props: {
+          type: 'textarea',
+          placeholder: t('project.node.main_arguments_tips')
+        }
+      },
+      {
+        type: 'input',
+        field: 'jvmArgs',
+        name: t('project.node.jvm_args'),
+        props: {
+          type: 'textarea',
+          placeholder: t('project.node.jvm_args_tips')
+        }
+      },
+      useJavaTaskMainJar(model),
+    {
+      type: 'editor',
+      field: 'rawScript',
+      span: rawScriptSpan,
+      name: t('project.node.script'),
+      validate: {
+        trigger: ['input', 'trigger'],
+        required: true,
+        message: t('project.node.script_tips')

Review Comment:
   Usually no one writes Java code in a browser, so a shell should suffice



-- 
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


[GitHub] [dolphinscheduler] SbloodyS commented on pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
SbloodyS commented on PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#issuecomment-1197628328

   > > Backend part overall LGTM, it would be better if we could have those exceptions covered in UTs.
   > 
   > @SbloodyS Could u please take another look when available? Thanks~
   
   Will take a look this afternoon.


-- 
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


[GitHub] [dolphinscheduler] 106umao commented on a diff in pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
106umao commented on code in PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#discussion_r930794179


##########
docs/docs/en/guide/task/java.md:
##########
@@ -0,0 +1,48 @@
+# Overview
+
+This node is used to perform java-type tasks and supports the use of single files and jar packages as program entries.
+
+# Create Tasks
+
+- Click on project management-> Project name-> workflow definition, click on the“Create workflow” button, go to the DAG edit page:
+
+- Drag the toolbar's Java task node to the palette.
+
+# Task Parameters
+| **Parameter** | **Description** |
+| ------- | ---------- |
+|Node Name|the name of the set task. The node name in a workflow definition is unique.
+|Run Flag|indicates whether the node is scheduled properly and, if it is not needed, turns on the kill switch.
+|Description|describes the functionality of the node.
+|Task Priority|when the number of worker threads is insufficient, the worker is executed according to the priority from high to low. When the priority is the same, the worker is executed according to the first in, first out principle.
+|Worker Group|The machine whose task is assigned to the Worker group executes, and selecting Default will randomly select a Worker machine to execute.
+|Environment Name|configure the environment in which the task runs.
+|Number Of Failed Retries|number of resubmitted tasks that failed, supported drop-down and hand-fill.
+|Failed Retry Interval|the interval between tasks that fail and are resubmitted, supported by drop-down and hand-fill.
+|Delayed Execution Time|the amount of time a task is delayed, in units.
+|Timeout Alarm|Check timeout warning, timeout failure, when the task exceeds the“Timeout length”, send a warning message and the task execution fails.
+|Module Path|turn on the use of Java 9 + 's modularity feature, put all resources into-module-path, and require that the JDK version in your worker support modularity.
+|Main Parameter|as a normal Java program main method entry parameter.
+|Java VM Parameters|configure startup virtual machine parameters.
+|Script|you need to write Java code if you use the Java run type. The public class must exist in the code without writing a package statement.
+|Resources|these can be external JAR packages or other resource files that are added to the Classpath or module path and can be easily retrieved in your JAVA script.
+|Custom parameter|a user-defined parameter that is part of HTTP and replaces the contents of the script with the ${ variable } .
+|Pre Tasks|selecting a pre-task for the current task sets the selected pre-task upstream of the current task.

Review Comment:
   thanks, it is have 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


[GitHub] [dolphinscheduler] sonarcloud[bot] commented on pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
sonarcloud[bot] commented on PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#issuecomment-1198841768

   SonarCloud Quality Gate failed.&nbsp; &nbsp; [![Quality Gate failed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/failed-16px.png 'Quality Gate failed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=10689)
   
   [![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png 'Bug')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG)  
   [![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png 'Vulnerability')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY)  
   [![Security Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png 'Security Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT)  
   [![Code Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png 'Code Smell')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL) [15 Code Smells](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL)
   
   [![0.4%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/0-16px.png '0.4%')](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_coverage&view=list) [0.4% Coverage](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_coverage&view=list)  
   [![1.9%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3-16px.png '1.9%')](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_duplicated_lines_density&view=list) [1.9% Duplication](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_duplicated_lines_density&view=list)
   
   


-- 
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


[GitHub] [dolphinscheduler] sonarcloud[bot] commented on pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
sonarcloud[bot] commented on PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#issuecomment-1171323763

   SonarCloud Quality Gate failed.&nbsp; &nbsp; [![Quality Gate failed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/failed-16px.png 'Quality Gate failed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=10689)
   
   [![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png 'Bug')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG)  
   [![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png 'Vulnerability')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY)  
   [![Security Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png 'Security Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT) [![E](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/E-16px.png 'E')](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT) [1 Security Hotspot](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT)  
   [![Code Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png 'Code Smell')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL) [24 Code Smells](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL)
   
   [![0.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/0-16px.png '0.0%')](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_coverage&view=list) [0.0% Coverage](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_coverage&view=list)  
   [![2.1%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3-16px.png '2.1%')](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_duplicated_lines_density&view=list) [2.1% Duplication](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_duplicated_lines_density&view=list)
   
   


-- 
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


[GitHub] [dolphinscheduler] 106umao commented on pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
106umao commented on PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#issuecomment-1211704565

   somebody can help me look on the docs dead link error:  [✖] https://dolphinscheduler.apache.org/python/index.html → Status: 404


-- 
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


[GitHub] [dolphinscheduler] SbloodyS commented on a diff in pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
SbloodyS commented on code in PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#discussion_r940828204


##########
dolphinscheduler-ui/src/locales/en_US/project.ts:
##########
@@ -143,7 +142,7 @@ export default {
     rerun: 'Rerun',
     stop: 'Stop',
     pause: 'Pause',
-    recovery_waiting_thread: 'Recovery waiting thread',
+    recovery_waiting_thread:  'Recovery waiting thread',

Review Comment:
   Please remove unnessnary change.



##########
dolphinscheduler-ui/src/locales/zh_CN/project.ts:
##########
@@ -284,6 +284,10 @@ export default {
     online: '已上线'
   },
   node: {
+    is_module_path: '使用模块路劲',

Review Comment:
   ```suggestion
       is_module_path: '使用模块路径',
   ```



##########
dolphinscheduler-task-plugin/dolphinscheduler-task-java/src/main/java/org/apache/dolphinscheduler/plugin/task/java/JavaTask.java:
##########
@@ -0,0 +1,438 @@
+/*
+ * 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 static org.apache.dolphinscheduler.plugin.task.java.JavaConstants.JAVA_HOME_VAR;
+import static org.apache.dolphinscheduler.plugin.task.java.JavaConstants.PUBLIC_CLASS_NAME_REGEX;
+
+import org.apache.dolphinscheduler.plugin.task.api.AbstractTaskExecutor;
+import org.apache.dolphinscheduler.plugin.task.api.ShellCommandExecutor;
+import org.apache.dolphinscheduler.plugin.task.api.TaskConstants;
+import org.apache.dolphinscheduler.plugin.task.api.TaskException;
+import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext;
+import org.apache.dolphinscheduler.plugin.task.api.model.Property;
+import org.apache.dolphinscheduler.plugin.task.api.model.ResourceInfo;
+import org.apache.dolphinscheduler.plugin.task.api.model.TaskResponse;
+import org.apache.dolphinscheduler.plugin.task.api.parameters.AbstractParameters;
+import org.apache.dolphinscheduler.plugin.task.api.parser.ParamUtils;
+import org.apache.dolphinscheduler.plugin.task.api.parser.ParameterUtils;
+import org.apache.dolphinscheduler.plugin.task.api.utils.MapUtils;
+import org.apache.dolphinscheduler.plugin.task.java.exception.JavaSourceFileExistException;
+import org.apache.dolphinscheduler.plugin.task.java.exception.PublicClassNotFoundException;
+import org.apache.dolphinscheduler.plugin.task.java.exception.RunTypeNotFoundException;
+import org.apache.dolphinscheduler.spi.utils.JSONUtils;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.lang3.SystemUtils;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import com.google.common.base.Preconditions;
+
+/**
+ * java task
+ */
+public class JavaTask extends AbstractTaskExecutor {
+
+    /**
+     * Contains various parameters for this task
+     */
+    private JavaParameters javaParameters;
+
+    /**
+     * To run shell commands
+     */
+    private ShellCommandExecutor shellCommandExecutor;
+
+    /**
+     * task execution context
+     */
+    private TaskExecutionContext taskRequest;
+
+    /**
+     * class name regex pattern
+     */
+    private static final Pattern classNamePattern = Pattern.compile(PUBLIC_CLASS_NAME_REGEX);
+
+    /**
+     * @description: Construct a Java task
+     * @date: 7/22/22 2:36 AM
+     * @param: [org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext]
+     * @return: JavaTask
+     **/
+    public JavaTask(TaskExecutionContext taskRequest) {
+        super(taskRequest);
+        this.taskRequest = taskRequest;
+        this.shellCommandExecutor = new ShellCommandExecutor(this::logHandle,
+                taskRequest,
+                logger);
+    }
+
+    /**
+     * @description: Initializes a Java task
+     * @date: 7/22/22 2:36 AM
+     * @param: []
+     * @return: void
+     **/
+    @Override
+    public void init() {
+        logger.info("java task params {}", taskRequest.getTaskParams());
+        javaParameters = JSONUtils.parseObject(taskRequest.getTaskParams(), JavaParameters.class);
+        if (javaParameters == null || !javaParameters.checkParameters()) {
+            throw new TaskException("java task params is not valid");
+        }
+        if (javaParameters.getRunType().equals(JavaConstants.RUN_TYPE_JAR)) {
+            setMainJarName();
+        }
+    }
+
+    /**
+     * @description: Gets the Java source file that was initially processed
+     * @date: 7/22/22 2:36 AM
+     * @param: []
+     * @return: java.lang.String
+     **/
+    @Override
+    public String getPreScript() {
+        String rawJavaScript = javaParameters.getRawScript().replaceAll("\\r\\n", "\n");
+        try {
+            rawJavaScript = convertJavaSourceCodePlaceholders(rawJavaScript);
+        } catch (StringIndexOutOfBoundsException e) {
+            logger.error("setShareVar field format error, raw java script : {}", rawJavaScript);
+        }
+        return rawJavaScript;
+    }
+
+    /**
+     * @description: Execute Java tasks
+     * @date: 7/22/22 2:36 AM
+     * @param: []
+     * @return: void
+     **/
+    @Override
+    public void handle() throws Exception {
+        try {
+            // Step 1: judge if is java or jar run type.
+            // Step 2 case1: The jar run type builds the command directly, adding resource to the java -jar class when building the command
+            // Step 2 case2: The java run type, first replace the custom parameters, then compile the code, and then build the command will add resource
+            // Step 3: To run the command
+            String command = null;
+            switch (javaParameters.getRunType()) {
+                case JavaConstants.RUN_TYPE_JAVA:
+                    command = buildJavaCommand();
+                    break;
+                case JavaConstants.RUN_TYPE_JAR:
+                    command = buildJarCommand();
+                    break;
+                default:
+                    throw new RunTypeNotFoundException("run type is required, but it is null now.");
+            }
+            Preconditions.checkNotNull(command, "command not be null.");
+            TaskResponse taskResponse = shellCommandExecutor.run(command);
+            logger.info("java task run result : {}", taskResponse);
+            setExitStatusCode(taskResponse.getExitStatusCode());
+            setAppIds(taskResponse.getAppIds());
+            setProcessId(taskResponse.getProcessId());
+            setVarPool(shellCommandExecutor.getVarPool());
+        } catch (InterruptedException e) {
+            logger.error("java task interrupted ", e);
+            setExitStatusCode(TaskConstants.EXIT_CODE_FAILURE);
+            Thread.currentThread().interrupt();
+        } catch (RunTypeNotFoundException e) {
+            logger.error(e.getMessage());
+            setExitStatusCode(TaskConstants.EXIT_CODE_FAILURE);
+            throw e;
+        } catch (Exception e) {
+            logger.error("java task failed ", e);
+            setExitStatusCode(TaskConstants.EXIT_CODE_FAILURE);
+            throw new TaskException("run java task error", e);
+        }
+    }
+
+    /**
+     * @description: Construct a shell command for the java Run mode
+     * @date: 7/22/22 2:36 AM
+     * @param: []
+     * @return: java.lang.String
+     **/
+    protected String buildJavaCommand() throws Exception {
+        String sourceCode = buildJavaSourceContent();
+        String className = compilerRawScript(sourceCode);
+        StringBuilder builder = new StringBuilder();
+        builder.append(getJavaCommandPath())
+                .append("java").append(" ")
+                .append(buildResourcePath())
+                .append(" ")
+                .append(className).append(" ")
+                .append(javaParameters.getMainArgs().trim()).append(" ")
+                .append(javaParameters.getJvmArgs().trim());
+        return builder.toString();
+    }
+
+    private void setMainJarName() {
+        ResourceInfo mainJar = javaParameters.getMainJar();
+        String resourceName = getResourceNameOfMainJar(mainJar);
+        mainJar.setRes(resourceName);
+        javaParameters.setMainJar(mainJar);
+    }
+
+    /**
+     * @description: Construct a shell command for the java -jar Run mode
+     * @date: 7/22/22 2:36 AM
+     * @param: []
+     * @return: java.lang.String
+     **/
+    protected String buildJarCommand() {
+        String fullName = javaParameters.getMainJar().getResourceName();
+        String mainJarName = fullName.substring(0, fullName.lastIndexOf('.'));
+        mainJarName = mainJarName.substring(mainJarName.lastIndexOf('.') + 1) + ".jar";
+        StringBuilder builder = new StringBuilder();
+        builder.append(getJavaCommandPath())
+                .append("java").append(" ")
+                .append(buildResourcePath()).append(" ")
+                .append("-jar").append(" ")
+                .append(taskRequest.getExecutePath())
+                .append(mainJarName).append(" ")
+                .append(javaParameters.getMainArgs().trim()).append(" ")
+                .append(javaParameters.getJvmArgs().trim());
+        return builder.toString();
+    }
+
+    private String getResourceNameOfMainJar(ResourceInfo mainJar) {
+        if (null == mainJar) {
+            throw new RuntimeException("The jar for the task is required.");
+        }
+
+        return mainJar.getId() == 0
+                ? mainJar.getRes()
+                // when update resource maybe has error
+                : mainJar.getResourceName().replaceFirst("/", "");
+    }
+
+    @Override
+    public void cancelApplication(boolean cancelApplication) throws Exception {
+        // cancel process
+        shellCommandExecutor.cancelApplication();
+    }
+
+    @Override
+    public AbstractParameters getParameters() {
+        return javaParameters;
+    }
+
+    /**
+     * @description: Replaces placeholders such as local variables in source files
+     * @date: 7/22/22 2:36 AM
+     * @param: [java.lang.String]
+     * @return: java.lang.String
+     **/
+    protected static String convertJavaSourceCodePlaceholders(String rawScript) throws StringIndexOutOfBoundsException {
+        int len = "${setShareVar(${".length();
+        int scriptStart = 0;
+        while ((scriptStart = rawScript.indexOf("${setShareVar(${", scriptStart)) != -1) {
+            int start = -1;
+            int end = rawScript.indexOf('}', scriptStart + len);
+            String prop = rawScript.substring(scriptStart + len, end);
+
+            start = rawScript.indexOf(',', end);
+            end = rawScript.indexOf(')', start);
+
+            String value = rawScript.substring(start + 1, end);
+
+            start = rawScript.indexOf('}', start) + 1;
+            end = rawScript.length();
+
+            String replaceScript = String.format("print(\"${{setValue({},{})}}\".format(\"%s\",%s))", prop, value);
+
+            rawScript = rawScript.substring(0, scriptStart) + replaceScript + rawScript.substring(start, end);
+
+            scriptStart += replaceScript.length();
+        }
+        return rawScript;
+    }
+
+    /**
+     * @description: Creates a Java source file when it does not exist
+     * @date: 7/22/22 2:36 AM
+     * @param: [java.lang.String, java.lang.String]
+     * @return: java.lang.String
+     **/
+    protected void createJavaSourceFileIfNotExists(String sourceCode, String fileName) throws IOException {
+        logger.info("tenantCode :{}, task dir:{}", taskRequest.getTenantCode(), taskRequest.getExecutePath());

Review Comment:
   ```suggestion
           logger.info("tenantCode: {}, task dir: {}", taskRequest.getTenantCode(), taskRequest.getExecutePath());
   ```



##########
dolphinscheduler-task-plugin/dolphinscheduler-task-java/src/main/java/org/apache/dolphinscheduler/plugin/task/java/JavaTask.java:
##########
@@ -0,0 +1,438 @@
+/*
+ * 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 static org.apache.dolphinscheduler.plugin.task.java.JavaConstants.JAVA_HOME_VAR;
+import static org.apache.dolphinscheduler.plugin.task.java.JavaConstants.PUBLIC_CLASS_NAME_REGEX;
+
+import org.apache.dolphinscheduler.plugin.task.api.AbstractTaskExecutor;
+import org.apache.dolphinscheduler.plugin.task.api.ShellCommandExecutor;
+import org.apache.dolphinscheduler.plugin.task.api.TaskConstants;
+import org.apache.dolphinscheduler.plugin.task.api.TaskException;
+import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext;
+import org.apache.dolphinscheduler.plugin.task.api.model.Property;
+import org.apache.dolphinscheduler.plugin.task.api.model.ResourceInfo;
+import org.apache.dolphinscheduler.plugin.task.api.model.TaskResponse;
+import org.apache.dolphinscheduler.plugin.task.api.parameters.AbstractParameters;
+import org.apache.dolphinscheduler.plugin.task.api.parser.ParamUtils;
+import org.apache.dolphinscheduler.plugin.task.api.parser.ParameterUtils;
+import org.apache.dolphinscheduler.plugin.task.api.utils.MapUtils;
+import org.apache.dolphinscheduler.plugin.task.java.exception.JavaSourceFileExistException;
+import org.apache.dolphinscheduler.plugin.task.java.exception.PublicClassNotFoundException;
+import org.apache.dolphinscheduler.plugin.task.java.exception.RunTypeNotFoundException;
+import org.apache.dolphinscheduler.spi.utils.JSONUtils;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.lang3.SystemUtils;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import com.google.common.base.Preconditions;
+
+/**
+ * java task
+ */
+public class JavaTask extends AbstractTaskExecutor {
+
+    /**
+     * Contains various parameters for this task
+     */
+    private JavaParameters javaParameters;
+
+    /**
+     * To run shell commands
+     */
+    private ShellCommandExecutor shellCommandExecutor;
+
+    /**
+     * task execution context
+     */
+    private TaskExecutionContext taskRequest;
+
+    /**
+     * class name regex pattern
+     */
+    private static final Pattern classNamePattern = Pattern.compile(PUBLIC_CLASS_NAME_REGEX);
+
+    /**
+     * @description: Construct a Java task
+     * @date: 7/22/22 2:36 AM
+     * @param: [org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext]
+     * @return: JavaTask
+     **/
+    public JavaTask(TaskExecutionContext taskRequest) {
+        super(taskRequest);
+        this.taskRequest = taskRequest;
+        this.shellCommandExecutor = new ShellCommandExecutor(this::logHandle,
+                taskRequest,
+                logger);
+    }
+
+    /**
+     * @description: Initializes a Java task
+     * @date: 7/22/22 2:36 AM
+     * @param: []
+     * @return: void
+     **/
+    @Override
+    public void init() {
+        logger.info("java task params {}", taskRequest.getTaskParams());
+        javaParameters = JSONUtils.parseObject(taskRequest.getTaskParams(), JavaParameters.class);
+        if (javaParameters == null || !javaParameters.checkParameters()) {
+            throw new TaskException("java task params is not valid");
+        }
+        if (javaParameters.getRunType().equals(JavaConstants.RUN_TYPE_JAR)) {
+            setMainJarName();
+        }
+    }
+
+    /**
+     * @description: Gets the Java source file that was initially processed
+     * @date: 7/22/22 2:36 AM
+     * @param: []
+     * @return: java.lang.String
+     **/
+    @Override
+    public String getPreScript() {
+        String rawJavaScript = javaParameters.getRawScript().replaceAll("\\r\\n", "\n");
+        try {
+            rawJavaScript = convertJavaSourceCodePlaceholders(rawJavaScript);
+        } catch (StringIndexOutOfBoundsException e) {
+            logger.error("setShareVar field format error, raw java script : {}", rawJavaScript);
+        }
+        return rawJavaScript;
+    }
+
+    /**
+     * @description: Execute Java tasks
+     * @date: 7/22/22 2:36 AM
+     * @param: []
+     * @return: void
+     **/
+    @Override
+    public void handle() throws Exception {
+        try {
+            // Step 1: judge if is java or jar run type.
+            // Step 2 case1: The jar run type builds the command directly, adding resource to the java -jar class when building the command
+            // Step 2 case2: The java run type, first replace the custom parameters, then compile the code, and then build the command will add resource
+            // Step 3: To run the command
+            String command = null;
+            switch (javaParameters.getRunType()) {
+                case JavaConstants.RUN_TYPE_JAVA:
+                    command = buildJavaCommand();
+                    break;
+                case JavaConstants.RUN_TYPE_JAR:
+                    command = buildJarCommand();
+                    break;
+                default:
+                    throw new RunTypeNotFoundException("run type is required, but it is null now.");
+            }
+            Preconditions.checkNotNull(command, "command not be null.");
+            TaskResponse taskResponse = shellCommandExecutor.run(command);
+            logger.info("java task run result : {}", taskResponse);
+            setExitStatusCode(taskResponse.getExitStatusCode());
+            setAppIds(taskResponse.getAppIds());
+            setProcessId(taskResponse.getProcessId());
+            setVarPool(shellCommandExecutor.getVarPool());
+        } catch (InterruptedException e) {
+            logger.error("java task interrupted ", e);
+            setExitStatusCode(TaskConstants.EXIT_CODE_FAILURE);
+            Thread.currentThread().interrupt();
+        } catch (RunTypeNotFoundException e) {
+            logger.error(e.getMessage());
+            setExitStatusCode(TaskConstants.EXIT_CODE_FAILURE);
+            throw e;
+        } catch (Exception e) {
+            logger.error("java task failed ", e);
+            setExitStatusCode(TaskConstants.EXIT_CODE_FAILURE);
+            throw new TaskException("run java task error", e);
+        }
+    }
+
+    /**
+     * @description: Construct a shell command for the java Run mode
+     * @date: 7/22/22 2:36 AM
+     * @param: []
+     * @return: java.lang.String
+     **/
+    protected String buildJavaCommand() throws Exception {
+        String sourceCode = buildJavaSourceContent();
+        String className = compilerRawScript(sourceCode);
+        StringBuilder builder = new StringBuilder();
+        builder.append(getJavaCommandPath())
+                .append("java").append(" ")
+                .append(buildResourcePath())
+                .append(" ")
+                .append(className).append(" ")
+                .append(javaParameters.getMainArgs().trim()).append(" ")
+                .append(javaParameters.getJvmArgs().trim());
+        return builder.toString();
+    }
+
+    private void setMainJarName() {
+        ResourceInfo mainJar = javaParameters.getMainJar();
+        String resourceName = getResourceNameOfMainJar(mainJar);
+        mainJar.setRes(resourceName);
+        javaParameters.setMainJar(mainJar);
+    }
+
+    /**
+     * @description: Construct a shell command for the java -jar Run mode
+     * @date: 7/22/22 2:36 AM
+     * @param: []
+     * @return: java.lang.String
+     **/
+    protected String buildJarCommand() {
+        String fullName = javaParameters.getMainJar().getResourceName();
+        String mainJarName = fullName.substring(0, fullName.lastIndexOf('.'));
+        mainJarName = mainJarName.substring(mainJarName.lastIndexOf('.') + 1) + ".jar";
+        StringBuilder builder = new StringBuilder();
+        builder.append(getJavaCommandPath())
+                .append("java").append(" ")
+                .append(buildResourcePath()).append(" ")
+                .append("-jar").append(" ")
+                .append(taskRequest.getExecutePath())
+                .append(mainJarName).append(" ")
+                .append(javaParameters.getMainArgs().trim()).append(" ")
+                .append(javaParameters.getJvmArgs().trim());
+        return builder.toString();
+    }
+
+    private String getResourceNameOfMainJar(ResourceInfo mainJar) {
+        if (null == mainJar) {
+            throw new RuntimeException("The jar for the task is required.");
+        }
+
+        return mainJar.getId() == 0
+                ? mainJar.getRes()
+                // when update resource maybe has error
+                : mainJar.getResourceName().replaceFirst("/", "");
+    }
+
+    @Override
+    public void cancelApplication(boolean cancelApplication) throws Exception {
+        // cancel process
+        shellCommandExecutor.cancelApplication();
+    }
+
+    @Override
+    public AbstractParameters getParameters() {
+        return javaParameters;
+    }
+
+    /**
+     * @description: Replaces placeholders such as local variables in source files
+     * @date: 7/22/22 2:36 AM
+     * @param: [java.lang.String]
+     * @return: java.lang.String
+     **/
+    protected static String convertJavaSourceCodePlaceholders(String rawScript) throws StringIndexOutOfBoundsException {
+        int len = "${setShareVar(${".length();
+        int scriptStart = 0;
+        while ((scriptStart = rawScript.indexOf("${setShareVar(${", scriptStart)) != -1) {
+            int start = -1;
+            int end = rawScript.indexOf('}', scriptStart + len);
+            String prop = rawScript.substring(scriptStart + len, end);
+
+            start = rawScript.indexOf(',', end);
+            end = rawScript.indexOf(')', start);
+
+            String value = rawScript.substring(start + 1, end);
+
+            start = rawScript.indexOf('}', start) + 1;
+            end = rawScript.length();
+
+            String replaceScript = String.format("print(\"${{setValue({},{})}}\".format(\"%s\",%s))", prop, value);
+
+            rawScript = rawScript.substring(0, scriptStart) + replaceScript + rawScript.substring(start, end);
+
+            scriptStart += replaceScript.length();
+        }
+        return rawScript;
+    }
+
+    /**
+     * @description: Creates a Java source file when it does not exist
+     * @date: 7/22/22 2:36 AM
+     * @param: [java.lang.String, java.lang.String]
+     * @return: java.lang.String
+     **/
+    protected void createJavaSourceFileIfNotExists(String sourceCode, String fileName) throws IOException {
+        logger.info("tenantCode :{}, task dir:{}", taskRequest.getTenantCode(), taskRequest.getExecutePath());
+
+        if (!Files.exists(Paths.get(fileName))) {
+            logger.info("generate java source file:{}", fileName);
+
+            StringBuilder sb = new StringBuilder();
+            sb.append(sourceCode);
+            logger.info(sb.toString());
+
+            // write data to file
+            FileUtils.writeStringToFile(new File(fileName),
+                    sb.toString(),
+                    StandardCharsets.UTF_8);
+        } else {
+            throw new JavaSourceFileExistException("java source file exists, please report an issue on official.");
+        }
+    }
+
+    /**
+     * @description: Construct the full path name of the Java source file from the temporary execution path of the task
+     * @date: 7/22/22 2:36 AM
+     * @param: []
+     * @return: java.lang.String
+     **/
+    protected String buildJavaSourceCodeFileFullName(String publicClassName) {
+        return String.format(JavaConstants.JAVA_SOURCE_CODE_NAME_TEMPLATE, taskRequest.getExecutePath(), publicClassName);
+    }
+
+    /**
+     * @description: Construct a Classpath or module path based on isModulePath
+     * @date: 7/22/22 2:36 AM
+     * @param: []
+     * @return: java.lang.String
+     **/
+    protected String buildResourcePath() {
+        StringBuilder builder = new StringBuilder();
+        if (javaParameters.isModulePath()) {
+            builder.append("--module-path");
+        } else {
+            builder.append("--class-path");
+        }
+        builder.append(" ").append(JavaConstants.CLASSPATH_CURRENT_DIR)
+                .append(JavaConstants.PATH_SEPARATOR)
+                .append(taskRequest.getExecutePath());
+        for (ResourceInfo info : javaParameters.getResourceFilesList()) {
+            builder.append(JavaConstants.PATH_SEPARATOR);
+            builder.append(taskRequest.getExecutePath())
+                    .append(info.getResourceName());
+        }
+        return builder.toString();
+    }
+
+    /**
+     * @description: Compile the Java source file
+     * @date: 7/22/22 2:36 AM
+     * @param: [java.lang.String]
+     * @return: java.lang.String
+     **/
+    protected String compilerRawScript(String sourceCode) throws IOException, InterruptedException {
+        String publicClassName = getPublicClassName(sourceCode);
+        String fileName =  buildJavaSourceCodeFileFullName(publicClassName);
+        createJavaSourceFileIfNotExists(sourceCode, fileName);
+        String compileCommand = buildJavaCompileCommand(fileName, sourceCode);
+        Preconditions.checkNotNull(compileCommand, "command not be null.");
+        TaskResponse compileResponse = shellCommandExecutor.run(compileCommand);
+        // must drop the command file ,if do not ,the next command will not run. because be limited the ShellCommandExecutor's create file rules
+        dropShellCommandFile();
+        shellCommandExecutor = new ShellCommandExecutor(this::logHandle,
+                taskRequest,
+                logger);
+        logger.info("java task code compile result : " + compileResponse);

Review Comment:
   ```suggestion
           logger.info("java task code compile result: " + compileResponse);
   ```



##########
dolphinscheduler-task-plugin/dolphinscheduler-task-java/src/main/java/org/apache/dolphinscheduler/plugin/task/java/JavaTask.java:
##########
@@ -0,0 +1,438 @@
+/*
+ * 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 static org.apache.dolphinscheduler.plugin.task.java.JavaConstants.JAVA_HOME_VAR;
+import static org.apache.dolphinscheduler.plugin.task.java.JavaConstants.PUBLIC_CLASS_NAME_REGEX;
+
+import org.apache.dolphinscheduler.plugin.task.api.AbstractTaskExecutor;
+import org.apache.dolphinscheduler.plugin.task.api.ShellCommandExecutor;
+import org.apache.dolphinscheduler.plugin.task.api.TaskConstants;
+import org.apache.dolphinscheduler.plugin.task.api.TaskException;
+import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext;
+import org.apache.dolphinscheduler.plugin.task.api.model.Property;
+import org.apache.dolphinscheduler.plugin.task.api.model.ResourceInfo;
+import org.apache.dolphinscheduler.plugin.task.api.model.TaskResponse;
+import org.apache.dolphinscheduler.plugin.task.api.parameters.AbstractParameters;
+import org.apache.dolphinscheduler.plugin.task.api.parser.ParamUtils;
+import org.apache.dolphinscheduler.plugin.task.api.parser.ParameterUtils;
+import org.apache.dolphinscheduler.plugin.task.api.utils.MapUtils;
+import org.apache.dolphinscheduler.plugin.task.java.exception.JavaSourceFileExistException;
+import org.apache.dolphinscheduler.plugin.task.java.exception.PublicClassNotFoundException;
+import org.apache.dolphinscheduler.plugin.task.java.exception.RunTypeNotFoundException;
+import org.apache.dolphinscheduler.spi.utils.JSONUtils;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.lang3.SystemUtils;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import com.google.common.base.Preconditions;
+
+/**
+ * java task
+ */
+public class JavaTask extends AbstractTaskExecutor {
+
+    /**
+     * Contains various parameters for this task
+     */
+    private JavaParameters javaParameters;
+
+    /**
+     * To run shell commands
+     */
+    private ShellCommandExecutor shellCommandExecutor;
+
+    /**
+     * task execution context
+     */
+    private TaskExecutionContext taskRequest;
+
+    /**
+     * class name regex pattern
+     */
+    private static final Pattern classNamePattern = Pattern.compile(PUBLIC_CLASS_NAME_REGEX);
+
+    /**
+     * @description: Construct a Java task
+     * @date: 7/22/22 2:36 AM
+     * @param: [org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext]
+     * @return: JavaTask
+     **/
+    public JavaTask(TaskExecutionContext taskRequest) {
+        super(taskRequest);
+        this.taskRequest = taskRequest;
+        this.shellCommandExecutor = new ShellCommandExecutor(this::logHandle,
+                taskRequest,
+                logger);
+    }
+
+    /**
+     * @description: Initializes a Java task
+     * @date: 7/22/22 2:36 AM
+     * @param: []
+     * @return: void
+     **/
+    @Override
+    public void init() {
+        logger.info("java task params {}", taskRequest.getTaskParams());
+        javaParameters = JSONUtils.parseObject(taskRequest.getTaskParams(), JavaParameters.class);
+        if (javaParameters == null || !javaParameters.checkParameters()) {
+            throw new TaskException("java task params is not valid");
+        }
+        if (javaParameters.getRunType().equals(JavaConstants.RUN_TYPE_JAR)) {
+            setMainJarName();
+        }
+    }
+
+    /**
+     * @description: Gets the Java source file that was initially processed
+     * @date: 7/22/22 2:36 AM
+     * @param: []
+     * @return: java.lang.String
+     **/
+    @Override
+    public String getPreScript() {
+        String rawJavaScript = javaParameters.getRawScript().replaceAll("\\r\\n", "\n");
+        try {
+            rawJavaScript = convertJavaSourceCodePlaceholders(rawJavaScript);
+        } catch (StringIndexOutOfBoundsException e) {
+            logger.error("setShareVar field format error, raw java script : {}", rawJavaScript);
+        }
+        return rawJavaScript;
+    }
+
+    /**
+     * @description: Execute Java tasks
+     * @date: 7/22/22 2:36 AM
+     * @param: []
+     * @return: void
+     **/
+    @Override
+    public void handle() throws Exception {
+        try {
+            // Step 1: judge if is java or jar run type.
+            // Step 2 case1: The jar run type builds the command directly, adding resource to the java -jar class when building the command
+            // Step 2 case2: The java run type, first replace the custom parameters, then compile the code, and then build the command will add resource
+            // Step 3: To run the command
+            String command = null;
+            switch (javaParameters.getRunType()) {
+                case JavaConstants.RUN_TYPE_JAVA:
+                    command = buildJavaCommand();
+                    break;
+                case JavaConstants.RUN_TYPE_JAR:
+                    command = buildJarCommand();
+                    break;
+                default:
+                    throw new RunTypeNotFoundException("run type is required, but it is null now.");
+            }
+            Preconditions.checkNotNull(command, "command not be null.");
+            TaskResponse taskResponse = shellCommandExecutor.run(command);
+            logger.info("java task run result : {}", taskResponse);
+            setExitStatusCode(taskResponse.getExitStatusCode());
+            setAppIds(taskResponse.getAppIds());
+            setProcessId(taskResponse.getProcessId());
+            setVarPool(shellCommandExecutor.getVarPool());
+        } catch (InterruptedException e) {
+            logger.error("java task interrupted ", e);
+            setExitStatusCode(TaskConstants.EXIT_CODE_FAILURE);
+            Thread.currentThread().interrupt();
+        } catch (RunTypeNotFoundException e) {
+            logger.error(e.getMessage());
+            setExitStatusCode(TaskConstants.EXIT_CODE_FAILURE);
+            throw e;
+        } catch (Exception e) {
+            logger.error("java task failed ", e);
+            setExitStatusCode(TaskConstants.EXIT_CODE_FAILURE);
+            throw new TaskException("run java task error", e);
+        }
+    }
+
+    /**
+     * @description: Construct a shell command for the java Run mode
+     * @date: 7/22/22 2:36 AM
+     * @param: []
+     * @return: java.lang.String
+     **/
+    protected String buildJavaCommand() throws Exception {
+        String sourceCode = buildJavaSourceContent();
+        String className = compilerRawScript(sourceCode);
+        StringBuilder builder = new StringBuilder();
+        builder.append(getJavaCommandPath())
+                .append("java").append(" ")
+                .append(buildResourcePath())
+                .append(" ")
+                .append(className).append(" ")
+                .append(javaParameters.getMainArgs().trim()).append(" ")
+                .append(javaParameters.getJvmArgs().trim());
+        return builder.toString();
+    }
+
+    private void setMainJarName() {
+        ResourceInfo mainJar = javaParameters.getMainJar();
+        String resourceName = getResourceNameOfMainJar(mainJar);
+        mainJar.setRes(resourceName);
+        javaParameters.setMainJar(mainJar);
+    }
+
+    /**
+     * @description: Construct a shell command for the java -jar Run mode
+     * @date: 7/22/22 2:36 AM
+     * @param: []
+     * @return: java.lang.String
+     **/
+    protected String buildJarCommand() {
+        String fullName = javaParameters.getMainJar().getResourceName();
+        String mainJarName = fullName.substring(0, fullName.lastIndexOf('.'));
+        mainJarName = mainJarName.substring(mainJarName.lastIndexOf('.') + 1) + ".jar";
+        StringBuilder builder = new StringBuilder();
+        builder.append(getJavaCommandPath())
+                .append("java").append(" ")
+                .append(buildResourcePath()).append(" ")
+                .append("-jar").append(" ")
+                .append(taskRequest.getExecutePath())
+                .append(mainJarName).append(" ")
+                .append(javaParameters.getMainArgs().trim()).append(" ")
+                .append(javaParameters.getJvmArgs().trim());
+        return builder.toString();
+    }
+
+    private String getResourceNameOfMainJar(ResourceInfo mainJar) {
+        if (null == mainJar) {
+            throw new RuntimeException("The jar for the task is required.");
+        }
+
+        return mainJar.getId() == 0
+                ? mainJar.getRes()
+                // when update resource maybe has error
+                : mainJar.getResourceName().replaceFirst("/", "");
+    }
+
+    @Override
+    public void cancelApplication(boolean cancelApplication) throws Exception {
+        // cancel process
+        shellCommandExecutor.cancelApplication();
+    }
+
+    @Override
+    public AbstractParameters getParameters() {
+        return javaParameters;
+    }
+
+    /**
+     * @description: Replaces placeholders such as local variables in source files
+     * @date: 7/22/22 2:36 AM
+     * @param: [java.lang.String]
+     * @return: java.lang.String
+     **/
+    protected static String convertJavaSourceCodePlaceholders(String rawScript) throws StringIndexOutOfBoundsException {
+        int len = "${setShareVar(${".length();
+        int scriptStart = 0;
+        while ((scriptStart = rawScript.indexOf("${setShareVar(${", scriptStart)) != -1) {
+            int start = -1;
+            int end = rawScript.indexOf('}', scriptStart + len);
+            String prop = rawScript.substring(scriptStart + len, end);
+
+            start = rawScript.indexOf(',', end);
+            end = rawScript.indexOf(')', start);
+
+            String value = rawScript.substring(start + 1, end);
+
+            start = rawScript.indexOf('}', start) + 1;
+            end = rawScript.length();
+
+            String replaceScript = String.format("print(\"${{setValue({},{})}}\".format(\"%s\",%s))", prop, value);
+
+            rawScript = rawScript.substring(0, scriptStart) + replaceScript + rawScript.substring(start, end);
+
+            scriptStart += replaceScript.length();
+        }
+        return rawScript;
+    }
+
+    /**
+     * @description: Creates a Java source file when it does not exist
+     * @date: 7/22/22 2:36 AM
+     * @param: [java.lang.String, java.lang.String]
+     * @return: java.lang.String
+     **/
+    protected void createJavaSourceFileIfNotExists(String sourceCode, String fileName) throws IOException {
+        logger.info("tenantCode :{}, task dir:{}", taskRequest.getTenantCode(), taskRequest.getExecutePath());
+
+        if (!Files.exists(Paths.get(fileName))) {
+            logger.info("generate java source file:{}", fileName);

Review Comment:
   ```suggestion
               logger.info("generate java source file: {}", fileName);
   ```



-- 
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


[GitHub] [dolphinscheduler] 106umao commented on pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
106umao commented on PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#issuecomment-1193270364

   Hi @zhuangchong @SbloodyS @Amy0104 
   please help me restart CI 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


[GitHub] [dolphinscheduler] sonarcloud[bot] commented on pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
sonarcloud[bot] commented on PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#issuecomment-1231117618

   SonarCloud Quality Gate failed.&nbsp; &nbsp; [![Quality Gate failed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/failed-16px.png 'Quality Gate failed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=10689)
   
   [![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png 'Bug')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG)  
   [![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png 'Vulnerability')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY)  
   [![Security Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png 'Security Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT)  
   [![Code Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png 'Code Smell')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL) [8 Code Smells](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL)
   
   [![0.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/0-16px.png '0.0%')](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_coverage&view=list) [0.0% Coverage](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_coverage&view=list)  
   [![2.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3-16px.png '2.0%')](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_duplicated_lines_density&view=list) [2.0% Duplication](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_duplicated_lines_density&view=list)
   
   


-- 
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


[GitHub] [dolphinscheduler] zhongjiajie commented on a diff in pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
zhongjiajie commented on code in PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#discussion_r914393150


##########
docs/docs/zh/guide/task/java.md:
##########
@@ -0,0 +1,50 @@
+# JAVA 节点
+
+## 综述
+
+该节点用于执行 java 类型的任务,支持使用单文件和jar包作为程序入口。
+
+## 创建任务
+
+- 点击项目管理 -> 项目名称 -> 工作流定义,点击”创建工作流”按钮,进入 DAG 编辑页面:
+
+- 拖动工具栏的JAVA任务节点到画板中。
+
+## 任务参数
+
+- 节点名称:设置任务的名称。一个工作流定义中的节点名称是唯一的。
+- 运行标志:标识这个节点是否能正常调度,如果不需要执行,可以打开禁止执行开关。
+- 描述:描述该节点的功能。
+- 任务优先级:worker 线程数不足时,根据优先级从高到低依次执行,优先级一样时根据先进先出原则执行。
+- Worker 分组:任务分配给 worker 组的机器机执行,选择 Default,会随机选择一台 worker 机执行。
+- 环境名称:配置运行任务的环境。
+- 失败重试次数:任务失败重新提交的次数,支持下拉和手填。
+- 失败重试间隔:任务失败重新提交任务的时间间隔,支持下拉和手填。
+- 延迟执行时间:任务延迟执行的时间,以分为单位。
+- 超时告警:勾选超时告警、超时失败,当任务超过"超时时长"后,会发送告警邮件并且任务执行失败。
+- 模块路劲:开启使用JAVA9+的模块化特性,把所有资源放入--module-path中,要求您的worker中的JDK版本支持模块化。
+- 主程序参数:作为普通Java程序main方法入口参数。
+- 虚拟机参数:配置启动虚拟机参数。
+- 脚本:若使用JAVA运行类型则需要编写JAVA代码。代码中必须存在public类,不用写package语句。
+- 资源:可以是外部JAR包也可以是其他资源文件,它们都会被加入到类路径或模块路径中,您可以在自己的JAVA脚本中轻松获取。
+- 自定义参数:是 http 局部的用户自定义参数,会替换脚本中以 ${变量} 的内容。
+- 前置任务:选择当前任务的前置任务,会将被选择的前置任务设置为当前任务的上游。
+
+## 任务样例
+
+HTTP 定义了与服务器交互的不同方法,最基本的方法有4种,分别是GET,POST,PUT,DELETE。这里我们使用 http 任务节点,演示使用 POST 向系统的登录页面发送请求,提交数据。
+
+主要配置参数如下:
+
+- 运行类型
+- 模块路径
+- 主程序参数
+- 虚拟机参数
+- 脚本文件
+
+![java_task](../../../../img/tasks/demo/java_task01.png)

Review Comment:
   both English and Chinese documents should use the English version screenshot



##########
docs/docs/en/guide/task/java.md:
##########
@@ -0,0 +1,67 @@
+# Overview
+
+This node is used to perform java-type tasks and supports the use of single files and jar packages as program entries.
+
+# Create Tasks
+
+- Click on project management-> Project name-> workflow definition, click on the“Create workflow” button, go to the DAG edit page:
+
+- Drag the toolbar's Java task node to the palette.
+
+# Task Parameters
+
+- Node Name: the name of the set task. The node name in a workflow definition is unique.
+
+- Run Flag: indicates whether the node is scheduled properly and, if it is not needed, turns on the kill switch.
+
+- Description: describes the functionality of the node.
+
+- Task Priority: when the number of worker threads is insufficient, the worker is executed according to the priority from high to low. When the priority is the same, the worker is executed according to the first in, first out principle.
+
+- Worker Group: The machine whose task is assigned to the Worker group executes, and selecting Default will randomly select a Worker machine to execute.
+
+- Environment Name: configure the environment in which the task runs.
+
+- Number Of Failed Retries: number of resubmitted tasks that failed, supported drop-down and hand-fill.
+
+- Failed Retry Interval: the interval between tasks that fail and are resubmitted, supported by drop-down and hand-fill.
+
+- Delayed Execution Time: the amount of time a task is delayed, in units.
+
+- Timeout Alarm: Check timeout warning, timeout failure, when the task exceeds the“Timeout length”, send a warning message and the task execution fails.
+
+- Module Path: turn on the use of Java 9 + 's modularity feature, put all resources into-module-path, and require that the JDK version in your worker support modularity.
+
+- Main Parameter: as a normal Java program main method entry parameter.
+
+- Java VM Parameters: configure startup virtual machine parameters.
+
+- Script: you need to write Java code if you use the Java run type. The public class must exist in the code without writing a package statement.
+
+- Resources: these can be external JAR packages or other resource files that are added to the Classpath or module path and can be easily retrieved in your JAVA script.
+
+- Custom parameter: a user-defined parameter that is part of HTTP and replaces the contents of the script with the ${ variable } .
+
+- Pre Tasks: selecting a pre-task for the current task sets the selected pre-task upstream of the current task.
+
+## Example
+
+HTTP defines the different methods of interacting with the server, and the four most basic methods are GET, POST, PUT, and DELETE. Here we use the HTTP task node to demonstrate the use of POST to send a request to the system's login page and submit data.
+
+The main configuration parameters are as follows:
+
+- Run Type
+

Review Comment:
   redundant blank line too



##########
docs/docs/en/guide/task/java.md:
##########
@@ -0,0 +1,67 @@
+# Overview
+
+This node is used to perform java-type tasks and supports the use of single files and jar packages as program entries.
+
+# Create Tasks
+
+- Click on project management-> Project name-> workflow definition, click on the“Create workflow” button, go to the DAG edit page:
+
+- Drag the toolbar's Java task node to the palette.
+
+# Task Parameters
+
+- Node Name: the name of the set task. The node name in a workflow definition is unique.
+
+- Run Flag: indicates whether the node is scheduled properly and, if it is not needed, turns on the kill switch.
+
+- Description: describes the functionality of the node.
+
+- Task Priority: when the number of worker threads is insufficient, the worker is executed according to the priority from high to low. When the priority is the same, the worker is executed according to the first in, first out principle.
+
+- Worker Group: The machine whose task is assigned to the Worker group executes, and selecting Default will randomly select a Worker machine to execute.
+
+- Environment Name: configure the environment in which the task runs.
+
+- Number Of Failed Retries: number of resubmitted tasks that failed, supported drop-down and hand-fill.
+
+- Failed Retry Interval: the interval between tasks that fail and are resubmitted, supported by drop-down and hand-fill.
+
+- Delayed Execution Time: the amount of time a task is delayed, in units.
+
+- Timeout Alarm: Check timeout warning, timeout failure, when the task exceeds the“Timeout length”, send a warning message and the task execution fails.
+
+- Module Path: turn on the use of Java 9 + 's modularity feature, put all resources into-module-path, and require that the JDK version in your worker support modularity.
+
+- Main Parameter: as a normal Java program main method entry parameter.
+
+- Java VM Parameters: configure startup virtual machine parameters.
+
+- Script: you need to write Java code if you use the Java run type. The public class must exist in the code without writing a package statement.
+
+- Resources: these can be external JAR packages or other resource files that are added to the Classpath or module path and can be easily retrieved in your JAVA script.
+
+- Custom parameter: a user-defined parameter that is part of HTTP and replaces the contents of the script with the ${ variable } .
+
+- Pre Tasks: selecting a pre-task for the current task sets the selected pre-task upstream of the current task.
+
+## Example
+
+HTTP defines the different methods of interacting with the server, and the four most basic methods are GET, POST, PUT, and DELETE. Here we use the HTTP task node to demonstrate the use of POST to send a request to the system's login page and submit data.
+
+The main configuration parameters are as follows:
+
+- Run Type
+
+- Module Path
+
+- Main Parameters
+
+- Java VM Parameters
+
+- Script 
+
+![java_task](../../../../img/tasks/demo/java_task02.png)
+
+## Notice

Review Comment:
   ```suggestion
   ## Note
   ```



##########
docs/docs/en/guide/task/java.md:
##########
@@ -0,0 +1,67 @@
+# Overview
+
+This node is used to perform java-type tasks and supports the use of single files and jar packages as program entries.
+
+# Create Tasks
+
+- Click on project management-> Project name-> workflow definition, click on the“Create workflow” button, go to the DAG edit page:
+
+- Drag the toolbar's Java task node to the palette.
+
+# Task Parameters
+
+- Node Name: the name of the set task. The node name in a workflow definition is unique.
+

Review Comment:
   please remove the redundant blank line 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


[GitHub] [dolphinscheduler] 106umao commented on a diff in pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
106umao commented on code in PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#discussion_r915776033


##########
dolphinscheduler-task-plugin/dolphinscheduler-task-java/src/main/java/org/apache/dolphinscheduler/plugin/task/java/JavaConstants.java:
##########
@@ -0,0 +1,46 @@
+/*
+ * 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;
+
+public class JavaConstants {
+
+    private JavaConstants() {
+        throw new IllegalStateException("Utility class");
+    }
+
+    public static final String JAVA_HOME = "JAVA_HOME";
+
+
+    public static final String RUN_TYPE_JAVA = "JAVA";
+    public static final String RUN_TYPE_JAR = "JAR";
+
+//    to be extended.
+//    public static final String RUN_TYPE_JSHELL = "JSHELL";
+//    public static final String RUN_TYPE_INJVM = "INJVM";
+
+
+

Review Comment:
   thx, it is done



-- 
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


[GitHub] [dolphinscheduler] 106umao commented on a diff in pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
106umao commented on code in PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#discussion_r915816485


##########
dolphinscheduler-ui/src/locales/en_US/project.ts:
##########
@@ -126,7 +126,6 @@ export default {
     switch_version: 'Switch To This Version',
     confirm_switch_version: 'Confirm Switch To This Version?',
     current_version: 'Current Version',
-    run_type: 'Run Type',

Review Comment:
   > The 'run_type' can not be removed, because it is used in workflow instance column.
   
   thank you. maybe I deleted it by mistake.



-- 
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


[GitHub] [dolphinscheduler] 106umao commented on a diff in pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
106umao commented on code in PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#discussion_r915806595


##########
dolphinscheduler-ui/src/views/projects/task/components/node/fields/use-java.ts:
##########
@@ -0,0 +1,98 @@
+/*
+ * 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.
+ */
+import { computed } from 'vue'
+import { useI18n } from 'vue-i18n'
+import { useCustomParams, useResources ,useMainJar} from '.'
+import type { IJsonItem } from '../types'
+
+export function useJava(model: { [field: string]: any }): IJsonItem[] {
+  const { t } = useI18n()
+  const rawScriptSpan = computed(() => (model.runType === 'JAR' ? 0 : 24))
+  return [
+    {
+        type: 'select',
+        field: 'runType',
+        span: 12,
+        name: t('project.node.run_type'),
+        options: RUN_TYPES,
+        props: {
+          'on-update:value': () => {
+            // if(model.runType=='JAR'){
+            //     model.rawScript=''
+            // }else{
+            //     model.mainJar = null
+            //     model.rawScript=''
+            // }
+          }

Review Comment:
   thx,it is done



-- 
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


[GitHub] [dolphinscheduler] sonarcloud[bot] commented on pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
sonarcloud[bot] commented on PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#issuecomment-1241001332

   SonarCloud Quality Gate failed.&nbsp; &nbsp; [![Quality Gate failed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/failed-16px.png 'Quality Gate failed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=10689)
   
   [![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png 'Bug')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG)  
   [![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png 'Vulnerability')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY)  
   [![Security Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png 'Security Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT)  
   [![Code Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png 'Code Smell')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL) [8 Code Smells](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL)
   
   [![0.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/0-16px.png '0.0%')](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_coverage&view=list) [0.0% Coverage](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_coverage&view=list)  
   [![2.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3-16px.png '2.0%')](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_duplicated_lines_density&view=list) [2.0% Duplication](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_duplicated_lines_density&view=list)
   
   


-- 
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


[GitHub] [dolphinscheduler] sonarcloud[bot] commented on pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
sonarcloud[bot] commented on PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#issuecomment-1201019517

   SonarCloud Quality Gate failed.&nbsp; &nbsp; [![Quality Gate failed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/failed-16px.png 'Quality Gate failed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=10689)
   
   [![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png 'Bug')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG)  
   [![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png 'Vulnerability')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY)  
   [![Security Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png 'Security Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT)  
   [![Code Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png 'Code Smell')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL) [15 Code Smells](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL)
   
   [![0.4%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/0-16px.png '0.4%')](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_coverage&view=list) [0.4% Coverage](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_coverage&view=list)  
   [![1.9%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3-16px.png '1.9%')](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_duplicated_lines_density&view=list) [1.9% Duplication](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_duplicated_lines_density&view=list)
   
   


-- 
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


[GitHub] [dolphinscheduler] kezhenxu94 commented on a diff in pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
kezhenxu94 commented on code in PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#discussion_r935007110


##########
dolphinscheduler-task-plugin/dolphinscheduler-task-java/src/main/java/org/apache/dolphinscheduler/plugin/task/java/JavaConstants.java:
##########
@@ -0,0 +1,67 @@
+/*
+ * 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;
+
+public class JavaConstants {
+
+    private JavaConstants() {
+        throw new IllegalStateException("Utility class");
+    }
+
+    /**
+     * constant ${JAVA_HOME}
+     **/

Review Comment:
   All these comments in this file is meaningless



##########
docs/docs/en/guide/task/java.md:
##########
@@ -0,0 +1,47 @@
+# Overview
+
+This node is for executing java-type tasks and supports using files and jar packages as program entries.
+
+# Create Tasks
+
+- Click on `Project Management` -> `Project Name` -> `Workflow Definition`, click on the“Create workflow” button, go to the DAG edit page:

Review Comment:
   ```suggestion
   - Click on `Project Management` -> `Project Name` -> `Workflow Definition`, click on the “Create workflow” button, go to the DAG edit page:
   ```
   



##########
dolphinscheduler-task-plugin/dolphinscheduler-task-java/src/main/java/org/apache/dolphinscheduler/plugin/task/java/JavaParameters.java:
##########
@@ -0,0 +1,89 @@
+/*
+ * 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 org.apache.dolphinscheduler.plugin.task.api.model.ResourceInfo;
+import org.apache.dolphinscheduler.plugin.task.api.parameters.AbstractParameters;
+
+import java.util.List;
+
+import lombok.Getter;
+import lombok.Setter;
+import lombok.ToString;
+
+@Getter
+@Setter
+@ToString
+public class JavaParameters extends AbstractParameters {
+    /**
+     * origin java script
+     */
+    private String rawScript;
+
+    /**
+     * run in jar file
+     */
+    private ResourceInfo mainJar;
+
+    /**
+     * run type is JAVA or JAR
+     */
+    private String runType;

Review Comment:
   Consider making it an enum type 



##########
dolphinscheduler-task-plugin/dolphinscheduler-task-java/src/main/java/org/apache/dolphinscheduler/plugin/task/java/JavaParameters.java:
##########
@@ -0,0 +1,89 @@
+/*
+ * 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 org.apache.dolphinscheduler.plugin.task.api.model.ResourceInfo;
+import org.apache.dolphinscheduler.plugin.task.api.parameters.AbstractParameters;
+
+import java.util.List;
+
+import lombok.Getter;
+import lombok.Setter;
+import lombok.ToString;
+
+@Getter
+@Setter
+@ToString
+public class JavaParameters extends AbstractParameters {
+    /**
+     * origin java script
+     */
+    private String rawScript;
+
+    /**
+     * run in jar file
+     */
+    private ResourceInfo mainJar;
+
+    /**
+     * run type is JAVA or JAR
+     */
+    private String runType;
+
+    /**
+     * main method args
+     **/
+    private String mainArgs;
+
+    /**
+     * jvm args
+     **/
+    private String jvmArgs;
+
+    /**
+     * module path or class path flag
+     **/
+    private boolean isModulePath;
+
+    /**
+     * resource list
+     */
+    private List<ResourceInfo> resourceList;
+
+    /**
+     * @description:
+     * @date: 7/22/22 2:35 AM
+     * @param: []

Review Comment:
   @zhongjiajie might mean to remove the meaningless comments. @106umao  I comment in other places where the comments are meaningless. Please remove them or reword them to more meaningful comments



##########
dolphinscheduler-task-plugin/dolphinscheduler-task-java/src/main/java/org/apache/dolphinscheduler/plugin/task/java/JavaTask.java:
##########
@@ -0,0 +1,408 @@
+/*
+ * 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 static org.apache.dolphinscheduler.plugin.task.java.JavaConstants.JAVA_HOME_VAR;
+import static org.apache.dolphinscheduler.plugin.task.java.JavaConstants.PUBLIC_CLASS_NAME_REGEX;
+
+import org.apache.dolphinscheduler.plugin.task.api.AbstractTaskExecutor;
+import org.apache.dolphinscheduler.plugin.task.api.ShellCommandExecutor;
+import org.apache.dolphinscheduler.plugin.task.api.TaskConstants;
+import org.apache.dolphinscheduler.plugin.task.api.TaskException;
+import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext;
+import org.apache.dolphinscheduler.plugin.task.api.model.Property;
+import org.apache.dolphinscheduler.plugin.task.api.model.ResourceInfo;
+import org.apache.dolphinscheduler.plugin.task.api.model.TaskResponse;
+import org.apache.dolphinscheduler.plugin.task.api.parameters.AbstractParameters;
+import org.apache.dolphinscheduler.plugin.task.api.parser.ParamUtils;
+import org.apache.dolphinscheduler.plugin.task.api.parser.ParameterUtils;
+import org.apache.dolphinscheduler.plugin.task.api.utils.MapUtils;
+import org.apache.dolphinscheduler.plugin.task.java.exception.JavaSourceFileExistException;
+import org.apache.dolphinscheduler.plugin.task.java.exception.PublicClassNotFoundException;
+import org.apache.dolphinscheduler.plugin.task.java.exception.RunTypeNotFoundException;
+import org.apache.dolphinscheduler.spi.utils.JSONUtils;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.lang3.SystemUtils;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import com.google.common.base.Preconditions;
+
+/**
+ * java task
+ */
+public class JavaTask extends AbstractTaskExecutor {
+
+    /**
+     * java parameters
+     */
+    private JavaParameters javaParameters;
+
+    /**
+     * shell command executor
+     */
+    private ShellCommandExecutor shellCommandExecutor;
+
+    /**
+     * task execution context
+     */
+    private TaskExecutionContext taskRequest;
+
+    /**
+     * class name regex pattern
+     */
+    private static final Pattern classNamePattern = Pattern.compile(PUBLIC_CLASS_NAME_REGEX);
+
+    /**
+     * @description:
+     * @date: 7/22/22 2:36 AM
+     * @param: [org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext]
+     * @return: JavaTask
+     **/
+    public JavaTask(TaskExecutionContext taskRequest) {
+        super(taskRequest);
+        this.taskRequest = taskRequest;
+        this.shellCommandExecutor = new ShellCommandExecutor(this::logHandle,
+                taskRequest,
+                logger);
+    }
+
+    /**
+     * @description:
+     * @date: 7/22/22 2:36 AM
+     * @param: []
+     * @return: void
+     **/
+    @Override
+    public void init() {
+        logger.info("java task params {}", taskRequest.getTaskParams());
+        javaParameters = JSONUtils.parseObject(taskRequest.getTaskParams(), JavaParameters.class);
+        if (javaParameters == null || !javaParameters.checkParameters()) {
+            throw new TaskException("java task params is not valid");
+        }
+        if (javaParameters.getRunType().equals(JavaConstants.RUN_TYPE_JAR)) {
+            setMainJarName();
+        }
+    }
+
+    /**
+     * @description:
+     * @date: 7/22/22 2:36 AM
+     * @param: []
+     * @return: java.lang.String
+     **/
+    @Override
+    public String getPreScript() {
+        String rawJavaScript = javaParameters.getRawScript().replaceAll("\\r\\n", "\n");
+        try {
+            rawJavaScript = convertJavaSourceCodePlaceholders(rawJavaScript);
+        } catch (StringIndexOutOfBoundsException e) {
+            logger.error("setShareVar field format error, raw java script : {}", rawJavaScript);
+        }
+        return rawJavaScript;
+    }
+
+    /**
+     * @description:
+     * @date: 7/22/22 2:36 AM
+     * @param: []
+     * @return: void
+     **/
+    @Override
+    public void handle() throws Exception {
+        try {
+            // Step 1: judge if is java or jar run type.
+            // Step 2 case1: The jar run type builds the command directly, adding resource to the java -jar class when building the command
+            // Step 2 case2: The java run type, first replace the custom parameters, then compile the code, and then build the command will add resource
+            // Step 3: To run the command
+            String command = null;
+            switch (javaParameters.getRunType()) {
+                case JavaConstants.RUN_TYPE_JAVA:
+                    command = buildJavaCommand();
+                    break;
+                case JavaConstants.RUN_TYPE_JAR:
+                    command = buildJarCommand();
+                    break;
+                default:
+                    throw new RunTypeNotFoundException("run type is required, but it is null now.");
+            }
+            Preconditions.checkNotNull(command, "command not be null.");
+            TaskResponse taskResponse = shellCommandExecutor.run(command);
+            logger.info("java task run result : " + taskResponse);

Review Comment:
   ```suggestion
               logger.info("java task run result: {}", taskResponse);
   ```
   



##########
dolphinscheduler-task-plugin/dolphinscheduler-task-java/src/main/java/org/apache/dolphinscheduler/plugin/task/java/JavaTask.java:
##########
@@ -0,0 +1,408 @@
+/*
+ * 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 static org.apache.dolphinscheduler.plugin.task.java.JavaConstants.JAVA_HOME_VAR;
+import static org.apache.dolphinscheduler.plugin.task.java.JavaConstants.PUBLIC_CLASS_NAME_REGEX;
+
+import org.apache.dolphinscheduler.plugin.task.api.AbstractTaskExecutor;
+import org.apache.dolphinscheduler.plugin.task.api.ShellCommandExecutor;
+import org.apache.dolphinscheduler.plugin.task.api.TaskConstants;
+import org.apache.dolphinscheduler.plugin.task.api.TaskException;
+import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext;
+import org.apache.dolphinscheduler.plugin.task.api.model.Property;
+import org.apache.dolphinscheduler.plugin.task.api.model.ResourceInfo;
+import org.apache.dolphinscheduler.plugin.task.api.model.TaskResponse;
+import org.apache.dolphinscheduler.plugin.task.api.parameters.AbstractParameters;
+import org.apache.dolphinscheduler.plugin.task.api.parser.ParamUtils;
+import org.apache.dolphinscheduler.plugin.task.api.parser.ParameterUtils;
+import org.apache.dolphinscheduler.plugin.task.api.utils.MapUtils;
+import org.apache.dolphinscheduler.plugin.task.java.exception.JavaSourceFileExistException;
+import org.apache.dolphinscheduler.plugin.task.java.exception.PublicClassNotFoundException;
+import org.apache.dolphinscheduler.plugin.task.java.exception.RunTypeNotFoundException;
+import org.apache.dolphinscheduler.spi.utils.JSONUtils;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.lang3.SystemUtils;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import com.google.common.base.Preconditions;
+
+/**
+ * java task
+ */
+public class JavaTask extends AbstractTaskExecutor {
+
+    /**
+     * java parameters
+     */
+    private JavaParameters javaParameters;
+
+    /**
+     * shell command executor
+     */

Review Comment:
   Please remove all these useless comments 



-- 
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


[GitHub] [dolphinscheduler] sonarcloud[bot] commented on pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
sonarcloud[bot] commented on PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#issuecomment-1184604392

   SonarCloud Quality Gate failed.&nbsp; &nbsp; [![Quality Gate failed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/failed-16px.png 'Quality Gate failed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=10689)
   
   [![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png 'Bug')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG)  
   [![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png 'Vulnerability')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY)  
   [![Security Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png 'Security Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT)  
   [![Code Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png 'Code Smell')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL) [14 Code Smells](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL)
   
   [![0.4%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/0-16px.png '0.4%')](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_coverage&view=list) [0.4% Coverage](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_coverage&view=list)  
   [![2.2%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3-16px.png '2.2%')](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_duplicated_lines_density&view=list) [2.2% Duplication](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_duplicated_lines_density&view=list)
   
   


-- 
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


[GitHub] [dolphinscheduler] pinkhello commented on a diff in pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
pinkhello commented on code in PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#discussion_r919706203


##########
dolphinscheduler-task-plugin/dolphinscheduler-task-java/src/main/java/org/apache/dolphinscheduler/plugin/task/java/JavaTask.java:
##########
@@ -0,0 +1,343 @@
+/*
+ * 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 org.apache.dolphinscheduler.plugin.task.api.AbstractTaskExecutor;
+import org.apache.dolphinscheduler.plugin.task.api.ShellCommandExecutor;
+import org.apache.dolphinscheduler.plugin.task.api.TaskConstants;
+import org.apache.dolphinscheduler.plugin.task.api.TaskException;
+import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext;
+import org.apache.dolphinscheduler.plugin.task.api.model.Property;
+import org.apache.dolphinscheduler.plugin.task.api.model.ResourceInfo;
+import org.apache.dolphinscheduler.plugin.task.api.model.TaskResponse;
+import org.apache.dolphinscheduler.plugin.task.api.parameters.AbstractParameters;
+import org.apache.dolphinscheduler.plugin.task.api.parser.ParamUtils;
+import org.apache.dolphinscheduler.plugin.task.api.parser.ParameterUtils;
+import org.apache.dolphinscheduler.plugin.task.api.utils.MapUtils;
+import org.apache.dolphinscheduler.plugin.task.java.exception.JavaSourceFileExistException;
+import org.apache.dolphinscheduler.plugin.task.java.exception.PublicClassNotFoundException;
+import org.apache.dolphinscheduler.plugin.task.java.exception.RunTypeNotFoundException;
+import org.apache.dolphinscheduler.spi.utils.JSONUtils;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.lang3.SystemUtils;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import com.google.common.base.Preconditions;
+
+/**
+ * java task
+ */
+public class JavaTask extends AbstractTaskExecutor {
+
+    /**
+     * java parameters
+     */
+    private JavaParameters javaParameters;
+
+    /**
+     * shell command executor
+     */
+    private ShellCommandExecutor shellCommandExecutor;
+
+    private TaskExecutionContext taskRequest;
+
+    /**
+     * constructor
+     *
+     * @param taskRequest taskRequest
+     */
+    public JavaTask(TaskExecutionContext taskRequest) {
+        super(taskRequest);
+        this.taskRequest = taskRequest;
+        this.shellCommandExecutor = new ShellCommandExecutor(this::logHandle,
+                taskRequest,
+                logger);
+    }
+
+    @Override
+    public void init() {
+        logger.info("java task params {}", taskRequest.getTaskParams());
+        javaParameters = JSONUtils.parseObject(taskRequest.getTaskParams(), JavaParameters.class);
+        if (javaParameters == null || !javaParameters.checkParameters()) {
+            throw new TaskException("java task params is not valid");
+        }
+        if (javaParameters.getRunType().equals(JavaConstants.RUN_TYPE_JAR)) {
+            setMainJarName();
+        }
+    }
+
+    @Override
+    public String getPreScript() {
+        String rawJavaScript = javaParameters.getRawScript().replaceAll("\\r\\n", "\n");
+        try {
+            rawJavaScript = convertJavaSourceCodePlaceholders(rawJavaScript);
+        } catch (StringIndexOutOfBoundsException e) {
+            logger.error("setShareVar field format error, raw java script : {}", rawJavaScript);
+        }
+        return rawJavaScript;
+    }
+
+    @Override
+    public void handle() throws Exception {
+        try {
+            // Step 1 judge if is java or jar run type.
+            // The  jar run type builds the command directly, adding resource to the java -jar class when building the command
+            // The java run type, first replace the custom parameters, then compile the code, and then build the command will add resource
+            // To run the coma
+            String command = null;
+            switch (javaParameters.getRunType()) {
+                case JavaConstants.RUN_TYPE_JAVA:
+                    command = buildJavaCommand();
+                    break;
+                case JavaConstants.RUN_TYPE_JAR:
+                    command = buildJarCommand();
+                    break;
+                default:
+                    throw new RunTypeNotFoundException("run type is required, but it is null now.");
+            }
+            Preconditions.checkNotNull(command, "command not be null.");
+            TaskResponse taskResponse = shellCommandExecutor.run(command);
+            logger.info("java task run result : " + taskResponse);
+            setExitStatusCode(taskResponse.getExitStatusCode());
+            setAppIds(taskResponse.getAppIds());
+            setProcessId(taskResponse.getProcessId());
+            setVarPool(shellCommandExecutor.getVarPool());
+        } catch (InterruptedException e) {
+            logger.error("java task interrupted ", e);
+            setExitStatusCode(TaskConstants.EXIT_CODE_FAILURE);
+            Thread.currentThread().interrupt();
+        } catch (Exception e) {
+            logger.error("java task failed ", e);
+            setExitStatusCode(TaskConstants.EXIT_CODE_FAILURE);
+            throw new TaskException("run java task error", e);
+        }
+    }
+
+    protected String buildJavaCommand() throws Exception {
+        String sourceCode = buildJavaSourceContent();
+        String className = compilerRawScript(sourceCode);
+        StringBuilder builder = new StringBuilder();
+        builder.append(getJavaHomeBinAbsolutePath())
+                .append("java").append(" ")
+                .append(buildResourcePath())
+                .append(" ")
+                .append(className).append(" ")
+                .append(javaParameters.getMainArgs().trim()).append(" ")
+                .append(javaParameters.getJvmArgs().trim());
+        return builder.toString();
+    }
+
+    private void setMainJarName() {
+        ResourceInfo mainJar = javaParameters.getMainJar();
+        String resourceName = getResourceNameOfMainJar(mainJar);
+        mainJar.setRes(resourceName);
+        javaParameters.setMainJar(mainJar);
+    }
+
+    private String getResourceNameOfMainJar(ResourceInfo mainJar) {
+        if (null == mainJar) {
+            throw new RuntimeException("The jar for the task is required.");
+        }
+
+        return mainJar.getId() == 0
+                ? mainJar.getRes()
+                // when update resource maybe has error
+                : mainJar.getResourceName().replaceFirst("/", "");
+    }
+
+    protected String buildJarCommand() {
+        String fullName = javaParameters.getMainJar().getResourceName();
+        String mainJarName = fullName.substring(0, fullName.lastIndexOf('.'));
+        mainJarName = mainJarName.substring(mainJarName.lastIndexOf('.') + 1) + ".jar";
+        StringBuilder builder = new StringBuilder();
+        builder.append(getJavaHomeBinAbsolutePath())
+                .append("java").append(" ")
+                .append(buildResourcePath()).append(" ")
+                .append("-jar").append(" ")
+                .append(taskRequest.getExecutePath())
+                .append(mainJarName).append(" ")
+                .append(javaParameters.getMainArgs().trim()).append(" ")
+                .append(javaParameters.getJvmArgs().trim());
+        return builder.toString();
+    }
+    
+    @Override
+    public void cancelApplication(boolean cancelApplication) throws Exception {
+        // cancel process
+        shellCommandExecutor.cancelApplication();
+    }
+
+    @Override
+    public AbstractParameters getParameters() {
+        return javaParameters;
+    }
+
+    /**
+     * convertJavaScriptPlaceholders
+     *
+     * @param rawScript rawScript
+     * @return String
+     * @throws StringIndexOutOfBoundsException StringIndexOutOfBoundsException
+     */
+    protected static String convertJavaSourceCodePlaceholders(String rawScript) throws StringIndexOutOfBoundsException {
+        int len = "${setShareVar(${".length();
+        int scriptStart = 0;
+        while ((scriptStart = rawScript.indexOf("${setShareVar(${", scriptStart)) != -1) {
+            int start = -1;
+            int end = rawScript.indexOf('}', scriptStart + len);
+            String prop = rawScript.substring(scriptStart + len, end);
+
+            start = rawScript.indexOf(',', end);
+            end = rawScript.indexOf(')', start);
+
+            String value = rawScript.substring(start + 1, end);
+
+            start = rawScript.indexOf('}', start) + 1;
+            end = rawScript.length();
+
+            String replaceScript = String.format("print(\"${{setValue({},{})}}\".format(\"%s\",%s))", prop, value);
+
+            rawScript = rawScript.substring(0, scriptStart) + replaceScript + rawScript.substring(start, end);
+
+            scriptStart += replaceScript.length();
+        }
+        return rawScript;
+    }
+
+    protected void createJavaSourceFileIfNotExists(String sourceCode, String fileName) throws IOException {
+        logger.info("tenantCode :{}, task dir:{}", taskRequest.getTenantCode(), taskRequest.getExecutePath());
+
+        if (!Files.exists(Paths.get(fileName))) {
+            logger.info("generate java source file:{}", fileName);
+
+            StringBuilder sb = new StringBuilder();
+            sb.append(sourceCode);
+            logger.info(sb.toString());
+
+            // write data to file
+            FileUtils.writeStringToFile(new File(fileName),
+                    sb.toString(),
+                    StandardCharsets.UTF_8);
+        } else {
+            throw new JavaSourceFileExistException("java source file exists, please report an issue on official.");
+        }
+    }
+
+    protected String buildJavaSourceCodeFileFullName(String publicClassName) {
+        return String.format(JavaConstants.JAVA_SOURCE_CODE_NAME_TEMPLATE, taskRequest.getExecutePath(), publicClassName);
+    }
+
+    protected String buildResourcePath() {
+        StringBuilder builder = new StringBuilder();
+        if (javaParameters.isModulePath()) {
+            builder.append("--module-path");
+        } else {
+            builder.append("--class-path");
+        }
+        builder.append(" ").append(JavaConstants.CLASSPATH_CURRENT_DIR)
+                .append(JavaConstants.PATH_SEPARATOR)
+                .append(taskRequest.getExecutePath());
+        for (ResourceInfo info : javaParameters.getResourceFilesList()) {
+            builder.append(JavaConstants.PATH_SEPARATOR);
+            builder.append(taskRequest.getExecutePath())
+                    .append(info.getResourceName());
+        }
+        return builder.toString();
+    }
+
+    protected String compilerRawScript(String sourceCode) throws IOException, InterruptedException {
+        String publicClassName = getPublicClassName(sourceCode);
+        String fileName =  buildJavaSourceCodeFileFullName(publicClassName);
+        createJavaSourceFileIfNotExists(sourceCode, fileName);
+        String compileCommand = buildJavaCompileCommand(fileName, sourceCode);
+        Preconditions.checkNotNull(compileCommand, "command not be null.");
+        TaskResponse compileResponse = shellCommandExecutor.run(compileCommand);
+        // must drop the command file ,if do not ,the next command will not run. because be limited the ShellCommandExecutor's create file rules
+        dropShellCommandFile();
+        shellCommandExecutor = new ShellCommandExecutor(this::logHandle,
+                taskRequest,
+                logger);
+        logger.info("java task code compile result : " + compileResponse);
+        return publicClassName;
+    }
+
+    private void dropShellCommandFile() throws IOException {
+        String commandFilePath = String.format("%s/%s.%s"
+                , taskRequest.getExecutePath()
+                , taskRequest.getTaskAppId()
+                , SystemUtils.IS_OS_WINDOWS ? "bat" : "command");
+        Path path = Paths.get(commandFilePath);
+        if (Files.exists(path)) {
+            Files.delete(path);
+        }
+    }
+
+    protected String buildJavaCompileCommand(String fileName, String sourceCode) throws IOException {
+
+        StringBuilder compilerCommand = new StringBuilder()
+                .append(getJavaHomeBinAbsolutePath())
+                .append("javac").append(" ")
+                .append(buildResourcePath()).append(" ")
+                .append(fileName);
+        return compilerCommand.toString();
+    }
+
+    protected String buildJavaSourceContent() {
+        String rawJavaScript = javaParameters.getRawScript().replaceAll("\\r\\n", "\n");
+        // replace placeholder
+
+        Map<String, Property> paramsMap = taskRequest.getPrepareParamsMap();
+        if (MapUtils.isEmpty(paramsMap)) {
+            paramsMap = new HashMap<>();
+        }
+        if (MapUtils.isNotEmpty(taskRequest.getParamsMap())) {
+            paramsMap.putAll(taskRequest.getParamsMap());
+        }
+        rawJavaScript = ParameterUtils.convertParameterPlaceholders(rawJavaScript, ParamUtils.convert(paramsMap));
+        logger.info("raw java script : {}", javaParameters.getRawScript());
+        return rawJavaScript;
+    }
+
+    private String getJavaHomeBinAbsolutePath() {
+        String javaHomeAbsolutePath = System.getenv(JavaConstants.JAVA_HOME);
+        Preconditions.checkNotNull(javaHomeAbsolutePath, "not find the java home in the version. ");
+        return javaHomeAbsolutePath + System.getProperty("file.separator") + "bin" + System.getProperty("file.separator");
+    }
+
+    public String getPublicClassName(String sourceCode) {
+        String pattern = "(.*\\s+public\\s+class\\s+)([a-zA-Z_]+[//w_]*)([.\\s\\S]*)";
+        Pattern compile = Pattern.compile(pattern);

Review Comment:
   I think should cache regex pattern to improve performance, its performance matters.



-- 
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


[GitHub] [dolphinscheduler] zhuangchong commented on a diff in pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
zhuangchong commented on code in PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#discussion_r934133015


##########
dolphinscheduler-ui/src/locales/zh_CN/project.ts:
##########
@@ -284,6 +284,10 @@ export default {
     online: '已上线'
   },
   node: {
+    is_module_path: '模块路劲',

Review Comment:
   Please modify the value.



-- 
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


[GitHub] [dolphinscheduler] sonarcloud[bot] commented on pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
sonarcloud[bot] commented on PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#issuecomment-1199305195

   SonarCloud Quality Gate failed.&nbsp; &nbsp; [![Quality Gate failed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/failed-16px.png 'Quality Gate failed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=10689)
   
   [![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png 'Bug')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG)  
   [![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png 'Vulnerability')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY)  
   [![Security Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png 'Security Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT)  
   [![Code Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png 'Code Smell')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL) [15 Code Smells](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL)
   
   [![0.4%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/0-16px.png '0.4%')](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_coverage&view=list) [0.4% Coverage](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_coverage&view=list)  
   [![1.9%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3-16px.png '1.9%')](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_duplicated_lines_density&view=list) [1.9% Duplication](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_duplicated_lines_density&view=list)
   
   


-- 
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


[GitHub] [dolphinscheduler] sonarcloud[bot] commented on pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
sonarcloud[bot] commented on PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#issuecomment-1171323992

   SonarCloud Quality Gate failed.&nbsp; &nbsp; [![Quality Gate failed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/failed-16px.png 'Quality Gate failed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=10689)
   
   [![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png 'Bug')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG)  
   [![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png 'Vulnerability')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY)  
   [![Security Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png 'Security Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT) [![E](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/E-16px.png 'E')](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT) [1 Security Hotspot](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT)  
   [![Code Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png 'Code Smell')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL) [24 Code Smells](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL)
   
   [![0.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/0-16px.png '0.0%')](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_coverage&view=list) [0.0% Coverage](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_coverage&view=list)  
   [![2.1%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3-16px.png '2.1%')](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_duplicated_lines_density&view=list) [2.1% Duplication](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_duplicated_lines_density&view=list)
   
   


-- 
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


[GitHub] [dolphinscheduler] sonarcloud[bot] commented on pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
sonarcloud[bot] commented on PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#issuecomment-1172926118

   SonarCloud Quality Gate failed.&nbsp; &nbsp; [![Quality Gate failed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/failed-16px.png 'Quality Gate failed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=10689)
   
   [![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png 'Bug')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG)  
   [![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png 'Vulnerability')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY)  
   [![Security Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png 'Security Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT) [![E](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/E-16px.png 'E')](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT) [1 Security Hotspot](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT)  
   [![Code Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png 'Code Smell')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL) [24 Code Smells](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL)
   
   [![0.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/0-16px.png '0.0%')](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_coverage&view=list) [0.0% Coverage](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_coverage&view=list)  
   [![2.1%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3-16px.png '2.1%')](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_duplicated_lines_density&view=list) [2.1% Duplication](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_duplicated_lines_density&view=list)
   
   


-- 
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


[GitHub] [dolphinscheduler] SbloodyS commented on a diff in pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
SbloodyS commented on code in PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#discussion_r916484314


##########
dolphinscheduler-task-plugin/dolphinscheduler-task-java/src/main/test/org/apache/dolphinscheduler/plugin/task/java/JavaTaskTest.java:
##########
@@ -0,0 +1,161 @@
+/*
+ * 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 org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext;
+import org.apache.dolphinscheduler.plugin.task.api.model.Property;
+import org.apache.dolphinscheduler.plugin.task.api.model.ResourceInfo;
+import org.apache.dolphinscheduler.spi.utils.JSONUtils;
+import org.junit.Assert;
+import org.junit.Test;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import static org.apache.dolphinscheduler.plugin.task.api.enums.DataType.VARCHAR;
+import static org.apache.dolphinscheduler.plugin.task.api.enums.Direct.IN;
+import static org.apache.dolphinscheduler.plugin.task.java.JavaConstants.RUN_TYPE_JAR;
+import static org.apache.dolphinscheduler.plugin.task.java.JavaConstants.RUN_TYPE_JAVA;
+import java.io.IOException;
+public class JavaTaskTest {
+    @Test
+    public void testJavaHome() {
+        Assert.assertNotNull(System.getenv().get("JAVA_HOME"));
+    }
+
+
+    @Test
+    public void buildJarCommand() {
+        String homePath = System.getenv(JavaConstants.JAVA_HOME);
+        Assert.assertNotNull(homePath);
+        String homeBinPath =  homePath+ System.getProperty("file.separator") + "bin" + System.getProperty("file.separator");
+        JavaTask javaTask = runJarType();
+        Assert.assertEquals(javaTask.buildJarCommand(), homeBinPath
+                +"java --class-path .:/tmp/dolphinscheduler/test/executepath:/tmp/dolphinscheduler/test/executepath/opt/share/jar/resource2.jar -jar /tmp/dolphinscheduler/test/executepath/opt/share/jar/main.jar -host 127.0.0.1 -port 8080 -xms:50m");
+    }
+
+    @Test
+    public void buildJavaCompileCommand() throws IOException {
+        JavaTask javaTask = runJavaType();
+        String sourceCode = javaTask.buildJavaSourceContent();
+        String publicClassName = javaTask.getPublicClassName(sourceCode);
+        Assert.assertEquals("JavaTaskTest", publicClassName);
+        String fileName = javaTask.buildJavaSourceCodeFileFullName(publicClassName);
+        try {
+            String homePath = System.getenv(JavaConstants.JAVA_HOME);
+            Assert.assertNotNull(homePath);
+            String homeBinPath = homePath + System.getProperty("file.separator") + "bin" + System.getProperty("file.separator");
+            Path path = Paths.get(fileName);
+            if (Files.exists(path)) {
+                Files.delete(path);
+            }
+            javaTask.createJavaSourceFileIfNotExists(sourceCode, fileName);
+            Assert.assertEquals(homeBinPath
+                    +"javac --class-path .:/tmp/dolphinscheduler/test/executepath:/tmp/dolphinscheduler/test/executepath/opt/share/jar/resource2.jar /tmp/dolphinscheduler/test/executepath/JavaTaskTest.java", javaTask.buildJavaCompileCommand(fileName, sourceCode));
+
+        } finally {
+            Path path = Paths.get(fileName);
+            if (Files.exists(path)) {
+                Files.delete(path);
+            }
+        }
+
+    }
+
+
+    @Test
+    public void buildJavaCommand() throws Exception {
+        String homePath = System.getenv(JavaConstants.JAVA_HOME);
+        Assert.assertNotNull(homePath);
+        String homeBinPath =  homePath+ System.getProperty("file.separator") + "bin" + System.getProperty("file.separator");
+        JavaTask javaTask = runJavaType();
+        String sourceCode = javaTask.buildJavaSourceContent();
+        String publicClassName = javaTask.getPublicClassName(sourceCode);
+        Assert.assertEquals("JavaTaskTest", publicClassName);
+        String fileName = javaTask.buildJavaSourceCodeFileFullName(publicClassName);
+        Path path = Paths.get(fileName);
+        if (Files.exists(path)) {
+            Files.delete(path);
+        }
+        Assert.assertEquals(javaTask.buildJavaCommand(), homeBinPath + "java --class-path .:/tmp/dolphinscheduler/test/executepath:/tmp/dolphinscheduler/test/executepath/opt/share/jar/resource2.jar JavaTaskTest -host 127.0.0.1 -port 8080 -xms:50m");
+    }
+
+    public JavaParameters createJavaParametersObject(String runType) {
+        JavaParameters javaParameters = new JavaParameters();
+        javaParameters.setRunType(runType);
+        javaParameters.setModulePath(false);
+        javaParameters.setJvmArgs("-xms:50m");
+        javaParameters.setMainArgs("-host 127.0.0.1 -port 8080");
+        ResourceInfo resourceJar = new ResourceInfo();
+        resourceJar.setId(2);
+        resourceJar.setResourceName("/opt/share/jar/resource2.jar");
+        resourceJar.setRes("I'm resource2.jar");
+        ArrayList<ResourceInfo> resourceInfoArrayList = new ArrayList<>();
+        resourceInfoArrayList.add(resourceJar);
+        javaParameters.setResourceList(resourceInfoArrayList);
+        javaParameters.setRawScript(
+                        "import java.io.IOException;\n" +
+                        "public class JavaTaskTest {\n" +
+                        "    public static void main(String[] args) throws IOException {\n" +
+                        "        StringBuilder builder = new StringBuilder(\"Hello: \");\n" +
+                        "        for (String arg : args) {\n" +
+                        "            builder.append(arg).append(\" \");\n" +
+                        "        }\n" +
+                        "        System.out.println(builder);\n" +
+                        "    }\n" +
+                        "}\n");
+        ArrayList<Property> localParams = new ArrayList<>();
+        Property property = new Property();
+        property.setProp("name");
+        property.setValue("zhangsan");
+        property.setDirect(IN);
+        property.setType(VARCHAR);
+        javaParameters.setLocalParams(localParams);
+//        javaParameters.setVarPool("");

Review Comment:
   We should remove meaningless code.



-- 
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


[GitHub] [dolphinscheduler] sonarcloud[bot] commented on pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
sonarcloud[bot] commented on PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#issuecomment-1178625637

   SonarCloud Quality Gate failed.&nbsp; &nbsp; [![Quality Gate failed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/failed-16px.png 'Quality Gate failed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=10689)
   
   [![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png 'Bug')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG)  
   [![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png 'Vulnerability')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY)  
   [![Security Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png 'Security Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT) [![E](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/E-16px.png 'E')](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT) [1 Security Hotspot](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT)  
   [![Code Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png 'Code Smell')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL) [16 Code Smells](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL)
   
   [![0.4%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/0-16px.png '0.4%')](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_coverage&view=list) [0.4% Coverage](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_coverage&view=list)  
   [![2.2%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3-16px.png '2.2%')](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_duplicated_lines_density&view=list) [2.2% Duplication](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_duplicated_lines_density&view=list)
   
   


-- 
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


[GitHub] [dolphinscheduler] 106umao commented on a diff in pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
106umao commented on code in PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#discussion_r915773206


##########
docs/docs/zh/guide/task/java.md:
##########
@@ -0,0 +1,50 @@
+# JAVA 节点
+
+## 综述
+
+该节点用于执行 java 类型的任务,支持使用单文件和jar包作为程序入口。
+
+## 创建任务
+
+- 点击项目管理 -> 项目名称 -> 工作流定义,点击”创建工作流”按钮,进入 DAG 编辑页面:
+
+- 拖动工具栏的JAVA任务节点到画板中。
+
+## 任务参数
+
+- 节点名称:设置任务的名称。一个工作流定义中的节点名称是唯一的。
+- 运行标志:标识这个节点是否能正常调度,如果不需要执行,可以打开禁止执行开关。
+- 描述:描述该节点的功能。
+- 任务优先级:worker 线程数不足时,根据优先级从高到低依次执行,优先级一样时根据先进先出原则执行。
+- Worker 分组:任务分配给 worker 组的机器机执行,选择 Default,会随机选择一台 worker 机执行。
+- 环境名称:配置运行任务的环境。
+- 失败重试次数:任务失败重新提交的次数,支持下拉和手填。
+- 失败重试间隔:任务失败重新提交任务的时间间隔,支持下拉和手填。
+- 延迟执行时间:任务延迟执行的时间,以分为单位。
+- 超时告警:勾选超时告警、超时失败,当任务超过"超时时长"后,会发送告警邮件并且任务执行失败。
+- 模块路劲:开启使用JAVA9+的模块化特性,把所有资源放入--module-path中,要求您的worker中的JDK版本支持模块化。
+- 主程序参数:作为普通Java程序main方法入口参数。
+- 虚拟机参数:配置启动虚拟机参数。
+- 脚本:若使用JAVA运行类型则需要编写JAVA代码。代码中必须存在public类,不用写package语句。
+- 资源:可以是外部JAR包也可以是其他资源文件,它们都会被加入到类路径或模块路径中,您可以在自己的JAVA脚本中轻松获取。
+- 自定义参数:是 http 局部的用户自定义参数,会替换脚本中以 ${变量} 的内容。
+- 前置任务:选择当前任务的前置任务,会将被选择的前置任务设置为当前任务的上游。
+
+## 任务样例
+
+HTTP 定义了与服务器交互的不同方法,最基本的方法有4种,分别是GET,POST,PUT,DELETE。这里我们使用 http 任务节点,演示使用 POST 向系统的登录页面发送请求,提交数据。
+
+主要配置参数如下:
+
+- 运行类型
+- 模块路径
+- 主程序参数
+- 虚拟机参数
+- 脚本文件
+
+![java_task](../../../../img/tasks/demo/java_task01.png)

Review Comment:
   thx, it is done



-- 
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


[GitHub] [dolphinscheduler] kezhenxu94 commented on a diff in pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
kezhenxu94 commented on code in PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#discussion_r914441653


##########
dolphinscheduler-task-plugin/dolphinscheduler-task-java/src/main/java/org/apache/dolphinscheduler/plugin/task/java/JavaConstants.java:
##########
@@ -0,0 +1,46 @@
+/*
+ * 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;
+
+public class JavaConstants {
+
+    private JavaConstants() {
+        throw new IllegalStateException("Utility class");
+    }
+
+    public static final String JAVA_HOME = "JAVA_HOME";
+
+
+    public static final String RUN_TYPE_JAVA = "JAVA";
+    public static final String RUN_TYPE_JAR = "JAR";
+
+//    to be extended.
+//    public static final String RUN_TYPE_JSHELL = "JSHELL";
+//    public static final String RUN_TYPE_INJVM = "INJVM";
+
+
+

Review Comment:
   Do put these commented codes here if you don't plan to implement in this PR, create an issue to track the todo tasks



##########
dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/model/TaskResponse.java:
##########
@@ -123,4 +123,18 @@ public TaskRunStatus getStatus() {
     public void setStatus(TaskRunStatus status) {
         this.status = status;
     }
+
+    @Override
+    public String toString() {
+        return "TaskResponse{" +
+                "varPool='" + varPool + '\'' +
+                ", processId=" + processId +
+                ", resultString='" + resultString + '\'' +
+                ", appIds='" + appIds + '\'' +
+                ", process=" + process +
+                ", cancel=" + cancel +
+                ", exitStatusCode=" + exitStatusCode +
+                ", status=" + status +
+                '}';
+    }

Review Comment:
   Please use `@ToString` annotation (or even `@Data` annotation and remove the `getter/setter`) from lombok 



##########
dolphinscheduler-task-plugin/dolphinscheduler-task-java/src/main/java/org/apache/dolphinscheduler/plugin/task/java/JavaParameters.java:
##########
@@ -0,0 +1,114 @@
+/*
+ * 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 org.apache.dolphinscheduler.plugin.task.api.model.ResourceInfo;
+import org.apache.dolphinscheduler.plugin.task.api.parameters.AbstractParameters;
+
+import java.util.List;
+
+public class JavaParameters extends AbstractParameters {
+    /**
+     * origin java script
+     */
+    private String rawScript;
+
+    private ResourceInfo mainJar;
+
+    private String runType;
+
+    private String mainArgs;
+
+    private String jvmArgs;
+    private boolean isModulePath;
+
+
+    public boolean isModulePath() {
+        return isModulePath;
+    }
+
+    public void setModulePath(boolean modulePath) {
+        isModulePath = modulePath;
+    }
+
+
+
+    /**
+     * resource list
+     */
+    private List<ResourceInfo> resourceList;
+
+    public String getRawScript() {

Review Comment:
   Use `@Getter/@Setter` annotations from lombok



-- 
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


[GitHub] [dolphinscheduler] EricGao888 commented on pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
EricGao888 commented on PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#issuecomment-1196477164

   > > I add some comments on the English version docs. Thanks.
   > 
   > Thanks,I still need to learn from you
   
   @106umao You're welcome. We are lucky to have a devoted contributor like you. Thanks again for your effort.


-- 
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


[GitHub] [dolphinscheduler] 106umao commented on a diff in pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
106umao commented on code in PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#discussion_r943202515


##########
docs/docs/zh/guide/task/java.md:
##########
@@ -0,0 +1,50 @@
+# JAVA 节点
+
+## 综述
+
+该节点用于执行 java 类型的任务,支持使用单文件和jar包作为程序入口。
+
+## 创建任务
+
+- 点击项目管理 -> 项目名称 -> 工作流定义,点击”创建工作流”按钮,进入 DAG 编辑页面:
+
+- 拖动工具栏的JAVA任务节点到画板中。
+
+## 任务参数
+
+- 节点名称:设置任务的名称。一个工作流定义中的节点名称是唯一的。
+- 运行标志:标识这个节点是否能正常调度,如果不需要执行,可以打开禁止执行开关。
+- 描述:描述该节点的功能。
+- 任务优先级:worker 线程数不足时,根据优先级从高到低依次执行,优先级一样时根据先进先出原则执行。
+- Worker 分组:任务分配给 worker 组的机器机执行,选择 Default,会随机选择一台 worker 机执行。
+- 环境名称:配置运行任务的环境。
+- 失败重试次数:任务失败重新提交的次数,支持下拉和手填。
+- 失败重试间隔:任务失败重新提交任务的时间间隔,支持下拉和手填。
+- 延迟执行时间:任务延迟执行的时间,以分为单位。
+- 超时告警:勾选超时告警、超时失败,当任务超过"超时时长"后,会发送告警邮件并且任务执行失败。
+- 模块路劲:开启使用JAVA9+的模块化特性,把所有资源放入--module-path中,要求您的worker中的JDK版本支持模块化。

Review Comment:
   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


[GitHub] [dolphinscheduler] sonarcloud[bot] commented on pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
sonarcloud[bot] commented on PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#issuecomment-1213207173

   SonarCloud Quality Gate failed.&nbsp; &nbsp; [![Quality Gate failed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/failed-16px.png 'Quality Gate failed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=10689)
   
   [![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png 'Bug')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG)  
   [![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png 'Vulnerability')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY)  
   [![Security Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png 'Security Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT)  
   [![Code Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png 'Code Smell')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL) [12 Code Smells](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL)
   
   [![0.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/0-16px.png '0.0%')](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_coverage&view=list) [0.0% Coverage](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_coverage&view=list)  
   [![1.9%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3-16px.png '1.9%')](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_duplicated_lines_density&view=list) [1.9% Duplication](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_duplicated_lines_density&view=list)
   
   


-- 
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


[GitHub] [dolphinscheduler] 106umao commented on pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
106umao commented on PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#issuecomment-1213213304

   > > somebody can help me look on the docs dead link error: [heavy_multiplication_x] https://dolphinscheduler.apache.org/python/index.html → Status: 404
   > 
   > Please merge the latest dev branch code.
   
   have done, pls reaview for me


-- 
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


[GitHub] [dolphinscheduler] EricGao888 commented on pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
EricGao888 commented on PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#issuecomment-1241447297

   @106umao Congrats! Thanks for the contributions : )


-- 
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


[GitHub] [dolphinscheduler] sonarcloud[bot] commented on pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
sonarcloud[bot] commented on PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#issuecomment-1240253584

   SonarCloud Quality Gate failed.&nbsp; &nbsp; [![Quality Gate failed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/failed-16px.png 'Quality Gate failed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=10689)
   
   [![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png 'Bug')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG)  
   [![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png 'Vulnerability')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY)  
   [![Security Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png 'Security Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT)  
   [![Code Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png 'Code Smell')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL) [8 Code Smells](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL)
   
   [![0.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/0-16px.png '0.0%')](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_coverage&view=list) [0.0% Coverage](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_coverage&view=list)  
   [![2.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3-16px.png '2.0%')](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_duplicated_lines_density&view=list) [2.0% Duplication](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_duplicated_lines_density&view=list)
   
   


-- 
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


[GitHub] [dolphinscheduler] sonarcloud[bot] commented on pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
sonarcloud[bot] commented on PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#issuecomment-1170932710

   SonarCloud Quality Gate failed.&nbsp; &nbsp; [![Quality Gate failed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/failed-16px.png 'Quality Gate failed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=10689)
   
   [![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png 'Bug')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG)  
   [![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png 'Vulnerability')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY)  
   [![Security Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png 'Security Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT) [![E](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/E-16px.png 'E')](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT) [1 Security Hotspot](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT)  
   [![Code Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png 'Code Smell')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL) [24 Code Smells](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL)
   
   [![0.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/0-16px.png '0.0%')](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_coverage&view=list) [0.0% Coverage](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_coverage&view=list)  
   [![2.1%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3-16px.png '2.1%')](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_duplicated_lines_density&view=list) [2.1% Duplication](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_duplicated_lines_density&view=list)
   
   


-- 
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


[GitHub] [dolphinscheduler] sonarcloud[bot] commented on pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
sonarcloud[bot] commented on PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#issuecomment-1175306007

   SonarCloud Quality Gate failed.&nbsp; &nbsp; [![Quality Gate failed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/failed-16px.png 'Quality Gate failed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=10689)
   
   [![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png 'Bug')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG)  
   [![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png 'Vulnerability')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY)  
   [![Security Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png 'Security Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT) [![E](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/E-16px.png 'E')](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT) [1 Security Hotspot](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT)  
   [![Code Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png 'Code Smell')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL) [24 Code Smells](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL)
   
   [![0.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/0-16px.png '0.0%')](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_coverage&view=list) [0.0% Coverage](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_coverage&view=list)  
   [![2.1%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3-16px.png '2.1%')](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_duplicated_lines_density&view=list) [2.1% Duplication](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_duplicated_lines_density&view=list)
   
   


-- 
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


[GitHub] [dolphinscheduler] 106umao commented on pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
106umao commented on PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#issuecomment-1184544443

   > You need to add the JAVA task documentation link in the docsdev.js file.
   > 
   > https://github.com/apache/dolphinscheduler/blob/dev/docs/configs/docsdev.js
   
   
   
   > You need to add the JAVA task documentation link in the docsdev.js file.
   > 
   > https://github.com/apache/dolphinscheduler/blob/dev/docs/configs/docsdev.js
   
   thx, have done


-- 
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


[GitHub] [dolphinscheduler] EricGao888 commented on a diff in pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
EricGao888 commented on code in PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#discussion_r925751683


##########
dolphinscheduler-task-plugin/dolphinscheduler-task-java/src/main/java/org/apache/dolphinscheduler/plugin/task/java/JavaParameters.java:
##########
@@ -0,0 +1,64 @@
+/*
+ * 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 org.apache.dolphinscheduler.plugin.task.api.model.ResourceInfo;
+import org.apache.dolphinscheduler.plugin.task.api.parameters.AbstractParameters;
+
+import java.util.List;
+
+import lombok.Data;
+
+@Data

Review Comment:
   Hi~ I recommend replacing `@Data` with `@Getter`, `@Setter` and `@ToString` because `@Data` will generate some code we may not need and cause the test coverage to decrease. Thx : )
   see: https://projectlombok.org/features/Data and https://stackoverflow.com/questions/45569085/sonarqube-bad-coverage-because-of-lombok-data



-- 
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


[GitHub] [dolphinscheduler] 106umao commented on pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
106umao commented on PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#issuecomment-1193305140

   > > Hi @zhuangchong @SbloodyS @Amy0104 please help me restart CI failed
   > 
   > Merging the latest dev code can effectively reduce the probability of E2E failure.
   
   Thank you for your guidance. Be sure to do so next time.


-- 
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


[GitHub] [dolphinscheduler] EricGao888 commented on pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
EricGao888 commented on PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#issuecomment-1203423391

   I've restarted the failed CI.


-- 
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


[GitHub] [dolphinscheduler] 106umao commented on a diff in pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
106umao commented on code in PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#discussion_r943173299


##########
dolphinscheduler-task-plugin/dolphinscheduler-task-java/src/main/java/org/apache/dolphinscheduler/plugin/task/java/JavaParameters.java:
##########
@@ -0,0 +1,89 @@
+/*
+ * 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 org.apache.dolphinscheduler.plugin.task.api.model.ResourceInfo;
+import org.apache.dolphinscheduler.plugin.task.api.parameters.AbstractParameters;
+
+import java.util.List;
+
+import lombok.Getter;
+import lombok.Setter;
+import lombok.ToString;
+
+@Getter

Review Comment:
   done



-- 
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


[GitHub] [dolphinscheduler] sonarcloud[bot] commented on pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
sonarcloud[bot] commented on PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#issuecomment-1199307841

   SonarCloud Quality Gate failed.&nbsp; &nbsp; [![Quality Gate failed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/failed-16px.png 'Quality Gate failed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=10689)
   
   [![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png 'Bug')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG)  
   [![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png 'Vulnerability')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY)  
   [![Security Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png 'Security Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT)  
   [![Code Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png 'Code Smell')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL) [15 Code Smells](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL)
   
   [![0.4%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/0-16px.png '0.4%')](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_coverage&view=list) [0.4% Coverage](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_coverage&view=list)  
   [![1.9%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3-16px.png '1.9%')](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_duplicated_lines_density&view=list) [1.9% Duplication](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_duplicated_lines_density&view=list)
   
   


-- 
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


[GitHub] [dolphinscheduler] sonarcloud[bot] commented on pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
sonarcloud[bot] commented on PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#issuecomment-1197885186

   SonarCloud Quality Gate failed.&nbsp; &nbsp; [![Quality Gate failed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/failed-16px.png 'Quality Gate failed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=10689)
   
   [![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png 'Bug')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG)  
   [![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png 'Vulnerability')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY)  
   [![Security Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png 'Security Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT)  
   [![Code Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png 'Code Smell')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL) [15 Code Smells](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL)
   
   [![0.4%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/0-16px.png '0.4%')](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_coverage&view=list) [0.4% Coverage](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_coverage&view=list)  
   [![1.9%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3-16px.png '1.9%')](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_duplicated_lines_density&view=list) [1.9% Duplication](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_duplicated_lines_density&view=list)
   
   


-- 
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


[GitHub] [dolphinscheduler] sonarcloud[bot] commented on pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
sonarcloud[bot] commented on PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#issuecomment-1198842853

   SonarCloud Quality Gate failed.&nbsp; &nbsp; [![Quality Gate failed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/failed-16px.png 'Quality Gate failed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=10689)
   
   [![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png 'Bug')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG)  
   [![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png 'Vulnerability')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY)  
   [![Security Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png 'Security Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT)  
   [![Code Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png 'Code Smell')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL) [15 Code Smells](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL)
   
   [![0.4%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/0-16px.png '0.4%')](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_coverage&view=list) [0.4% Coverage](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_coverage&view=list)  
   [![1.9%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3-16px.png '1.9%')](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_duplicated_lines_density&view=list) [1.9% Duplication](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_duplicated_lines_density&view=list)
   
   


-- 
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


[GitHub] [dolphinscheduler] 106umao commented on a diff in pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
106umao commented on code in PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#discussion_r945314921


##########
dolphinscheduler-task-plugin/dolphinscheduler-task-java/src/main/java/org/apache/dolphinscheduler/plugin/task/java/JavaTask.java:
##########
@@ -0,0 +1,422 @@
+/*
+ * 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 static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.SINGLE_SLASH;
+import static org.apache.dolphinscheduler.plugin.task.java.JavaConstants.JAVA_HOME_VAR;
+import static org.apache.dolphinscheduler.plugin.task.java.JavaConstants.PUBLIC_CLASS_NAME_REGEX;
+
+
+import org.apache.dolphinscheduler.plugin.task.api.AbstractTaskExecutor;
+import org.apache.dolphinscheduler.plugin.task.api.ShellCommandExecutor;
+import org.apache.dolphinscheduler.plugin.task.api.TaskConstants;
+import org.apache.dolphinscheduler.plugin.task.api.TaskException;
+import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext;
+import org.apache.dolphinscheduler.plugin.task.api.model.Property;
+import org.apache.dolphinscheduler.plugin.task.api.model.ResourceInfo;
+import org.apache.dolphinscheduler.plugin.task.api.model.TaskResponse;
+import org.apache.dolphinscheduler.plugin.task.api.parameters.AbstractParameters;
+import org.apache.dolphinscheduler.plugin.task.api.parser.ParamUtils;
+import org.apache.dolphinscheduler.plugin.task.api.parser.ParameterUtils;
+import org.apache.dolphinscheduler.plugin.task.api.utils.MapUtils;
+import org.apache.dolphinscheduler.plugin.task.java.exception.JavaSourceFileExistException;
+import org.apache.dolphinscheduler.plugin.task.java.exception.PublicClassNotFoundException;
+import org.apache.dolphinscheduler.plugin.task.java.exception.RunTypeNotFoundException;
+import org.apache.dolphinscheduler.spi.utils.JSONUtils;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.lang3.SystemUtils;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import com.google.common.base.Preconditions;
+
+/**
+ * java task
+ */
+public class JavaTask extends AbstractTaskExecutor {
+
+    /**
+     * Contains various parameters for this task
+     */
+    private JavaParameters javaParameters;
+
+    /**
+     * To run shell commands
+     */
+    private ShellCommandExecutor shellCommandExecutor;
+
+    /**
+     * task execution context
+     */
+    private TaskExecutionContext taskRequest;
+
+    /**
+     * class name regex pattern
+     */
+    private static final Pattern classNamePattern = Pattern.compile(PUBLIC_CLASS_NAME_REGEX);
+
+    /**
+     * @description: Construct a Java task
+     * @param: [org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext]
+     * @return: JavaTask
+     **/
+    public JavaTask(TaskExecutionContext taskRequest) {
+        super(taskRequest);
+        this.taskRequest = taskRequest;
+        this.shellCommandExecutor = new ShellCommandExecutor(this::logHandle,
+                taskRequest,
+                logger);
+    }
+
+    /**
+     * @description: Initializes a Java task
+     * @param: []
+     * @return: void
+     **/
+    @Override
+    public void init() {
+        logger.info("java task params {}", taskRequest.getTaskParams());
+        javaParameters = JSONUtils.parseObject(taskRequest.getTaskParams(), JavaParameters.class);
+        if (javaParameters == null || !javaParameters.checkParameters()) {
+            throw new TaskException("java task params is not valid");
+        }
+        if (javaParameters.getRunType().equals(JavaConstants.RUN_TYPE_JAR)) {
+            setMainJarName();
+        }
+    }
+
+    /**
+     * @description: Gets the Java source file that was initially processed
+     * @param: []
+     * @return: java.lang.String
+     **/
+    @Override
+    public String getPreScript() {
+        String rawJavaScript = javaParameters.getRawScript().replaceAll("\\r\\n", "\n");
+        try {
+            rawJavaScript = convertJavaSourceCodePlaceholders(rawJavaScript);
+        } catch (StringIndexOutOfBoundsException e) {
+            logger.error("setShareVar field format error, raw java script : {}", rawJavaScript);
+        }
+        return rawJavaScript;
+    }
+
+    /**
+     * @description: Execute Java tasks
+     * @param: []
+     * @return: void
+     **/
+    @Override
+    public void handle() throws Exception {
+        try {
+            // Step 1: judge if is java or jar run type.
+            // Step 2 case1: The jar run type builds the command directly, adding resource to the java -jar class when building the command
+            // Step 2 case2: The java run type, first replace the custom parameters, then compile the code, and then build the command will add resource
+            // Step 3: To run the command
+            String command = null;
+            switch (javaParameters.getRunType()) {
+                case JavaConstants.RUN_TYPE_JAVA:
+                    command = buildJavaCommand();
+                    break;
+                case JavaConstants.RUN_TYPE_JAR:
+                    command = buildJarCommand();
+                    break;
+                default:
+                    throw new RunTypeNotFoundException("run type is required, but it is null now.");
+            }
+            Preconditions.checkNotNull(command, "command not be null.");
+            TaskResponse taskResponse = shellCommandExecutor.run(command);
+            logger.info("java task run result : {}", taskResponse);
+            setExitStatusCode(taskResponse.getExitStatusCode());
+            setAppIds(taskResponse.getAppIds());
+            setProcessId(taskResponse.getProcessId());
+            setVarPool(shellCommandExecutor.getVarPool());
+        } catch (InterruptedException e) {
+            logger.error("java task interrupted ", e);
+            setExitStatusCode(TaskConstants.EXIT_CODE_FAILURE);
+            Thread.currentThread().interrupt();
+        } catch (RunTypeNotFoundException e) {
+            logger.error(e.getMessage());
+            setExitStatusCode(TaskConstants.EXIT_CODE_FAILURE);
+            throw e;
+        } catch (Exception e) {
+            logger.error("java task failed ", e);
+            setExitStatusCode(TaskConstants.EXIT_CODE_FAILURE);
+            throw new TaskException("run java task error", e);
+        }
+    }
+
+    /**
+     * @description: Construct a shell command for the java Run mode
+     * @param: []
+     * @return: java.lang.String
+     **/
+    protected String buildJavaCommand() throws Exception {
+        String sourceCode = buildJavaSourceContent();
+        String className = compilerRawScript(sourceCode);
+        StringBuilder builder = new StringBuilder();
+        builder.append(getJavaCommandPath())
+                .append("java").append(" ")
+                .append(buildResourcePath())
+                .append(" ")
+                .append(className).append(" ")
+                .append(javaParameters.getMainArgs().trim()).append(" ")
+                .append(javaParameters.getJvmArgs().trim());
+        return builder.toString();
+    }
+
+    private void setMainJarName() {
+        ResourceInfo mainJar = javaParameters.getMainJar();
+        String resourceName = getResourceNameOfMainJar(mainJar);
+        mainJar.setRes(resourceName);
+        javaParameters.setMainJar(mainJar);
+    }
+
+    /**
+     * @description: Construct a shell command for the java -jar Run mode
+     * @param: []
+     * @return: java.lang.String
+     **/
+    protected String buildJarCommand() {
+        String fullName = javaParameters.getMainJar().getResourceName();
+        String mainJarName = fullName.substring(0, fullName.lastIndexOf('.'));
+        mainJarName = mainJarName.substring(mainJarName.lastIndexOf('.') + 1) + ".jar";
+        StringBuilder builder = new StringBuilder();
+        builder.append(getJavaCommandPath())
+                .append("java").append(" ")
+                .append(buildResourcePath()).append(" ")
+                .append("-jar").append(" ")
+                .append(taskRequest.getExecutePath())
+                .append(mainJarName).append(" ")
+                .append(javaParameters.getMainArgs().trim()).append(" ")
+                .append(javaParameters.getJvmArgs().trim());
+        return builder.toString();
+    }
+
+    private String getResourceNameOfMainJar(ResourceInfo mainJar) {
+        if (null == mainJar) {
+            throw new RuntimeException("The jar for the task is required.");
+        }
+        return mainJar.getId() == 0
+                ? mainJar.getRes()
+                // when update resource maybe has error
+                : mainJar.getResourceName().replaceFirst(SINGLE_SLASH, "");
+    }
+
+    @Override
+    public void cancelApplication(boolean cancelApplication) throws Exception {
+        // cancel process
+        shellCommandExecutor.cancelApplication();
+    }
+
+    @Override
+    public AbstractParameters getParameters() {
+        return javaParameters;
+    }
+
+    /**
+     * @description: Replaces placeholders such as local variables in source files
+     * @param: [java.lang.String]
+     * @return: java.lang.String
+     **/
+    protected static String convertJavaSourceCodePlaceholders(String rawScript) throws StringIndexOutOfBoundsException {

Review Comment:
   This method has the wrong comment. It's not the same method as what you said. Sorry



-- 
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


[GitHub] [dolphinscheduler] sonarcloud[bot] commented on pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
sonarcloud[bot] commented on PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#issuecomment-1214347875

   SonarCloud Quality Gate failed.&nbsp; &nbsp; [![Quality Gate failed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/failed-16px.png 'Quality Gate failed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=10689)
   
   [![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png 'Bug')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG)  
   [![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png 'Vulnerability')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY)  
   [![Security Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png 'Security Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT)  
   [![Code Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png 'Code Smell')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL) [12 Code Smells](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL)
   
   [![0.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/0-16px.png '0.0%')](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_coverage&view=list) [0.0% Coverage](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_coverage&view=list)  
   [![1.9%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3-16px.png '1.9%')](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_duplicated_lines_density&view=list) [1.9% Duplication](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_duplicated_lines_density&view=list)
   
   


-- 
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


[GitHub] [dolphinscheduler] 106umao commented on a diff in pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
106umao commented on code in PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#discussion_r945301740


##########
dolphinscheduler-task-plugin/dolphinscheduler-task-java/src/main/java/org/apache/dolphinscheduler/plugin/task/java/JavaTask.java:
##########
@@ -0,0 +1,422 @@
+/*
+ * 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 static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.SINGLE_SLASH;
+import static org.apache.dolphinscheduler.plugin.task.java.JavaConstants.JAVA_HOME_VAR;
+import static org.apache.dolphinscheduler.plugin.task.java.JavaConstants.PUBLIC_CLASS_NAME_REGEX;
+
+
+import org.apache.dolphinscheduler.plugin.task.api.AbstractTaskExecutor;
+import org.apache.dolphinscheduler.plugin.task.api.ShellCommandExecutor;
+import org.apache.dolphinscheduler.plugin.task.api.TaskConstants;
+import org.apache.dolphinscheduler.plugin.task.api.TaskException;
+import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext;
+import org.apache.dolphinscheduler.plugin.task.api.model.Property;
+import org.apache.dolphinscheduler.plugin.task.api.model.ResourceInfo;
+import org.apache.dolphinscheduler.plugin.task.api.model.TaskResponse;
+import org.apache.dolphinscheduler.plugin.task.api.parameters.AbstractParameters;
+import org.apache.dolphinscheduler.plugin.task.api.parser.ParamUtils;
+import org.apache.dolphinscheduler.plugin.task.api.parser.ParameterUtils;
+import org.apache.dolphinscheduler.plugin.task.api.utils.MapUtils;
+import org.apache.dolphinscheduler.plugin.task.java.exception.JavaSourceFileExistException;
+import org.apache.dolphinscheduler.plugin.task.java.exception.PublicClassNotFoundException;
+import org.apache.dolphinscheduler.plugin.task.java.exception.RunTypeNotFoundException;
+import org.apache.dolphinscheduler.spi.utils.JSONUtils;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.lang3.SystemUtils;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import com.google.common.base.Preconditions;
+
+/**
+ * java task
+ */
+public class JavaTask extends AbstractTaskExecutor {
+
+    /**
+     * Contains various parameters for this task
+     */
+    private JavaParameters javaParameters;
+
+    /**
+     * To run shell commands
+     */
+    private ShellCommandExecutor shellCommandExecutor;
+
+    /**
+     * task execution context
+     */
+    private TaskExecutionContext taskRequest;
+
+    /**
+     * class name regex pattern
+     */
+    private static final Pattern classNamePattern = Pattern.compile(PUBLIC_CLASS_NAME_REGEX);
+
+    /**
+     * @description: Construct a Java task
+     * @param: [org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext]
+     * @return: JavaTask
+     **/
+    public JavaTask(TaskExecutionContext taskRequest) {
+        super(taskRequest);
+        this.taskRequest = taskRequest;
+        this.shellCommandExecutor = new ShellCommandExecutor(this::logHandle,
+                taskRequest,
+                logger);
+    }
+
+    /**
+     * @description: Initializes a Java task
+     * @param: []
+     * @return: void
+     **/
+    @Override
+    public void init() {
+        logger.info("java task params {}", taskRequest.getTaskParams());
+        javaParameters = JSONUtils.parseObject(taskRequest.getTaskParams(), JavaParameters.class);
+        if (javaParameters == null || !javaParameters.checkParameters()) {
+            throw new TaskException("java task params is not valid");
+        }
+        if (javaParameters.getRunType().equals(JavaConstants.RUN_TYPE_JAR)) {
+            setMainJarName();
+        }
+    }
+
+    /**
+     * @description: Gets the Java source file that was initially processed
+     * @param: []
+     * @return: java.lang.String
+     **/
+    @Override
+    public String getPreScript() {
+        String rawJavaScript = javaParameters.getRawScript().replaceAll("\\r\\n", "\n");
+        try {
+            rawJavaScript = convertJavaSourceCodePlaceholders(rawJavaScript);
+        } catch (StringIndexOutOfBoundsException e) {
+            logger.error("setShareVar field format error, raw java script : {}", rawJavaScript);
+        }
+        return rawJavaScript;
+    }
+
+    /**
+     * @description: Execute Java tasks
+     * @param: []
+     * @return: void
+     **/
+    @Override
+    public void handle() throws Exception {
+        try {
+            // Step 1: judge if is java or jar run type.
+            // Step 2 case1: The jar run type builds the command directly, adding resource to the java -jar class when building the command
+            // Step 2 case2: The java run type, first replace the custom parameters, then compile the code, and then build the command will add resource
+            // Step 3: To run the command
+            String command = null;
+            switch (javaParameters.getRunType()) {
+                case JavaConstants.RUN_TYPE_JAVA:
+                    command = buildJavaCommand();
+                    break;
+                case JavaConstants.RUN_TYPE_JAR:
+                    command = buildJarCommand();
+                    break;
+                default:
+                    throw new RunTypeNotFoundException("run type is required, but it is null now.");
+            }
+            Preconditions.checkNotNull(command, "command not be null.");
+            TaskResponse taskResponse = shellCommandExecutor.run(command);
+            logger.info("java task run result : {}", taskResponse);
+            setExitStatusCode(taskResponse.getExitStatusCode());
+            setAppIds(taskResponse.getAppIds());
+            setProcessId(taskResponse.getProcessId());
+            setVarPool(shellCommandExecutor.getVarPool());
+        } catch (InterruptedException e) {
+            logger.error("java task interrupted ", e);
+            setExitStatusCode(TaskConstants.EXIT_CODE_FAILURE);
+            Thread.currentThread().interrupt();
+        } catch (RunTypeNotFoundException e) {
+            logger.error(e.getMessage());
+            setExitStatusCode(TaskConstants.EXIT_CODE_FAILURE);
+            throw e;
+        } catch (Exception e) {
+            logger.error("java task failed ", e);
+            setExitStatusCode(TaskConstants.EXIT_CODE_FAILURE);
+            throw new TaskException("run java task error", e);
+        }
+    }
+
+    /**
+     * @description: Construct a shell command for the java Run mode
+     * @param: []
+     * @return: java.lang.String
+     **/
+    protected String buildJavaCommand() throws Exception {
+        String sourceCode = buildJavaSourceContent();
+        String className = compilerRawScript(sourceCode);
+        StringBuilder builder = new StringBuilder();
+        builder.append(getJavaCommandPath())
+                .append("java").append(" ")
+                .append(buildResourcePath())
+                .append(" ")
+                .append(className).append(" ")
+                .append(javaParameters.getMainArgs().trim()).append(" ")
+                .append(javaParameters.getJvmArgs().trim());
+        return builder.toString();
+    }
+
+    private void setMainJarName() {
+        ResourceInfo mainJar = javaParameters.getMainJar();
+        String resourceName = getResourceNameOfMainJar(mainJar);
+        mainJar.setRes(resourceName);
+        javaParameters.setMainJar(mainJar);
+    }
+
+    /**
+     * @description: Construct a shell command for the java -jar Run mode
+     * @param: []
+     * @return: java.lang.String
+     **/
+    protected String buildJarCommand() {
+        String fullName = javaParameters.getMainJar().getResourceName();
+        String mainJarName = fullName.substring(0, fullName.lastIndexOf('.'));
+        mainJarName = mainJarName.substring(mainJarName.lastIndexOf('.') + 1) + ".jar";
+        StringBuilder builder = new StringBuilder();
+        builder.append(getJavaCommandPath())
+                .append("java").append(" ")
+                .append(buildResourcePath()).append(" ")
+                .append("-jar").append(" ")
+                .append(taskRequest.getExecutePath())
+                .append(mainJarName).append(" ")
+                .append(javaParameters.getMainArgs().trim()).append(" ")
+                .append(javaParameters.getJvmArgs().trim());
+        return builder.toString();
+    }
+
+    private String getResourceNameOfMainJar(ResourceInfo mainJar) {
+        if (null == mainJar) {
+            throw new RuntimeException("The jar for the task is required.");
+        }
+        return mainJar.getId() == 0
+                ? mainJar.getRes()
+                // when update resource maybe has error
+                : mainJar.getResourceName().replaceFirst(SINGLE_SLASH, "");
+    }
+
+    @Override
+    public void cancelApplication(boolean cancelApplication) throws Exception {
+        // cancel process
+        shellCommandExecutor.cancelApplication();
+    }
+
+    @Override
+    public AbstractParameters getParameters() {
+        return javaParameters;
+    }
+
+    /**
+     * @description: Replaces placeholders such as local variables in source files
+     * @param: [java.lang.String]
+     * @return: java.lang.String
+     **/
+    protected static String convertJavaSourceCodePlaceholders(String rawScript) throws StringIndexOutOfBoundsException {
+        int len = "${setShareVar(${".length();
+        int scriptStart = 0;
+        while ((scriptStart = rawScript.indexOf("${setShareVar(${", scriptStart)) != -1) {
+            int start = -1;
+            int end = rawScript.indexOf('}', scriptStart + len);
+            String prop = rawScript.substring(scriptStart + len, end);
+
+            start = rawScript.indexOf(',', end);
+            end = rawScript.indexOf(')', start);
+
+            String value = rawScript.substring(start + 1, end);
+
+            start = rawScript.indexOf('}', start) + 1;
+            end = rawScript.length();
+
+            String replaceScript = String.format("print(\"${{setValue({},{})}}\".format(\"%s\",%s))", prop, value);
+
+            rawScript = rawScript.substring(0, scriptStart) + replaceScript + rawScript.substring(start, end);
+
+            scriptStart += replaceScript.length();
+        }
+        return rawScript;
+    }
+
+    /**
+     * @description: Creates a Java source file when it does not exist
+     * @param: [java.lang.String, java.lang.String]
+     * @return: java.lang.String
+     **/
+    protected void createJavaSourceFileIfNotExists(String sourceCode, String fileName) throws IOException {
+        logger.info("tenantCode: {}, task dir:{}", taskRequest.getTenantCode(), taskRequest.getExecutePath());
+
+        if (!Files.exists(Paths.get(fileName))) {
+            logger.info("generate java source file: {}", fileName);
+
+            StringBuilder sb = new StringBuilder();
+            sb.append(sourceCode);
+            logger.info(sb.toString());
+
+            // write data to file
+            FileUtils.writeStringToFile(new File(fileName),
+                    sb.toString(),
+                    StandardCharsets.UTF_8);

Review Comment:
   Thank you. The test code is not clean



-- 
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


[GitHub] [dolphinscheduler] zhuangchong merged pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
zhuangchong merged PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689


-- 
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


[GitHub] [dolphinscheduler] 106umao commented on a diff in pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
106umao commented on code in PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#discussion_r915773783


##########
docs/docs/en/guide/task/java.md:
##########
@@ -0,0 +1,67 @@
+# Overview
+
+This node is used to perform java-type tasks and supports the use of single files and jar packages as program entries.
+
+# Create Tasks
+
+- Click on project management-> Project name-> workflow definition, click on the“Create workflow” button, go to the DAG edit page:
+
+- Drag the toolbar's Java task node to the palette.
+
+# Task Parameters
+
+- Node Name: the name of the set task. The node name in a workflow definition is unique.
+
+- Run Flag: indicates whether the node is scheduled properly and, if it is not needed, turns on the kill switch.
+
+- Description: describes the functionality of the node.
+
+- Task Priority: when the number of worker threads is insufficient, the worker is executed according to the priority from high to low. When the priority is the same, the worker is executed according to the first in, first out principle.
+
+- Worker Group: The machine whose task is assigned to the Worker group executes, and selecting Default will randomly select a Worker machine to execute.
+
+- Environment Name: configure the environment in which the task runs.
+
+- Number Of Failed Retries: number of resubmitted tasks that failed, supported drop-down and hand-fill.
+
+- Failed Retry Interval: the interval between tasks that fail and are resubmitted, supported by drop-down and hand-fill.
+
+- Delayed Execution Time: the amount of time a task is delayed, in units.
+
+- Timeout Alarm: Check timeout warning, timeout failure, when the task exceeds the“Timeout length”, send a warning message and the task execution fails.
+
+- Module Path: turn on the use of Java 9 + 's modularity feature, put all resources into-module-path, and require that the JDK version in your worker support modularity.
+
+- Main Parameter: as a normal Java program main method entry parameter.
+
+- Java VM Parameters: configure startup virtual machine parameters.
+
+- Script: you need to write Java code if you use the Java run type. The public class must exist in the code without writing a package statement.
+
+- Resources: these can be external JAR packages or other resource files that are added to the Classpath or module path and can be easily retrieved in your JAVA script.
+
+- Custom parameter: a user-defined parameter that is part of HTTP and replaces the contents of the script with the ${ variable } .
+
+- Pre Tasks: selecting a pre-task for the current task sets the selected pre-task upstream of the current task.
+
+## Example
+
+HTTP defines the different methods of interacting with the server, and the four most basic methods are GET, POST, PUT, and DELETE. Here we use the HTTP task node to demonstrate the use of POST to send a request to the system's login page and submit data.
+
+The main configuration parameters are as follows:
+
+- Run Type
+
+- Module Path
+
+- Main Parameters
+
+- Java VM Parameters
+
+- Script 
+
+![java_task](../../../../img/tasks/demo/java_task02.png)
+
+## Notice

Review Comment:
   thx, it is done



-- 
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


[GitHub] [dolphinscheduler] 106umao commented on a diff in pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
106umao commented on code in PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#discussion_r921247552


##########
dolphinscheduler-ui/src/views/projects/task/components/node/fields/use-main-jar.ts:
##########
@@ -26,7 +26,7 @@ export function useMainJar(model: { [field: string]: any }): IJsonItem {
   const mainJarOptions = ref([] as IMainJar[])
   const taskStore = useTaskNodeStore()
 
-  const mainJarSpan = computed(() => (model.programType === 'SQL' ? 0 : 24))
+  const mainJarSpan = computed(() => (model.programType === 'SQL' ? 0 : 24));

Review Comment:
   it is done



-- 
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


[GitHub] [dolphinscheduler] sonarcloud[bot] commented on pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
sonarcloud[bot] commented on PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#issuecomment-1184597967

   SonarCloud Quality Gate failed.&nbsp; &nbsp; [![Quality Gate failed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/failed-16px.png 'Quality Gate failed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=10689)
   
   [![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png 'Bug')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG)  
   [![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png 'Vulnerability')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY)  
   [![Security Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png 'Security Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT)  
   [![Code Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png 'Code Smell')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL) [14 Code Smells](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL)
   
   [![0.4%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/0-16px.png '0.4%')](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_coverage&view=list) [0.4% Coverage](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_coverage&view=list)  
   [![2.2%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3-16px.png '2.2%')](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_duplicated_lines_density&view=list) [2.2% Duplication](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_duplicated_lines_density&view=list)
   
   


-- 
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


[GitHub] [dolphinscheduler] 106umao commented on a diff in pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
106umao commented on code in PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#discussion_r930809299


##########
dolphinscheduler-task-plugin/dolphinscheduler-task-java/src/main/java/org/apache/dolphinscheduler/plugin/task/java/JavaParameters.java:
##########
@@ -0,0 +1,89 @@
+/*
+ * 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 org.apache.dolphinscheduler.plugin.task.api.model.ResourceInfo;
+import org.apache.dolphinscheduler.plugin.task.api.parameters.AbstractParameters;
+
+import java.util.List;
+
+import lombok.Getter;
+import lombok.Setter;
+import lombok.ToString;
+
+@Getter
+@Setter
+@ToString
+public class JavaParameters extends AbstractParameters {
+    /**
+     * origin java script
+     */
+    private String rawScript;
+
+    /**
+     * run in jar file
+     */
+    private ResourceInfo mainJar;
+
+    /**
+     * run type is JAVA or JAR
+     */
+    private String runType;
+
+    /**
+     * main method args
+     **/
+    private String mainArgs;
+
+    /**
+     * jvm args
+     **/
+    private String jvmArgs;
+
+    /**
+     * module path or class path flag
+     **/
+    private boolean isModulePath;
+
+    /**
+     * resource list
+     */
+    private List<ResourceInfo> resourceList;
+
+    /**
+     * @description:
+     * @date: 7/22/22 2:35 AM
+     * @param: []

Review Comment:
   > can we remove this unnecessary part? same as function `getResourceFilesList`
   
   this part still left cause extend the AbstractParameter, I not sure can delete



-- 
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


[GitHub] [dolphinscheduler] 106umao commented on pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
106umao commented on PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#issuecomment-1196467577

   > I add some comments on the English version docs. Thanks.
   
   Thanks,I still need to learn from you


-- 
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


[GitHub] [dolphinscheduler] zhongjiajie commented on a diff in pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
zhongjiajie commented on code in PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#discussion_r930569935


##########
docs/docs/en/guide/task/java.md:
##########
@@ -0,0 +1,48 @@
+# Overview
+
+This node is used to perform java-type tasks and supports the use of single files and jar packages as program entries.
+
+# Create Tasks
+
+- Click on project management-> Project name-> workflow definition, click on the“Create workflow” button, go to the DAG edit page:
+
+- Drag the toolbar's Java task node to the palette.
+
+# Task Parameters
+| **Parameter** | **Description** |
+| ------- | ---------- |
+|Node Name|the name of the set task. The node name in a workflow definition is unique.
+|Run Flag|indicates whether the node is scheduled properly and, if it is not needed, turns on the kill switch.
+|Description|describes the functionality of the node.
+|Task Priority|when the number of worker threads is insufficient, the worker is executed according to the priority from high to low. When the priority is the same, the worker is executed according to the first in, first out principle.
+|Worker Group|The machine whose task is assigned to the Worker group executes, and selecting Default will randomly select a Worker machine to execute.
+|Environment Name|configure the environment in which the task runs.
+|Number Of Failed Retries|number of resubmitted tasks that failed, supported drop-down and hand-fill.
+|Failed Retry Interval|the interval between tasks that fail and are resubmitted, supported by drop-down and hand-fill.
+|Delayed Execution Time|the amount of time a task is delayed, in units.
+|Timeout Alarm|Check timeout warning, timeout failure, when the task exceeds the“Timeout length”, send a warning message and the task execution fails.
+|Module Path|turn on the use of Java 9 + 's modularity feature, put all resources into-module-path, and require that the JDK version in your worker support modularity.
+|Main Parameter|as a normal Java program main method entry parameter.
+|Java VM Parameters|configure startup virtual machine parameters.
+|Script|you need to write Java code if you use the Java run type. The public class must exist in the code without writing a package statement.
+|Resources|these can be external JAR packages or other resource files that are added to the Classpath or module path and can be easily retrieved in your JAVA script.
+|Custom parameter|a user-defined parameter that is part of HTTP and replaces the contents of the script with the ${ variable } .
+|Pre Tasks|selecting a pre-task for the current task sets the selected pre-task upstream of the current task.

Review Comment:
   can you add `|` in the end of this table to make it supports the full Markdown table format? 
   
   ```diff
   - |Node Name|the name of the set task. The node name in a workflow definition is unique.
   + | Node Name | the name of the set task. The node name in a workflow definition is unique. |
   ```



##########
docs/docs/en/guide/task/java.md:
##########
@@ -0,0 +1,48 @@
+# Overview
+
+This node is used to perform java-type tasks and supports the use of single files and jar packages as program entries.
+
+# Create Tasks
+
+- Click on project management-> Project name-> workflow definition, click on the“Create workflow” button, go to the DAG edit page:
+
+- Drag the toolbar's Java task node to the palette.
+
+# Task Parameters
+| **Parameter** | **Description** |
+| ------- | ---------- |
+|Node Name|the name of the set task. The node name in a workflow definition is unique.
+|Run Flag|indicates whether the node is scheduled properly and, if it is not needed, turns on the kill switch.
+|Description|describes the functionality of the node.
+|Task Priority|when the number of worker threads is insufficient, the worker is executed according to the priority from high to low. When the priority is the same, the worker is executed according to the first in, first out principle.
+|Worker Group|The machine whose task is assigned to the Worker group executes, and selecting Default will randomly select a Worker machine to execute.
+|Environment Name|configure the environment in which the task runs.
+|Number Of Failed Retries|number of resubmitted tasks that failed, supported drop-down and hand-fill.
+|Failed Retry Interval|the interval between tasks that fail and are resubmitted, supported by drop-down and hand-fill.
+|Delayed Execution Time|the amount of time a task is delayed, in units.
+|Timeout Alarm|Check timeout warning, timeout failure, when the task exceeds the“Timeout length”, send a warning message and the task execution fails.
+|Module Path|turn on the use of Java 9 + 's modularity feature, put all resources into-module-path, and require that the JDK version in your worker support modularity.
+|Main Parameter|as a normal Java program main method entry parameter.
+|Java VM Parameters|configure startup virtual machine parameters.
+|Script|you need to write Java code if you use the Java run type. The public class must exist in the code without writing a package statement.
+|Resources|these can be external JAR packages or other resource files that are added to the Classpath or module path and can be easily retrieved in your JAVA script.
+|Custom parameter|a user-defined parameter that is part of HTTP and replaces the contents of the script with the ${ variable } .
+|Pre Tasks|selecting a pre-task for the current task sets the selected pre-task upstream of the current task.
+
+## Example
+
+Java task types have two modes of execution, which are demonstrated here as an example of a Java mode.
+
+The main configuration parameters are as follows:
+- Run Type
+- Module Path
+- Main Parameters
+- Java VM Parameters
+

Review Comment:
   ```suggestion
   ```



##########
dolphinscheduler-task-plugin/dolphinscheduler-task-java/src/main/java/org/apache/dolphinscheduler/plugin/task/java/JavaParameters.java:
##########
@@ -0,0 +1,89 @@
+/*
+ * 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 org.apache.dolphinscheduler.plugin.task.api.model.ResourceInfo;
+import org.apache.dolphinscheduler.plugin.task.api.parameters.AbstractParameters;
+
+import java.util.List;
+
+import lombok.Getter;
+import lombok.Setter;
+import lombok.ToString;
+
+@Getter
+@Setter
+@ToString
+public class JavaParameters extends AbstractParameters {
+    /**
+     * origin java script
+     */
+    private String rawScript;
+
+    /**
+     * run in jar file
+     */
+    private ResourceInfo mainJar;
+
+    /**
+     * run type is JAVA or JAR
+     */
+    private String runType;
+
+    /**
+     * main method args
+     **/
+    private String mainArgs;
+
+    /**
+     * jvm args
+     **/
+    private String jvmArgs;
+
+    /**
+     * module path or class path flag
+     **/
+    private boolean isModulePath;
+
+    /**
+     * resource list
+     */
+    private List<ResourceInfo> resourceList;
+
+    /**
+     * @description:
+     * @date: 7/22/22 2:35 AM
+     * @param: []

Review Comment:
   I find it still in class `JavaTask.java`, could you search global and remove them?



##########
dolphinscheduler-task-plugin/dolphinscheduler-task-java/src/main/java/org/apache/dolphinscheduler/plugin/task/java/JavaParameters.java:
##########
@@ -0,0 +1,89 @@
+/*
+ * 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 org.apache.dolphinscheduler.plugin.task.api.model.ResourceInfo;
+import org.apache.dolphinscheduler.plugin.task.api.parameters.AbstractParameters;
+
+import java.util.List;
+
+import lombok.Getter;
+import lombok.Setter;
+import lombok.ToString;
+
+@Getter
+@Setter
+@ToString
+public class JavaParameters extends AbstractParameters {
+    /**
+     * origin java script
+     */
+    private String rawScript;
+
+    /**
+     * run in jar file
+     */
+    private ResourceInfo mainJar;
+
+    /**
+     * run type is JAVA or JAR
+     */
+    private String runType;
+
+    /**
+     * main method args
+     **/
+    private String mainArgs;
+
+    /**
+     * jvm args
+     **/
+    private String jvmArgs;
+
+    /**
+     * module path or class path flag
+     **/
+    private boolean isModulePath;
+
+    /**
+     * resource list
+     */
+    private List<ResourceInfo> resourceList;
+
+    /**
+     * @description:
+     * @date: 7/22/22 2:35 AM
+     * @param: []

Review Comment:
   can we remove this unnecessary part? same as function `getResourceFilesList`



-- 
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


[GitHub] [dolphinscheduler] sonarcloud[bot] commented on pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
sonarcloud[bot] commented on PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#issuecomment-1172926238

   SonarCloud Quality Gate failed.&nbsp; &nbsp; [![Quality Gate failed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/failed-16px.png 'Quality Gate failed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=10689)
   
   [![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png 'Bug')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG)  
   [![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png 'Vulnerability')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY)  
   [![Security Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png 'Security Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT) [![E](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/E-16px.png 'E')](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT) [1 Security Hotspot](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT)  
   [![Code Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png 'Code Smell')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL) [24 Code Smells](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL)
   
   [![0.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/0-16px.png '0.0%')](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_coverage&view=list) [0.0% Coverage](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_coverage&view=list)  
   [![2.1%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3-16px.png '2.1%')](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_duplicated_lines_density&view=list) [2.1% Duplication](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_duplicated_lines_density&view=list)
   
   


-- 
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


[GitHub] [dolphinscheduler] 106umao commented on pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
106umao commented on PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#issuecomment-1200445565

   Hi, @SbloodyS PTAL


-- 
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


[GitHub] [dolphinscheduler] sonarcloud[bot] commented on pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
sonarcloud[bot] commented on PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#issuecomment-1203007960

   SonarCloud Quality Gate failed.&nbsp; &nbsp; [![Quality Gate failed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/failed-16px.png 'Quality Gate failed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=10689)
   
   [![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png 'Bug')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG)  
   [![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png 'Vulnerability')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY)  
   [![Security Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png 'Security Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT)  
   [![Code Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png 'Code Smell')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL) [13 Code Smells](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL)
   
   [![0.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/0-16px.png '0.0%')](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_coverage&view=list) [0.0% Coverage](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_coverage&view=list)  
   [![1.8%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3-16px.png '1.8%')](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_duplicated_lines_density&view=list) [1.8% Duplication](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_duplicated_lines_density&view=list)
   
   


-- 
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


[GitHub] [dolphinscheduler] sonarcloud[bot] commented on pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
sonarcloud[bot] commented on PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#issuecomment-1211805256

   SonarCloud Quality Gate failed.&nbsp; &nbsp; [![Quality Gate failed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/failed-16px.png 'Quality Gate failed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=10689)
   
   [![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png 'Bug')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG)  
   [![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png 'Vulnerability')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY)  
   [![Security Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png 'Security Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT)  
   [![Code Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png 'Code Smell')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL) [13 Code Smells](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL)
   
   [![0.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/0-16px.png '0.0%')](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_coverage&view=list) [0.0% Coverage](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_coverage&view=list)  
   [![1.9%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3-16px.png '1.9%')](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_duplicated_lines_density&view=list) [1.9% Duplication](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_duplicated_lines_density&view=list)
   
   


-- 
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


[GitHub] [dolphinscheduler] 106umao commented on pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
106umao commented on PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#issuecomment-1211660843

   > LGTM as long as CI passes.
   
   thanks,  I have done some work again. PTAL


-- 
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


[GitHub] [dolphinscheduler] sonarcloud[bot] commented on pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
sonarcloud[bot] commented on PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#issuecomment-1231117879

   SonarCloud Quality Gate failed.&nbsp; &nbsp; [![Quality Gate failed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/failed-16px.png 'Quality Gate failed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=10689)
   
   [![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png 'Bug')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG)  
   [![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png 'Vulnerability')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY)  
   [![Security Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png 'Security Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT)  
   [![Code Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png 'Code Smell')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL) [8 Code Smells](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL)
   
   [![0.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/0-16px.png '0.0%')](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_coverage&view=list) [0.0% Coverage](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_coverage&view=list)  
   [![2.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3-16px.png '2.0%')](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_duplicated_lines_density&view=list) [2.0% Duplication](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_duplicated_lines_density&view=list)
   
   


-- 
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


[GitHub] [dolphinscheduler] 106umao commented on a diff in pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
106umao commented on code in PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#discussion_r957971836


##########
dolphinscheduler-ui/src/views/projects/task/constants/task-type.ts:
##########
@@ -47,6 +48,9 @@ export type TaskType =
 export type TaskExecuteType = 'STREAM' | 'BATCH'
 
 export const TASK_TYPES_MAP = {
+  JAVA: {
+    alias: 'JAVA'
+  },

Review Comment:
   Yes



-- 
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


[GitHub] [dolphinscheduler] 106umao commented on a diff in pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
106umao commented on code in PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#discussion_r965444771


##########
pom.xml:
##########
@@ -261,6 +262,12 @@
                 <version>${project.version}</version>
             </dependency>
 
+            <dependency>
+                <groupId>mysql</groupId>
+                <artifactId>mysql-connector-java</artifactId>
+                <version>${mysql.connector.version}</version>
+            </dependency>
+

Review Comment:
   have done



-- 
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


[GitHub] [dolphinscheduler] sonarcloud[bot] commented on pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
sonarcloud[bot] commented on PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#issuecomment-1239774618

   SonarCloud Quality Gate failed.&nbsp; &nbsp; [![Quality Gate failed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/failed-16px.png 'Quality Gate failed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=10689)
   
   [![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png 'Bug')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG)  
   [![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png 'Vulnerability')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY)  
   [![Security Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png 'Security Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT)  
   [![Code Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png 'Code Smell')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL) [8 Code Smells](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL)
   
   [![0.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/0-16px.png '0.0%')](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_coverage&view=list) [0.0% Coverage](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_coverage&view=list)  
   [![2.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3-16px.png '2.0%')](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_duplicated_lines_density&view=list) [2.0% Duplication](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_duplicated_lines_density&view=list)
   
   


-- 
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


[GitHub] [dolphinscheduler] zhuangchong commented on a diff in pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
zhuangchong commented on code in PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#discussion_r920779818


##########
dolphinscheduler-ui/src/views/projects/task/components/node/fields/use-main-jar.ts:
##########
@@ -26,7 +26,7 @@ export function useMainJar(model: { [field: string]: any }): IJsonItem {
   const mainJarOptions = ref([] as IMainJar[])
   const taskStore = useTaskNodeStore()
 
-  const mainJarSpan = computed(() => (model.programType === 'SQL' ? 0 : 24))
+  const mainJarSpan = computed(() => (model.programType === 'SQL' ? 0 : 24));

Review Comment:
   No need to modify 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


[GitHub] [dolphinscheduler] SbloodyS commented on a diff in pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
SbloodyS commented on code in PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#discussion_r925747531


##########
dolphinscheduler-task-plugin/dolphinscheduler-task-java/src/main/java/org/apache/dolphinscheduler/plugin/task/java/JavaTask.java:
##########
@@ -0,0 +1,348 @@
+/*
+ * 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 static org.apache.dolphinscheduler.plugin.task.java.JavaConstants.PUBLIC_CLASS_NAME_REGEX;
+
+import org.apache.dolphinscheduler.plugin.task.api.AbstractTaskExecutor;
+import org.apache.dolphinscheduler.plugin.task.api.ShellCommandExecutor;
+import org.apache.dolphinscheduler.plugin.task.api.TaskConstants;
+import org.apache.dolphinscheduler.plugin.task.api.TaskException;
+import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext;
+import org.apache.dolphinscheduler.plugin.task.api.model.Property;
+import org.apache.dolphinscheduler.plugin.task.api.model.ResourceInfo;
+import org.apache.dolphinscheduler.plugin.task.api.model.TaskResponse;
+import org.apache.dolphinscheduler.plugin.task.api.parameters.AbstractParameters;
+import org.apache.dolphinscheduler.plugin.task.api.parser.ParamUtils;
+import org.apache.dolphinscheduler.plugin.task.api.parser.ParameterUtils;
+import org.apache.dolphinscheduler.plugin.task.api.utils.MapUtils;
+import org.apache.dolphinscheduler.plugin.task.java.exception.JavaSourceFileExistException;
+import org.apache.dolphinscheduler.plugin.task.java.exception.PublicClassNotFoundException;
+import org.apache.dolphinscheduler.plugin.task.java.exception.RunTypeNotFoundException;
+import org.apache.dolphinscheduler.spi.utils.JSONUtils;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.lang3.SystemUtils;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import com.google.common.base.Preconditions;
+
+/**
+ * java task
+ */
+public class JavaTask extends AbstractTaskExecutor {
+
+    /**
+     * java parameters
+     */
+    private JavaParameters javaParameters;
+
+    /**
+     * shell command executor
+     */
+    private ShellCommandExecutor shellCommandExecutor;
+
+    /**
+     * task execution context
+     */
+    private TaskExecutionContext taskRequest;
+
+    private static final Pattern classNamePattern = Pattern.compile(PUBLIC_CLASS_NAME_REGEX);
+
+    /**
+     * constructor
+     *
+     * @param taskRequest taskRequest
+     */
+    public JavaTask(TaskExecutionContext taskRequest) {
+        super(taskRequest);
+        this.taskRequest = taskRequest;
+        this.shellCommandExecutor = new ShellCommandExecutor(this::logHandle,
+                taskRequest,
+                logger);
+    }
+
+    @Override
+    public void init() {
+        logger.info("java task params {}", taskRequest.getTaskParams());
+        javaParameters = JSONUtils.parseObject(taskRequest.getTaskParams(), JavaParameters.class);
+        if (javaParameters == null || !javaParameters.checkParameters()) {
+            throw new TaskException("java task params is not valid");
+        }
+        if (javaParameters.getRunType().equals(JavaConstants.RUN_TYPE_JAR)) {
+            setMainJarName();
+        }
+    }
+
+    @Override
+    public String getPreScript() {
+        String rawJavaScript = javaParameters.getRawScript().replaceAll("\\r\\n", "\n");
+        try {
+            rawJavaScript = convertJavaSourceCodePlaceholders(rawJavaScript);
+        } catch (StringIndexOutOfBoundsException e) {
+            logger.error("setShareVar field format error, raw java script : {}", rawJavaScript);
+        }
+        return rawJavaScript;
+    }
+
+    @Override
+    public void handle() throws Exception {
+        try {
+            // Step 1 judge if is java or jar run type.
+            // The  jar run type builds the command directly, adding resource to the java -jar class when building the command
+            // The java run type, first replace the custom parameters, then compile the code, and then build the command will add resource
+            // To run the coma
+            String command = null;
+            switch (javaParameters.getRunType()) {
+                case JavaConstants.RUN_TYPE_JAVA:
+                    command = buildJavaCommand();
+                    break;
+                case JavaConstants.RUN_TYPE_JAR:
+                    command = buildJarCommand();
+                    break;
+                default:
+                    throw new RunTypeNotFoundException("run type is required, but it is null now.");
+            }
+            Preconditions.checkNotNull(command, "command not be null.");
+            TaskResponse taskResponse = shellCommandExecutor.run(command);
+            logger.info("java task run result : " + taskResponse);
+            setExitStatusCode(taskResponse.getExitStatusCode());
+            setAppIds(taskResponse.getAppIds());
+            setProcessId(taskResponse.getProcessId());
+            setVarPool(shellCommandExecutor.getVarPool());
+        } catch (InterruptedException e) {
+            logger.error("java task interrupted ", e);
+            setExitStatusCode(TaskConstants.EXIT_CODE_FAILURE);
+            Thread.currentThread().interrupt();
+        } catch (Exception e) {
+            logger.error("java task failed ", e);
+            setExitStatusCode(TaskConstants.EXIT_CODE_FAILURE);
+            throw new TaskException("run java task error", e);
+        }
+    }
+
+    protected String buildJavaCommand() throws Exception {
+        String sourceCode = buildJavaSourceContent();
+        String className = compilerRawScript(sourceCode);
+        StringBuilder builder = new StringBuilder();
+        builder.append(getJavaHomeBinAbsolutePath())
+                .append("java").append(" ")
+                .append(buildResourcePath())
+                .append(" ")
+                .append(className).append(" ")
+                .append(javaParameters.getMainArgs().trim()).append(" ")
+                .append(javaParameters.getJvmArgs().trim());
+        return builder.toString();
+    }
+
+    private void setMainJarName() {
+        ResourceInfo mainJar = javaParameters.getMainJar();
+        String resourceName = getResourceNameOfMainJar(mainJar);
+        mainJar.setRes(resourceName);
+        javaParameters.setMainJar(mainJar);
+    }
+
+    private String getResourceNameOfMainJar(ResourceInfo mainJar) {
+        if (null == mainJar) {
+            throw new RuntimeException("The jar for the task is required.");
+        }
+
+        return mainJar.getId() == 0
+                ? mainJar.getRes()
+                // when update resource maybe has error
+                : mainJar.getResourceName().replaceFirst("/", "");
+    }
+
+    protected String buildJarCommand() {
+        String fullName = javaParameters.getMainJar().getResourceName();
+        String mainJarName = fullName.substring(0, fullName.lastIndexOf('.'));
+        mainJarName = mainJarName.substring(mainJarName.lastIndexOf('.') + 1) + ".jar";
+        StringBuilder builder = new StringBuilder();
+        builder.append(getJavaHomeBinAbsolutePath())
+                .append("java").append(" ")
+                .append(buildResourcePath()).append(" ")
+                .append("-jar").append(" ")
+                .append(taskRequest.getExecutePath())
+                .append(mainJarName).append(" ")
+                .append(javaParameters.getMainArgs().trim()).append(" ")
+                .append(javaParameters.getJvmArgs().trim());
+        return builder.toString();
+    }
+    
+    @Override
+    public void cancelApplication(boolean cancelApplication) throws Exception {
+        // cancel process
+        shellCommandExecutor.cancelApplication();
+    }
+
+    @Override
+    public AbstractParameters getParameters() {
+        return javaParameters;
+    }
+
+    /**
+     * convertJavaScriptPlaceholders
+     *
+     * @param rawScript rawScript
+     * @return String
+     * @throws StringIndexOutOfBoundsException StringIndexOutOfBoundsException
+     */
+    protected static String convertJavaSourceCodePlaceholders(String rawScript) throws StringIndexOutOfBoundsException {
+        int len = "${setShareVar(${".length();
+        int scriptStart = 0;
+        while ((scriptStart = rawScript.indexOf("${setShareVar(${", scriptStart)) != -1) {
+            int start = -1;
+            int end = rawScript.indexOf('}', scriptStart + len);
+            String prop = rawScript.substring(scriptStart + len, end);
+
+            start = rawScript.indexOf(',', end);
+            end = rawScript.indexOf(')', start);
+
+            String value = rawScript.substring(start + 1, end);
+
+            start = rawScript.indexOf('}', start) + 1;
+            end = rawScript.length();
+
+            String replaceScript = String.format("print(\"${{setValue({},{})}}\".format(\"%s\",%s))", prop, value);
+
+            rawScript = rawScript.substring(0, scriptStart) + replaceScript + rawScript.substring(start, end);
+
+            scriptStart += replaceScript.length();
+        }
+        return rawScript;
+    }
+
+    protected void createJavaSourceFileIfNotExists(String sourceCode, String fileName) throws IOException {
+        logger.info("tenantCode :{}, task dir:{}", taskRequest.getTenantCode(), taskRequest.getExecutePath());
+
+        if (!Files.exists(Paths.get(fileName))) {
+            logger.info("generate java source file:{}", fileName);
+
+            StringBuilder sb = new StringBuilder();
+            sb.append(sourceCode);
+            logger.info(sb.toString());
+
+            // write data to file
+            FileUtils.writeStringToFile(new File(fileName),
+                    sb.toString(),
+                    StandardCharsets.UTF_8);
+        } else {
+            throw new JavaSourceFileExistException("java source file exists, please report an issue on official.");
+        }
+    }
+
+    protected String buildJavaSourceCodeFileFullName(String publicClassName) {
+        return String.format(JavaConstants.JAVA_SOURCE_CODE_NAME_TEMPLATE, taskRequest.getExecutePath(), publicClassName);
+    }
+
+    protected String buildResourcePath() {
+        StringBuilder builder = new StringBuilder();
+        if (javaParameters.isModulePath()) {
+            builder.append("--module-path");
+        } else {
+            builder.append("--class-path");
+        }
+        builder.append(" ").append(JavaConstants.CLASSPATH_CURRENT_DIR)
+                .append(JavaConstants.PATH_SEPARATOR)
+                .append(taskRequest.getExecutePath());
+        for (ResourceInfo info : javaParameters.getResourceFilesList()) {
+            builder.append(JavaConstants.PATH_SEPARATOR);
+            builder.append(taskRequest.getExecutePath())
+                    .append(info.getResourceName());
+        }
+        return builder.toString();
+    }
+
+    protected String compilerRawScript(String sourceCode) throws IOException, InterruptedException {
+        String publicClassName = getPublicClassName(sourceCode);
+        String fileName =  buildJavaSourceCodeFileFullName(publicClassName);
+        createJavaSourceFileIfNotExists(sourceCode, fileName);
+        String compileCommand = buildJavaCompileCommand(fileName, sourceCode);
+        Preconditions.checkNotNull(compileCommand, "command not be null.");
+        TaskResponse compileResponse = shellCommandExecutor.run(compileCommand);
+        // must drop the command file ,if do not ,the next command will not run. because be limited the ShellCommandExecutor's create file rules
+        dropShellCommandFile();
+        shellCommandExecutor = new ShellCommandExecutor(this::logHandle,
+                taskRequest,
+                logger);
+        logger.info("java task code compile result : " + compileResponse);
+        return publicClassName;
+    }
+
+    private void dropShellCommandFile() throws IOException {
+        String commandFilePath = String.format("%s/%s.%s"
+                , taskRequest.getExecutePath()
+                , taskRequest.getTaskAppId()
+                , SystemUtils.IS_OS_WINDOWS ? "bat" : "command");
+        Path path = Paths.get(commandFilePath);
+        if (Files.exists(path)) {
+            Files.delete(path);
+        }
+    }
+
+    protected String buildJavaCompileCommand(String fileName, String sourceCode) throws IOException {
+
+        StringBuilder compilerCommand = new StringBuilder()
+                .append(getJavaHomeBinAbsolutePath())
+                .append("javac").append(" ")
+                .append(buildResourcePath()).append(" ")
+                .append(fileName);
+        return compilerCommand.toString();
+    }
+
+    protected String buildJavaSourceContent() {
+        String rawJavaScript = javaParameters.getRawScript().replaceAll("\\r\\n", "\n");
+        // replace placeholder
+
+        Map<String, Property> paramsMap = taskRequest.getPrepareParamsMap();
+        if (MapUtils.isEmpty(paramsMap)) {
+            paramsMap = new HashMap<>();
+        }
+        if (MapUtils.isNotEmpty(taskRequest.getParamsMap())) {
+            paramsMap.putAll(taskRequest.getParamsMap());
+        }
+        rawJavaScript = ParameterUtils.convertParameterPlaceholders(rawJavaScript, ParamUtils.convert(paramsMap));
+        logger.info("raw java script : {}", javaParameters.getRawScript());
+        return rawJavaScript;
+    }
+
+    private String getJavaHomeBinAbsolutePath() {
+        String javaHomeAbsolutePath = System.getenv(JavaConstants.JAVA_HOME);

Review Comment:
   It's better to use `${JAVA_HOME}` instead of this since this would invalidate the setting of environmental management. Just like we do in the python task plugin.
   
   At present, we write the configuration of environment management into the shell script and execute it through `source` to make the environment variables take effect.
   https://github.com/apache/dolphinscheduler/blob/25ded1e81b59a216275e6bbe26e0eb3e6f400f78/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/ShellCommandExecutor.java#L103-L114



-- 
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


[GitHub] [dolphinscheduler] sonarcloud[bot] commented on pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
sonarcloud[bot] commented on PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#issuecomment-1172855894

   SonarCloud Quality Gate failed.&nbsp; &nbsp; [![Quality Gate failed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/failed-16px.png 'Quality Gate failed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=10689)
   
   [![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png 'Bug')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG)  
   [![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png 'Vulnerability')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY)  
   [![Security Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png 'Security Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT) [![E](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/E-16px.png 'E')](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT) [1 Security Hotspot](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT)  
   [![Code Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png 'Code Smell')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL) [24 Code Smells](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL)
   
   [![0.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/0-16px.png '0.0%')](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_coverage&view=list) [0.0% Coverage](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_coverage&view=list)  
   [![2.1%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3-16px.png '2.1%')](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_duplicated_lines_density&view=list) [2.1% Duplication](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_duplicated_lines_density&view=list)
   
   


-- 
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


[GitHub] [dolphinscheduler] 106umao commented on a diff in pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
106umao commented on code in PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#discussion_r915772919


##########
docs/docs/en/guide/task/java.md:
##########
@@ -0,0 +1,67 @@
+# Overview
+
+This node is used to perform java-type tasks and supports the use of single files and jar packages as program entries.
+
+# Create Tasks
+
+- Click on project management-> Project name-> workflow definition, click on the“Create workflow” button, go to the DAG edit page:
+
+- Drag the toolbar's Java task node to the palette.
+
+# Task Parameters
+
+- Node Name: the name of the set task. The node name in a workflow definition is unique.
+

Review Comment:
   thx, it is done



##########
docs/docs/en/guide/task/java.md:
##########
@@ -0,0 +1,67 @@
+# Overview
+
+This node is used to perform java-type tasks and supports the use of single files and jar packages as program entries.
+
+# Create Tasks
+
+- Click on project management-> Project name-> workflow definition, click on the“Create workflow” button, go to the DAG edit page:
+
+- Drag the toolbar's Java task node to the palette.
+
+# Task Parameters
+
+- Node Name: the name of the set task. The node name in a workflow definition is unique.
+
+- Run Flag: indicates whether the node is scheduled properly and, if it is not needed, turns on the kill switch.
+
+- Description: describes the functionality of the node.
+
+- Task Priority: when the number of worker threads is insufficient, the worker is executed according to the priority from high to low. When the priority is the same, the worker is executed according to the first in, first out principle.
+
+- Worker Group: The machine whose task is assigned to the Worker group executes, and selecting Default will randomly select a Worker machine to execute.
+
+- Environment Name: configure the environment in which the task runs.
+
+- Number Of Failed Retries: number of resubmitted tasks that failed, supported drop-down and hand-fill.
+
+- Failed Retry Interval: the interval between tasks that fail and are resubmitted, supported by drop-down and hand-fill.
+
+- Delayed Execution Time: the amount of time a task is delayed, in units.
+
+- Timeout Alarm: Check timeout warning, timeout failure, when the task exceeds the“Timeout length”, send a warning message and the task execution fails.
+
+- Module Path: turn on the use of Java 9 + 's modularity feature, put all resources into-module-path, and require that the JDK version in your worker support modularity.
+
+- Main Parameter: as a normal Java program main method entry parameter.
+
+- Java VM Parameters: configure startup virtual machine parameters.
+
+- Script: you need to write Java code if you use the Java run type. The public class must exist in the code without writing a package statement.
+
+- Resources: these can be external JAR packages or other resource files that are added to the Classpath or module path and can be easily retrieved in your JAVA script.
+
+- Custom parameter: a user-defined parameter that is part of HTTP and replaces the contents of the script with the ${ variable } .
+
+- Pre Tasks: selecting a pre-task for the current task sets the selected pre-task upstream of the current task.
+
+## Example
+
+HTTP defines the different methods of interacting with the server, and the four most basic methods are GET, POST, PUT, and DELETE. Here we use the HTTP task node to demonstrate the use of POST to send a request to the system's login page and submit data.
+
+The main configuration parameters are as follows:
+
+- Run Type
+

Review Comment:
   thx, it is done



-- 
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


[GitHub] [dolphinscheduler] 106umao commented on a diff in pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
106umao commented on code in PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#discussion_r915775465


##########
dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/model/TaskResponse.java:
##########
@@ -123,4 +123,18 @@ public TaskRunStatus getStatus() {
     public void setStatus(TaskRunStatus status) {
         this.status = status;
     }
+
+    @Override
+    public String toString() {
+        return "TaskResponse{" +
+                "varPool='" + varPool + '\'' +
+                ", processId=" + processId +
+                ", resultString='" + resultString + '\'' +
+                ", appIds='" + appIds + '\'' +
+                ", process=" + process +
+                ", cancel=" + cancel +
+                ", exitStatusCode=" + exitStatusCode +
+                ", status=" + status +
+                '}';
+    }

Review Comment:
   thx, it is done



-- 
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


[GitHub] [dolphinscheduler] sonarcloud[bot] commented on pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
sonarcloud[bot] commented on PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#issuecomment-1178622239

   SonarCloud Quality Gate failed.&nbsp; &nbsp; [![Quality Gate failed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/failed-16px.png 'Quality Gate failed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=10689)
   
   [![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png 'Bug')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG)  
   [![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png 'Vulnerability')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY)  
   [![Security Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png 'Security Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT) [![E](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/E-16px.png 'E')](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT) [1 Security Hotspot](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT)  
   [![Code Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png 'Code Smell')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL) [16 Code Smells](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL)
   
   [![0.4%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/0-16px.png '0.4%')](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_coverage&view=list) [0.4% Coverage](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_coverage&view=list)  
   [![2.2%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3-16px.png '2.2%')](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_duplicated_lines_density&view=list) [2.2% Duplication](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_duplicated_lines_density&view=list)
   
   


-- 
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


[GitHub] [dolphinscheduler] 106umao commented on a diff in pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
106umao commented on code in PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#discussion_r916588355


##########
dolphinscheduler-task-plugin/dolphinscheduler-task-java/src/main/test/org/apache/dolphinscheduler/plugin/task/java/JavaTaskTest.java:
##########
@@ -0,0 +1,161 @@
+/*
+ * 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 org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext;
+import org.apache.dolphinscheduler.plugin.task.api.model.Property;
+import org.apache.dolphinscheduler.plugin.task.api.model.ResourceInfo;
+import org.apache.dolphinscheduler.spi.utils.JSONUtils;
+import org.junit.Assert;
+import org.junit.Test;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import static org.apache.dolphinscheduler.plugin.task.api.enums.DataType.VARCHAR;
+import static org.apache.dolphinscheduler.plugin.task.api.enums.Direct.IN;
+import static org.apache.dolphinscheduler.plugin.task.java.JavaConstants.RUN_TYPE_JAR;
+import static org.apache.dolphinscheduler.plugin.task.java.JavaConstants.RUN_TYPE_JAVA;
+import java.io.IOException;
+public class JavaTaskTest {
+    @Test
+    public void testJavaHome() {
+        Assert.assertNotNull(System.getenv().get("JAVA_HOME"));
+    }
+
+
+    @Test
+    public void buildJarCommand() {
+        String homePath = System.getenv(JavaConstants.JAVA_HOME);
+        Assert.assertNotNull(homePath);
+        String homeBinPath =  homePath+ System.getProperty("file.separator") + "bin" + System.getProperty("file.separator");
+        JavaTask javaTask = runJarType();
+        Assert.assertEquals(javaTask.buildJarCommand(), homeBinPath
+                +"java --class-path .:/tmp/dolphinscheduler/test/executepath:/tmp/dolphinscheduler/test/executepath/opt/share/jar/resource2.jar -jar /tmp/dolphinscheduler/test/executepath/opt/share/jar/main.jar -host 127.0.0.1 -port 8080 -xms:50m");
+    }
+
+    @Test
+    public void buildJavaCompileCommand() throws IOException {
+        JavaTask javaTask = runJavaType();
+        String sourceCode = javaTask.buildJavaSourceContent();
+        String publicClassName = javaTask.getPublicClassName(sourceCode);
+        Assert.assertEquals("JavaTaskTest", publicClassName);
+        String fileName = javaTask.buildJavaSourceCodeFileFullName(publicClassName);
+        try {
+            String homePath = System.getenv(JavaConstants.JAVA_HOME);
+            Assert.assertNotNull(homePath);
+            String homeBinPath = homePath + System.getProperty("file.separator") + "bin" + System.getProperty("file.separator");
+            Path path = Paths.get(fileName);
+            if (Files.exists(path)) {
+                Files.delete(path);
+            }
+            javaTask.createJavaSourceFileIfNotExists(sourceCode, fileName);
+            Assert.assertEquals(homeBinPath
+                    +"javac --class-path .:/tmp/dolphinscheduler/test/executepath:/tmp/dolphinscheduler/test/executepath/opt/share/jar/resource2.jar /tmp/dolphinscheduler/test/executepath/JavaTaskTest.java", javaTask.buildJavaCompileCommand(fileName, sourceCode));
+
+        } finally {
+            Path path = Paths.get(fileName);
+            if (Files.exists(path)) {
+                Files.delete(path);
+            }
+        }
+
+    }
+
+
+    @Test
+    public void buildJavaCommand() throws Exception {
+        String homePath = System.getenv(JavaConstants.JAVA_HOME);
+        Assert.assertNotNull(homePath);
+        String homeBinPath =  homePath+ System.getProperty("file.separator") + "bin" + System.getProperty("file.separator");
+        JavaTask javaTask = runJavaType();
+        String sourceCode = javaTask.buildJavaSourceContent();
+        String publicClassName = javaTask.getPublicClassName(sourceCode);
+        Assert.assertEquals("JavaTaskTest", publicClassName);
+        String fileName = javaTask.buildJavaSourceCodeFileFullName(publicClassName);
+        Path path = Paths.get(fileName);
+        if (Files.exists(path)) {
+            Files.delete(path);
+        }
+        Assert.assertEquals(javaTask.buildJavaCommand(), homeBinPath + "java --class-path .:/tmp/dolphinscheduler/test/executepath:/tmp/dolphinscheduler/test/executepath/opt/share/jar/resource2.jar JavaTaskTest -host 127.0.0.1 -port 8080 -xms:50m");
+    }
+
+    public JavaParameters createJavaParametersObject(String runType) {
+        JavaParameters javaParameters = new JavaParameters();
+        javaParameters.setRunType(runType);
+        javaParameters.setModulePath(false);
+        javaParameters.setJvmArgs("-xms:50m");
+        javaParameters.setMainArgs("-host 127.0.0.1 -port 8080");
+        ResourceInfo resourceJar = new ResourceInfo();
+        resourceJar.setId(2);
+        resourceJar.setResourceName("/opt/share/jar/resource2.jar");
+        resourceJar.setRes("I'm resource2.jar");
+        ArrayList<ResourceInfo> resourceInfoArrayList = new ArrayList<>();
+        resourceInfoArrayList.add(resourceJar);
+        javaParameters.setResourceList(resourceInfoArrayList);
+        javaParameters.setRawScript(
+                        "import java.io.IOException;\n" +
+                        "public class JavaTaskTest {\n" +
+                        "    public static void main(String[] args) throws IOException {\n" +
+                        "        StringBuilder builder = new StringBuilder(\"Hello: \");\n" +
+                        "        for (String arg : args) {\n" +
+                        "            builder.append(arg).append(\" \");\n" +
+                        "        }\n" +
+                        "        System.out.println(builder);\n" +
+                        "    }\n" +
+                        "}\n");
+        ArrayList<Property> localParams = new ArrayList<>();
+        Property property = new Property();
+        property.setProp("name");
+        property.setValue("zhangsan");
+        property.setDirect(IN);
+        property.setType(VARCHAR);
+        javaParameters.setLocalParams(localParams);
+//        javaParameters.setVarPool("");

Review Comment:
   thx, it is done .



-- 
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


[GitHub] [dolphinscheduler] EricGao888 commented on a diff in pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
EricGao888 commented on code in PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#discussion_r930572167


##########
docs/docs/en/guide/task/java.md:
##########
@@ -0,0 +1,48 @@
+# Overview
+
+This node is used to perform java-type tasks and supports the use of single files and jar packages as program entries.
+
+# Create Tasks
+
+- Click on project management-> Project name-> workflow definition, click on the“Create workflow” button, go to the DAG edit page:
+
+- Drag the toolbar's Java task node to the palette.
+
+# Task Parameters
+| **Parameter** | **Description** |
+| ------- | ---------- |
+|Node Name|the name of the set task. The node name in a workflow definition is unique.
+|Run Flag|indicates whether the node is scheduled properly and, if it is not needed, turns on the kill switch.

Review Comment:
   ```suggestion
   |Run Flag|Indicates whether the node is scheduled properly and turns on the kill switch, if not needed.
   ```
   Try to be brief and concise. 



##########
docs/docs/en/guide/task/java.md:
##########
@@ -0,0 +1,48 @@
+# Overview
+
+This node is used to perform java-type tasks and supports the use of single files and jar packages as program entries.
+
+# Create Tasks
+
+- Click on project management-> Project name-> workflow definition, click on the“Create workflow” button, go to the DAG edit page:
+
+- Drag the toolbar's Java task node to the palette.
+
+# Task Parameters
+| **Parameter** | **Description** |
+| ------- | ---------- |
+|Node Name|the name of the set task. The node name in a workflow definition is unique.
+|Run Flag|indicates whether the node is scheduled properly and, if it is not needed, turns on the kill switch.
+|Description|describes the functionality of the node.
+|Task Priority|when the number of worker threads is insufficient, the worker is executed according to the priority from high to low. When the priority is the same, the worker is executed according to the first in, first out principle.
+|Worker Group|The machine whose task is assigned to the Worker group executes, and selecting Default will randomly select a Worker machine to execute.
+|Environment Name|configure the environment in which the task runs.
+|Number Of Failed Retries|number of resubmitted tasks that failed, supported drop-down and hand-fill.
+|Failed Retry Interval|the interval between tasks that fail and are resubmitted, supported by drop-down and hand-fill.
+|Delayed Execution Time|the amount of time a task is delayed, in units.
+|Timeout Alarm|Check timeout warning, timeout failure, when the task exceeds the“Timeout length”, send a warning message and the task execution fails.
+|Module Path|turn on the use of Java 9 + 's modularity feature, put all resources into-module-path, and require that the JDK version in your worker support modularity.

Review Comment:
   ```suggestion
   |Module Path| pick Java 9 + 's modularity feature, put all resources into-module-path, and require that the JDK version in your worker supports modularity.
   ```



##########
docs/docs/en/guide/task/java.md:
##########
@@ -0,0 +1,48 @@
+# Overview
+
+This node is used to perform java-type tasks and supports the use of single files and jar packages as program entries.
+
+# Create Tasks
+
+- Click on project management-> Project name-> workflow definition, click on the“Create workflow” button, go to the DAG edit page:
+
+- Drag the toolbar's Java task node to the palette.
+
+# Task Parameters
+| **Parameter** | **Description** |
+| ------- | ---------- |
+|Node Name|the name of the set task. The node name in a workflow definition is unique.
+|Run Flag|indicates whether the node is scheduled properly and, if it is not needed, turns on the kill switch.
+|Description|describes the functionality of the node.
+|Task Priority|when the number of worker threads is insufficient, the worker is executed according to the priority from high to low. When the priority is the same, the worker is executed according to the first in, first out principle.
+|Worker Group|The machine whose task is assigned to the Worker group executes, and selecting Default will randomly select a Worker machine to execute.
+|Environment Name|configure the environment in which the task runs.
+|Number Of Failed Retries|number of resubmitted tasks that failed, supported drop-down and hand-fill.
+|Failed Retry Interval|the interval between tasks that fail and are resubmitted, supported by drop-down and hand-fill.
+|Delayed Execution Time|the amount of time a task is delayed, in units.
+|Timeout Alarm|Check timeout warning, timeout failure, when the task exceeds the“Timeout length”, send a warning message and the task execution fails.
+|Module Path|turn on the use of Java 9 + 's modularity feature, put all resources into-module-path, and require that the JDK version in your worker support modularity.
+|Main Parameter|as a normal Java program main method entry parameter.
+|Java VM Parameters|configure startup virtual machine parameters.
+|Script|you need to write Java code if you use the Java run type. The public class must exist in the code without writing a package statement.

Review Comment:
   ```suggestion
   |Script|You need to write Java code if you use the Java run type. The public class must exist in the code without writing a package statement.
   ```



##########
docs/docs/en/guide/task/java.md:
##########
@@ -0,0 +1,48 @@
+# Overview
+
+This node is used to perform java-type tasks and supports the use of single files and jar packages as program entries.

Review Comment:
   ```suggestion
   This node is for executing java-type tasks and supports using files and jar packages as program entries.
   ```
   
   Please avoid using passive tense in tech docs.



##########
docs/docs/en/guide/task/java.md:
##########
@@ -0,0 +1,48 @@
+# Overview
+
+This node is used to perform java-type tasks and supports the use of single files and jar packages as program entries.
+
+# Create Tasks
+
+- Click on project management-> Project name-> workflow definition, click on the“Create workflow” button, go to the DAG edit page:
+
+- Drag the toolbar's Java task node to the palette.
+
+# Task Parameters
+| **Parameter** | **Description** |
+| ------- | ---------- |
+|Node Name|the name of the set task. The node name in a workflow definition is unique.
+|Run Flag|indicates whether the node is scheduled properly and, if it is not needed, turns on the kill switch.
+|Description|describes the functionality of the node.

Review Comment:
   ```suggestion
   |Description|Describes the functionality of the node.
   ```
   As stated above, you could either use lower case or upper case, just be consistent.



##########
docs/docs/en/guide/task/java.md:
##########
@@ -0,0 +1,48 @@
+# Overview
+
+This node is used to perform java-type tasks and supports the use of single files and jar packages as program entries.
+
+# Create Tasks
+
+- Click on project management-> Project name-> workflow definition, click on the“Create workflow” button, go to the DAG edit page:
+
+- Drag the toolbar's Java task node to the palette.
+
+# Task Parameters
+| **Parameter** | **Description** |
+| ------- | ---------- |
+|Node Name|the name of the set task. The node name in a workflow definition is unique.
+|Run Flag|indicates whether the node is scheduled properly and, if it is not needed, turns on the kill switch.
+|Description|describes the functionality of the node.
+|Task Priority|when the number of worker threads is insufficient, the worker is executed according to the priority from high to low. When the priority is the same, the worker is executed according to the first in, first out principle.
+|Worker Group|The machine whose task is assigned to the Worker group executes, and selecting Default will randomly select a Worker machine to execute.

Review Comment:
   ```suggestion
   |Worker Group|The group of machines who execute the tasks. If selecting `Default`, DolphinScheduler will randomly choose a worker machine to execute the task.
   ```



##########
docs/docs/en/guide/task/java.md:
##########
@@ -0,0 +1,48 @@
+# Overview
+
+This node is used to perform java-type tasks and supports the use of single files and jar packages as program entries.
+
+# Create Tasks
+
+- Click on project management-> Project name-> workflow definition, click on the“Create workflow” button, go to the DAG edit page:

Review Comment:
   ```suggestion
   - Click on `Project Management` -> `Project Name` -> `Workflow Definition`, click on the“Create workflow” button, go to the DAG edit page:
   ```
   Please keep letter case and space usage consistent.



##########
docs/docs/en/guide/task/java.md:
##########
@@ -0,0 +1,48 @@
+# Overview
+
+This node is used to perform java-type tasks and supports the use of single files and jar packages as program entries.
+
+# Create Tasks
+
+- Click on project management-> Project name-> workflow definition, click on the“Create workflow” button, go to the DAG edit page:
+
+- Drag the toolbar's Java task node to the palette.
+
+# Task Parameters
+| **Parameter** | **Description** |
+| ------- | ---------- |
+|Node Name|the name of the set task. The node name in a workflow definition is unique.
+|Run Flag|indicates whether the node is scheduled properly and, if it is not needed, turns on the kill switch.
+|Description|describes the functionality of the node.
+|Task Priority|when the number of worker threads is insufficient, the worker is executed according to the priority from high to low. When the priority is the same, the worker is executed according to the first in, first out principle.

Review Comment:
   ```suggestion
   |Task Priority|When the number of worker threads is insufficient, the worker executes tasks according to the priority. When the priority is the same, the worker executes tasks by order.



##########
docs/docs/en/guide/task/java.md:
##########
@@ -0,0 +1,48 @@
+# Overview
+
+This node is used to perform java-type tasks and supports the use of single files and jar packages as program entries.
+
+# Create Tasks
+
+- Click on project management-> Project name-> workflow definition, click on the“Create workflow” button, go to the DAG edit page:
+
+- Drag the toolbar's Java task node to the palette.
+
+# Task Parameters
+| **Parameter** | **Description** |
+| ------- | ---------- |
+|Node Name|the name of the set task. The node name in a workflow definition is unique.

Review Comment:
   ```suggestion
   |Node Name|The name of the set task. The node name in a workflow definition is unique.
   ```
   It doesn't matter you choose to use lower or upper case here, just keep things consistent.



##########
docs/docs/en/guide/task/java.md:
##########
@@ -0,0 +1,48 @@
+# Overview
+
+This node is used to perform java-type tasks and supports the use of single files and jar packages as program entries.
+
+# Create Tasks
+
+- Click on project management-> Project name-> workflow definition, click on the“Create workflow” button, go to the DAG edit page:
+
+- Drag the toolbar's Java task node to the palette.
+
+# Task Parameters
+| **Parameter** | **Description** |
+| ------- | ---------- |
+|Node Name|the name of the set task. The node name in a workflow definition is unique.
+|Run Flag|indicates whether the node is scheduled properly and, if it is not needed, turns on the kill switch.
+|Description|describes the functionality of the node.
+|Task Priority|when the number of worker threads is insufficient, the worker is executed according to the priority from high to low. When the priority is the same, the worker is executed according to the first in, first out principle.
+|Worker Group|The machine whose task is assigned to the Worker group executes, and selecting Default will randomly select a Worker machine to execute.
+|Environment Name|configure the environment in which the task runs.
+|Number Of Failed Retries|number of resubmitted tasks that failed, supported drop-down and hand-fill.
+|Failed Retry Interval|the interval between tasks that fail and are resubmitted, supported by drop-down and hand-fill.
+|Delayed Execution Time|the amount of time a task is delayed, in units.
+|Timeout Alarm|Check timeout warning, timeout failure, when the task exceeds the“Timeout length”, send a warning message and the task execution fails.
+|Module Path|turn on the use of Java 9 + 's modularity feature, put all resources into-module-path, and require that the JDK version in your worker support modularity.
+|Main Parameter|as a normal Java program main method entry parameter.

Review Comment:
   ```suggestion
   |Main Parameter|Java program main method entry parameter.
   ```



##########
docs/docs/en/guide/task/java.md:
##########
@@ -0,0 +1,48 @@
+# Overview
+
+This node is used to perform java-type tasks and supports the use of single files and jar packages as program entries.
+
+# Create Tasks
+
+- Click on project management-> Project name-> workflow definition, click on the“Create workflow” button, go to the DAG edit page:
+
+- Drag the toolbar's Java task node to the palette.
+
+# Task Parameters
+| **Parameter** | **Description** |
+| ------- | ---------- |
+|Node Name|the name of the set task. The node name in a workflow definition is unique.
+|Run Flag|indicates whether the node is scheduled properly and, if it is not needed, turns on the kill switch.
+|Description|describes the functionality of the node.
+|Task Priority|when the number of worker threads is insufficient, the worker is executed according to the priority from high to low. When the priority is the same, the worker is executed according to the first in, first out principle.
+|Worker Group|The machine whose task is assigned to the Worker group executes, and selecting Default will randomly select a Worker machine to execute.
+|Environment Name|configure the environment in which the task runs.
+|Number Of Failed Retries|number of resubmitted tasks that failed, supported drop-down and hand-fill.
+|Failed Retry Interval|the interval between tasks that fail and are resubmitted, supported by drop-down and hand-fill.

Review Comment:
   ```suggestion
   |Failed Retry Interval|the interval between the failure and resubmission of a task. You can choose the number in the drop-down menu or fill it manually.
   ```



##########
docs/docs/en/guide/task/java.md:
##########
@@ -0,0 +1,48 @@
+# Overview
+
+This node is used to perform java-type tasks and supports the use of single files and jar packages as program entries.
+
+# Create Tasks
+
+- Click on project management-> Project name-> workflow definition, click on the“Create workflow” button, go to the DAG edit page:
+
+- Drag the toolbar's Java task node to the palette.
+
+# Task Parameters
+| **Parameter** | **Description** |
+| ------- | ---------- |
+|Node Name|the name of the set task. The node name in a workflow definition is unique.
+|Run Flag|indicates whether the node is scheduled properly and, if it is not needed, turns on the kill switch.
+|Description|describes the functionality of the node.
+|Task Priority|when the number of worker threads is insufficient, the worker is executed according to the priority from high to low. When the priority is the same, the worker is executed according to the first in, first out principle.
+|Worker Group|The machine whose task is assigned to the Worker group executes, and selecting Default will randomly select a Worker machine to execute.
+|Environment Name|configure the environment in which the task runs.
+|Number Of Failed Retries|number of resubmitted tasks that failed, supported drop-down and hand-fill.

Review Comment:
   ```suggestion
   |Number Of Failed Retries|Number of resubmitted tasks that failed. You can choose the number in the drop-down menu or fill it manually.
   ```



##########
docs/docs/en/guide/task/java.md:
##########
@@ -0,0 +1,48 @@
+# Overview
+
+This node is used to perform java-type tasks and supports the use of single files and jar packages as program entries.
+
+# Create Tasks
+
+- Click on project management-> Project name-> workflow definition, click on the“Create workflow” button, go to the DAG edit page:
+
+- Drag the toolbar's Java task node to the palette.
+
+# Task Parameters
+| **Parameter** | **Description** |
+| ------- | ---------- |
+|Node Name|the name of the set task. The node name in a workflow definition is unique.
+|Run Flag|indicates whether the node is scheduled properly and, if it is not needed, turns on the kill switch.
+|Description|describes the functionality of the node.
+|Task Priority|when the number of worker threads is insufficient, the worker is executed according to the priority from high to low. When the priority is the same, the worker is executed according to the first in, first out principle.
+|Worker Group|The machine whose task is assigned to the Worker group executes, and selecting Default will randomly select a Worker machine to execute.
+|Environment Name|configure the environment in which the task runs.

Review Comment:
   ```suggestion
   |Environment Name|Configure the environment in which the task runs.
   ```



##########
docs/docs/en/guide/task/java.md:
##########
@@ -0,0 +1,48 @@
+# Overview
+
+This node is used to perform java-type tasks and supports the use of single files and jar packages as program entries.
+
+# Create Tasks
+
+- Click on project management-> Project name-> workflow definition, click on the“Create workflow” button, go to the DAG edit page:
+
+- Drag the toolbar's Java task node to the palette.
+
+# Task Parameters
+| **Parameter** | **Description** |
+| ------- | ---------- |
+|Node Name|the name of the set task. The node name in a workflow definition is unique.
+|Run Flag|indicates whether the node is scheduled properly and, if it is not needed, turns on the kill switch.
+|Description|describes the functionality of the node.
+|Task Priority|when the number of worker threads is insufficient, the worker is executed according to the priority from high to low. When the priority is the same, the worker is executed according to the first in, first out principle.
+|Worker Group|The machine whose task is assigned to the Worker group executes, and selecting Default will randomly select a Worker machine to execute.
+|Environment Name|configure the environment in which the task runs.
+|Number Of Failed Retries|number of resubmitted tasks that failed, supported drop-down and hand-fill.
+|Failed Retry Interval|the interval between tasks that fail and are resubmitted, supported by drop-down and hand-fill.
+|Delayed Execution Time|the amount of time a task is delayed, in units.
+|Timeout Alarm|Check timeout warning, timeout failure, when the task exceeds the“Timeout length”, send a warning message and the task execution fails.
+|Module Path|turn on the use of Java 9 + 's modularity feature, put all resources into-module-path, and require that the JDK version in your worker support modularity.
+|Main Parameter|as a normal Java program main method entry parameter.
+|Java VM Parameters|configure startup virtual machine parameters.
+|Script|you need to write Java code if you use the Java run type. The public class must exist in the code without writing a package statement.
+|Resources|these can be external JAR packages or other resource files that are added to the Classpath or module path and can be easily retrieved in your JAVA script.

Review Comment:
   ```suggestion
   |Resources|External JAR packages or other resource files that are added to the classpath or module path and can be easily retrieved in your JAVA script.
   ```



##########
docs/docs/en/guide/task/java.md:
##########
@@ -0,0 +1,48 @@
+# Overview
+
+This node is used to perform java-type tasks and supports the use of single files and jar packages as program entries.
+
+# Create Tasks
+
+- Click on project management-> Project name-> workflow definition, click on the“Create workflow” button, go to the DAG edit page:
+
+- Drag the toolbar's Java task node to the palette.
+
+# Task Parameters
+| **Parameter** | **Description** |
+| ------- | ---------- |
+|Node Name|the name of the set task. The node name in a workflow definition is unique.
+|Run Flag|indicates whether the node is scheduled properly and, if it is not needed, turns on the kill switch.
+|Description|describes the functionality of the node.
+|Task Priority|when the number of worker threads is insufficient, the worker is executed according to the priority from high to low. When the priority is the same, the worker is executed according to the first in, first out principle.
+|Worker Group|The machine whose task is assigned to the Worker group executes, and selecting Default will randomly select a Worker machine to execute.
+|Environment Name|configure the environment in which the task runs.
+|Number Of Failed Retries|number of resubmitted tasks that failed, supported drop-down and hand-fill.
+|Failed Retry Interval|the interval between tasks that fail and are resubmitted, supported by drop-down and hand-fill.
+|Delayed Execution Time|the amount of time a task is delayed, in units.
+|Timeout Alarm|Check timeout warning, timeout failure, when the task exceeds the“Timeout length”, send a warning message and the task execution fails.
+|Module Path|turn on the use of Java 9 + 's modularity feature, put all resources into-module-path, and require that the JDK version in your worker support modularity.
+|Main Parameter|as a normal Java program main method entry parameter.
+|Java VM Parameters|configure startup virtual machine parameters.

Review Comment:
   ```suggestion
   |Java VM Parameters|JVM startup parameters.
   ```



##########
docs/docs/en/guide/task/java.md:
##########
@@ -0,0 +1,48 @@
+# Overview
+
+This node is used to perform java-type tasks and supports the use of single files and jar packages as program entries.
+
+# Create Tasks
+
+- Click on project management-> Project name-> workflow definition, click on the“Create workflow” button, go to the DAG edit page:
+
+- Drag the toolbar's Java task node to the palette.
+
+# Task Parameters
+| **Parameter** | **Description** |
+| ------- | ---------- |
+|Node Name|the name of the set task. The node name in a workflow definition is unique.
+|Run Flag|indicates whether the node is scheduled properly and, if it is not needed, turns on the kill switch.
+|Description|describes the functionality of the node.
+|Task Priority|when the number of worker threads is insufficient, the worker is executed according to the priority from high to low. When the priority is the same, the worker is executed according to the first in, first out principle.
+|Worker Group|The machine whose task is assigned to the Worker group executes, and selecting Default will randomly select a Worker machine to execute.
+|Environment Name|configure the environment in which the task runs.
+|Number Of Failed Retries|number of resubmitted tasks that failed, supported drop-down and hand-fill.
+|Failed Retry Interval|the interval between tasks that fail and are resubmitted, supported by drop-down and hand-fill.
+|Delayed Execution Time|the amount of time a task is delayed, in units.
+|Timeout Alarm|Check timeout warning, timeout failure, when the task exceeds the“Timeout length”, send a warning message and the task execution fails.
+|Module Path|turn on the use of Java 9 + 's modularity feature, put all resources into-module-path, and require that the JDK version in your worker support modularity.
+|Main Parameter|as a normal Java program main method entry parameter.
+|Java VM Parameters|configure startup virtual machine parameters.
+|Script|you need to write Java code if you use the Java run type. The public class must exist in the code without writing a package statement.
+|Resources|these can be external JAR packages or other resource files that are added to the Classpath or module path and can be easily retrieved in your JAVA script.
+|Custom parameter|a user-defined parameter that is part of HTTP and replaces the contents of the script with the ${ variable } .
+|Pre Tasks|selecting a pre-task for the current task sets the selected pre-task upstream of the current task.
+
+## Example
+
+Java task types have two modes of execution, which are demonstrated here as an example of a Java mode.

Review Comment:
   ```suggestion
   Java type tasks have two modes of execution, here is a demonstration of executing tasks in Java mode.
   ```
   I'm not sure what this sentence means. Could you please help make it more comprehensible?



##########
docs/docs/en/guide/task/java.md:
##########
@@ -0,0 +1,48 @@
+# Overview
+
+This node is used to perform java-type tasks and supports the use of single files and jar packages as program entries.
+
+# Create Tasks
+
+- Click on project management-> Project name-> workflow definition, click on the“Create workflow” button, go to the DAG edit page:
+
+- Drag the toolbar's Java task node to the palette.
+
+# Task Parameters
+| **Parameter** | **Description** |
+| ------- | ---------- |
+|Node Name|the name of the set task. The node name in a workflow definition is unique.
+|Run Flag|indicates whether the node is scheduled properly and, if it is not needed, turns on the kill switch.
+|Description|describes the functionality of the node.
+|Task Priority|when the number of worker threads is insufficient, the worker is executed according to the priority from high to low. When the priority is the same, the worker is executed according to the first in, first out principle.
+|Worker Group|The machine whose task is assigned to the Worker group executes, and selecting Default will randomly select a Worker machine to execute.
+|Environment Name|configure the environment in which the task runs.
+|Number Of Failed Retries|number of resubmitted tasks that failed, supported drop-down and hand-fill.
+|Failed Retry Interval|the interval between tasks that fail and are resubmitted, supported by drop-down and hand-fill.
+|Delayed Execution Time|the amount of time a task is delayed, in units.
+|Timeout Alarm|Check timeout warning, timeout failure, when the task exceeds the“Timeout length”, send a warning message and the task execution fails.
+|Module Path|turn on the use of Java 9 + 's modularity feature, put all resources into-module-path, and require that the JDK version in your worker support modularity.
+|Main Parameter|as a normal Java program main method entry parameter.
+|Java VM Parameters|configure startup virtual machine parameters.
+|Script|you need to write Java code if you use the Java run type. The public class must exist in the code without writing a package statement.
+|Resources|these can be external JAR packages or other resource files that are added to the Classpath or module path and can be easily retrieved in your JAVA script.
+|Custom parameter|a user-defined parameter that is part of HTTP and replaces the contents of the script with the ${ variable } .
+|Pre Tasks|selecting a pre-task for the current task sets the selected pre-task upstream of the current task.

Review Comment:
   ```suggestion
   |Pre Tasks|Selects a pre-task for the current task and sets the pre-task as the upstream of the current task.
   ```



##########
docs/docs/en/guide/task/java.md:
##########
@@ -0,0 +1,48 @@
+# Overview
+
+This node is used to perform java-type tasks and supports the use of single files and jar packages as program entries.
+
+# Create Tasks
+
+- Click on project management-> Project name-> workflow definition, click on the“Create workflow” button, go to the DAG edit page:
+
+- Drag the toolbar's Java task node to the palette.
+
+# Task Parameters
+| **Parameter** | **Description** |
+| ------- | ---------- |
+|Node Name|the name of the set task. The node name in a workflow definition is unique.
+|Run Flag|indicates whether the node is scheduled properly and, if it is not needed, turns on the kill switch.
+|Description|describes the functionality of the node.
+|Task Priority|when the number of worker threads is insufficient, the worker is executed according to the priority from high to low. When the priority is the same, the worker is executed according to the first in, first out principle.
+|Worker Group|The machine whose task is assigned to the Worker group executes, and selecting Default will randomly select a Worker machine to execute.
+|Environment Name|configure the environment in which the task runs.
+|Number Of Failed Retries|number of resubmitted tasks that failed, supported drop-down and hand-fill.
+|Failed Retry Interval|the interval between tasks that fail and are resubmitted, supported by drop-down and hand-fill.
+|Delayed Execution Time|the amount of time a task is delayed, in units.
+|Timeout Alarm|Check timeout warning, timeout failure, when the task exceeds the“Timeout length”, send a warning message and the task execution fails.
+|Module Path|turn on the use of Java 9 + 's modularity feature, put all resources into-module-path, and require that the JDK version in your worker support modularity.
+|Main Parameter|as a normal Java program main method entry parameter.
+|Java VM Parameters|configure startup virtual machine parameters.
+|Script|you need to write Java code if you use the Java run type. The public class must exist in the code without writing a package statement.
+|Resources|these can be external JAR packages or other resource files that are added to the Classpath or module path and can be easily retrieved in your JAVA script.
+|Custom parameter|a user-defined parameter that is part of HTTP and replaces the contents of the script with the ${ variable } .

Review Comment:
   ```suggestion
   |Custom parameter|A user-defined parameter that is part of HTTP and replaces `${ variable }` in the script .
   ```



##########
docs/docs/en/guide/task/java.md:
##########
@@ -0,0 +1,48 @@
+# Overview
+
+This node is used to perform java-type tasks and supports the use of single files and jar packages as program entries.
+
+# Create Tasks
+
+- Click on project management-> Project name-> workflow definition, click on the“Create workflow” button, go to the DAG edit page:
+
+- Drag the toolbar's Java task node to the palette.
+
+# Task Parameters
+| **Parameter** | **Description** |
+| ------- | ---------- |
+|Node Name|the name of the set task. The node name in a workflow definition is unique.
+|Run Flag|indicates whether the node is scheduled properly and, if it is not needed, turns on the kill switch.
+|Description|describes the functionality of the node.
+|Task Priority|when the number of worker threads is insufficient, the worker is executed according to the priority from high to low. When the priority is the same, the worker is executed according to the first in, first out principle.
+|Worker Group|The machine whose task is assigned to the Worker group executes, and selecting Default will randomly select a Worker machine to execute.
+|Environment Name|configure the environment in which the task runs.
+|Number Of Failed Retries|number of resubmitted tasks that failed, supported drop-down and hand-fill.
+|Failed Retry Interval|the interval between tasks that fail and are resubmitted, supported by drop-down and hand-fill.
+|Delayed Execution Time|the amount of time a task is delayed, in units.
+|Timeout Alarm|Check timeout warning, timeout failure, when the task exceeds the“Timeout length”, send a warning message and the task execution fails.
+|Module Path|turn on the use of Java 9 + 's modularity feature, put all resources into-module-path, and require that the JDK version in your worker support modularity.
+|Main Parameter|as a normal Java program main method entry parameter.
+|Java VM Parameters|configure startup virtual machine parameters.
+|Script|you need to write Java code if you use the Java run type. The public class must exist in the code without writing a package statement.
+|Resources|these can be external JAR packages or other resource files that are added to the Classpath or module path and can be easily retrieved in your JAVA script.
+|Custom parameter|a user-defined parameter that is part of HTTP and replaces the contents of the script with the ${ variable } .
+|Pre Tasks|selecting a pre-task for the current task sets the selected pre-task upstream of the current task.
+
+## Example
+
+Java task types have two modes of execution, which are demonstrated here as an example of a Java mode.
+
+The main configuration parameters are as follows:
+- Run Type
+- Module Path
+- Main Parameters
+- Java VM Parameters
+
+- Script 
+
+![java_task](../../../../img/tasks/demo/java_task02.png)
+
+## Note
+
+When you run a type with JAVA, the public class must exist in the code, and you can not write a package statement.

Review Comment:
   ```suggestion
   When you run the task in JAVA execution mode, the public class must exist in the code, and you could omit writing a package statement.
   ```
   I'm not quite sure what this sentence means. 



-- 
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


[GitHub] [dolphinscheduler] ruanwenjun commented on a diff in pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
ruanwenjun commented on code in PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#discussion_r945295271


##########
dolphinscheduler-task-plugin/dolphinscheduler-task-java/src/main/java/org/apache/dolphinscheduler/plugin/task/java/JavaConstants.java:
##########
@@ -0,0 +1,67 @@
+/*
+ * 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;
+
+public class JavaConstants {
+
+    private JavaConstants() {
+        throw new IllegalStateException("Utility class");
+    }
+
+    /**
+     * The constants used to get the Java installation directory
+     **/
+    public static final String JAVA_HOME_VAR = "${JAVA_HOME}";
+
+    /**
+     * this constant represents the use of the java command to run a task
+     **/
+    public static final String RUN_TYPE_JAVA = "JAVA";
+
+    /**
+     * this constant represents the use of the java -jar command to run a task
+     **/
+    public static final String RUN_TYPE_JAR = "JAR";
+
+    /**
+     * This constant is the Classpath or module path delimiter for different operating systems
+     **/
+    public static final String PATH_SEPARATOR = System.getProperty("path.separator");

Review Comment:
   Why you don't directly use `File.pathSeparatorChar`



##########
dolphinscheduler-task-plugin/dolphinscheduler-task-java/src/main/java/org/apache/dolphinscheduler/plugin/task/java/JavaConstants.java:
##########
@@ -0,0 +1,67 @@
+/*
+ * 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;
+
+public class JavaConstants {
+
+    private JavaConstants() {
+        throw new IllegalStateException("Utility class");
+    }
+
+    /**
+     * The constants used to get the Java installation directory
+     **/
+    public static final String JAVA_HOME_VAR = "${JAVA_HOME}";
+
+    /**
+     * this constant represents the use of the java command to run a task
+     **/
+    public static final String RUN_TYPE_JAVA = "JAVA";
+
+    /**
+     * this constant represents the use of the java -jar command to run a task
+     **/
+    public static final String RUN_TYPE_JAR = "JAR";
+
+    /**
+     * This constant is the Classpath or module path delimiter for different operating systems
+     **/
+    public static final String PATH_SEPARATOR = System.getProperty("path.separator");
+
+    /**
+     * This constant is the file delimiter for different operating systems
+     **/
+    public static final String FILE_SEPARATOR = System.getProperty("file.separator");

Review Comment:
   Why you don't directly use `File.separator`



##########
dolphinscheduler-task-plugin/dolphinscheduler-task-java/src/main/java/org/apache/dolphinscheduler/plugin/task/java/JavaParameters.java:
##########
@@ -0,0 +1,83 @@
+/*
+ * 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 org.apache.dolphinscheduler.plugin.task.api.model.ResourceInfo;
+import org.apache.dolphinscheduler.plugin.task.api.parameters.AbstractParameters;
+
+import java.util.List;
+
+import lombok.Data;
+
+@Data
+public class JavaParameters extends AbstractParameters {
+    /**
+     * origin java script
+     */
+    private String rawScript;
+
+    /**
+     * run in jar file
+     */
+    private ResourceInfo mainJar;
+
+    /**
+     * Marks the current task running mode
+     */
+    private String runType;
+
+    /**
+     * main method args
+     **/
+    private String mainArgs;
+
+    /**
+     * java virtual machine args
+     **/
+    private String jvmArgs;
+
+    /**
+     * module path or class path flag
+     **/
+    private boolean isModulePath;
+
+    /**
+     * resource list
+     */
+    private List<ResourceInfo> resourceList;
+
+    /**
+     * @description: Check that the parameters are valid
+     * @param: []
+     * @return: boolean
+     **/
+    @Override
+    public boolean checkParameters() {
+        return runType != null && (rawScript != null && !rawScript.isEmpty()) || mainJar != null;

Review Comment:
   ```suggestion
           return runType != null && StringUtils.isNotEmpty(rawScript) || mainJar != null;
   ```



##########
dolphinscheduler-task-plugin/dolphinscheduler-task-java/src/main/java/org/apache/dolphinscheduler/plugin/task/java/JavaTask.java:
##########
@@ -0,0 +1,422 @@
+/*
+ * 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 static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.SINGLE_SLASH;
+import static org.apache.dolphinscheduler.plugin.task.java.JavaConstants.JAVA_HOME_VAR;
+import static org.apache.dolphinscheduler.plugin.task.java.JavaConstants.PUBLIC_CLASS_NAME_REGEX;
+
+
+import org.apache.dolphinscheduler.plugin.task.api.AbstractTaskExecutor;
+import org.apache.dolphinscheduler.plugin.task.api.ShellCommandExecutor;
+import org.apache.dolphinscheduler.plugin.task.api.TaskConstants;
+import org.apache.dolphinscheduler.plugin.task.api.TaskException;
+import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext;
+import org.apache.dolphinscheduler.plugin.task.api.model.Property;
+import org.apache.dolphinscheduler.plugin.task.api.model.ResourceInfo;
+import org.apache.dolphinscheduler.plugin.task.api.model.TaskResponse;
+import org.apache.dolphinscheduler.plugin.task.api.parameters.AbstractParameters;
+import org.apache.dolphinscheduler.plugin.task.api.parser.ParamUtils;
+import org.apache.dolphinscheduler.plugin.task.api.parser.ParameterUtils;
+import org.apache.dolphinscheduler.plugin.task.api.utils.MapUtils;
+import org.apache.dolphinscheduler.plugin.task.java.exception.JavaSourceFileExistException;
+import org.apache.dolphinscheduler.plugin.task.java.exception.PublicClassNotFoundException;
+import org.apache.dolphinscheduler.plugin.task.java.exception.RunTypeNotFoundException;
+import org.apache.dolphinscheduler.spi.utils.JSONUtils;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.lang3.SystemUtils;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import com.google.common.base.Preconditions;
+
+/**
+ * java task
+ */
+public class JavaTask extends AbstractTaskExecutor {
+
+    /**
+     * Contains various parameters for this task
+     */
+    private JavaParameters javaParameters;
+
+    /**
+     * To run shell commands
+     */
+    private ShellCommandExecutor shellCommandExecutor;
+
+    /**
+     * task execution context
+     */
+    private TaskExecutionContext taskRequest;
+
+    /**
+     * class name regex pattern
+     */
+    private static final Pattern classNamePattern = Pattern.compile(PUBLIC_CLASS_NAME_REGEX);
+
+    /**
+     * @description: Construct a Java task
+     * @param: [org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext]
+     * @return: JavaTask
+     **/
+    public JavaTask(TaskExecutionContext taskRequest) {
+        super(taskRequest);
+        this.taskRequest = taskRequest;
+        this.shellCommandExecutor = new ShellCommandExecutor(this::logHandle,
+                taskRequest,
+                logger);
+    }
+
+    /**
+     * @description: Initializes a Java task
+     * @param: []
+     * @return: void
+     **/
+    @Override
+    public void init() {
+        logger.info("java task params {}", taskRequest.getTaskParams());
+        javaParameters = JSONUtils.parseObject(taskRequest.getTaskParams(), JavaParameters.class);
+        if (javaParameters == null || !javaParameters.checkParameters()) {
+            throw new TaskException("java task params is not valid");
+        }
+        if (javaParameters.getRunType().equals(JavaConstants.RUN_TYPE_JAR)) {
+            setMainJarName();
+        }
+    }
+
+    /**
+     * @description: Gets the Java source file that was initially processed
+     * @param: []
+     * @return: java.lang.String
+     **/
+    @Override
+    public String getPreScript() {
+        String rawJavaScript = javaParameters.getRawScript().replaceAll("\\r\\n", "\n");
+        try {
+            rawJavaScript = convertJavaSourceCodePlaceholders(rawJavaScript);
+        } catch (StringIndexOutOfBoundsException e) {
+            logger.error("setShareVar field format error, raw java script : {}", rawJavaScript);
+        }
+        return rawJavaScript;
+    }
+
+    /**
+     * @description: Execute Java tasks
+     * @param: []
+     * @return: void
+     **/
+    @Override
+    public void handle() throws Exception {
+        try {
+            // Step 1: judge if is java or jar run type.
+            // Step 2 case1: The jar run type builds the command directly, adding resource to the java -jar class when building the command
+            // Step 2 case2: The java run type, first replace the custom parameters, then compile the code, and then build the command will add resource
+            // Step 3: To run the command
+            String command = null;
+            switch (javaParameters.getRunType()) {
+                case JavaConstants.RUN_TYPE_JAVA:
+                    command = buildJavaCommand();
+                    break;
+                case JavaConstants.RUN_TYPE_JAR:
+                    command = buildJarCommand();
+                    break;
+                default:
+                    throw new RunTypeNotFoundException("run type is required, but it is null now.");

Review Comment:
   Why you don't put this in `javaParameters.checkParameters()`



##########
dolphinscheduler-task-plugin/dolphinscheduler-task-java/src/main/java/org/apache/dolphinscheduler/plugin/task/java/JavaTask.java:
##########
@@ -0,0 +1,422 @@
+/*
+ * 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 static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.SINGLE_SLASH;
+import static org.apache.dolphinscheduler.plugin.task.java.JavaConstants.JAVA_HOME_VAR;
+import static org.apache.dolphinscheduler.plugin.task.java.JavaConstants.PUBLIC_CLASS_NAME_REGEX;
+
+
+import org.apache.dolphinscheduler.plugin.task.api.AbstractTaskExecutor;
+import org.apache.dolphinscheduler.plugin.task.api.ShellCommandExecutor;
+import org.apache.dolphinscheduler.plugin.task.api.TaskConstants;
+import org.apache.dolphinscheduler.plugin.task.api.TaskException;
+import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext;
+import org.apache.dolphinscheduler.plugin.task.api.model.Property;
+import org.apache.dolphinscheduler.plugin.task.api.model.ResourceInfo;
+import org.apache.dolphinscheduler.plugin.task.api.model.TaskResponse;
+import org.apache.dolphinscheduler.plugin.task.api.parameters.AbstractParameters;
+import org.apache.dolphinscheduler.plugin.task.api.parser.ParamUtils;
+import org.apache.dolphinscheduler.plugin.task.api.parser.ParameterUtils;
+import org.apache.dolphinscheduler.plugin.task.api.utils.MapUtils;
+import org.apache.dolphinscheduler.plugin.task.java.exception.JavaSourceFileExistException;
+import org.apache.dolphinscheduler.plugin.task.java.exception.PublicClassNotFoundException;
+import org.apache.dolphinscheduler.plugin.task.java.exception.RunTypeNotFoundException;
+import org.apache.dolphinscheduler.spi.utils.JSONUtils;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.lang3.SystemUtils;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import com.google.common.base.Preconditions;
+
+/**
+ * java task
+ */
+public class JavaTask extends AbstractTaskExecutor {
+
+    /**
+     * Contains various parameters for this task
+     */
+    private JavaParameters javaParameters;
+
+    /**
+     * To run shell commands
+     */
+    private ShellCommandExecutor shellCommandExecutor;
+
+    /**
+     * task execution context
+     */
+    private TaskExecutionContext taskRequest;
+
+    /**
+     * class name regex pattern
+     */
+    private static final Pattern classNamePattern = Pattern.compile(PUBLIC_CLASS_NAME_REGEX);
+
+    /**
+     * @description: Construct a Java task
+     * @param: [org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext]
+     * @return: JavaTask
+     **/
+    public JavaTask(TaskExecutionContext taskRequest) {
+        super(taskRequest);
+        this.taskRequest = taskRequest;
+        this.shellCommandExecutor = new ShellCommandExecutor(this::logHandle,
+                taskRequest,
+                logger);
+    }
+
+    /**
+     * @description: Initializes a Java task
+     * @param: []
+     * @return: void
+     **/
+    @Override
+    public void init() {
+        logger.info("java task params {}", taskRequest.getTaskParams());
+        javaParameters = JSONUtils.parseObject(taskRequest.getTaskParams(), JavaParameters.class);
+        if (javaParameters == null || !javaParameters.checkParameters()) {
+            throw new TaskException("java task params is not valid");
+        }
+        if (javaParameters.getRunType().equals(JavaConstants.RUN_TYPE_JAR)) {
+            setMainJarName();
+        }
+    }
+
+    /**
+     * @description: Gets the Java source file that was initially processed
+     * @param: []
+     * @return: java.lang.String
+     **/
+    @Override
+    public String getPreScript() {
+        String rawJavaScript = javaParameters.getRawScript().replaceAll("\\r\\n", "\n");
+        try {
+            rawJavaScript = convertJavaSourceCodePlaceholders(rawJavaScript);
+        } catch (StringIndexOutOfBoundsException e) {
+            logger.error("setShareVar field format error, raw java script : {}", rawJavaScript);
+        }
+        return rawJavaScript;
+    }
+
+    /**
+     * @description: Execute Java tasks
+     * @param: []
+     * @return: void
+     **/
+    @Override
+    public void handle() throws Exception {
+        try {
+            // Step 1: judge if is java or jar run type.
+            // Step 2 case1: The jar run type builds the command directly, adding resource to the java -jar class when building the command
+            // Step 2 case2: The java run type, first replace the custom parameters, then compile the code, and then build the command will add resource
+            // Step 3: To run the command
+            String command = null;
+            switch (javaParameters.getRunType()) {
+                case JavaConstants.RUN_TYPE_JAVA:
+                    command = buildJavaCommand();
+                    break;
+                case JavaConstants.RUN_TYPE_JAR:
+                    command = buildJarCommand();
+                    break;
+                default:
+                    throw new RunTypeNotFoundException("run type is required, but it is null now.");
+            }
+            Preconditions.checkNotNull(command, "command not be null.");
+            TaskResponse taskResponse = shellCommandExecutor.run(command);
+            logger.info("java task run result : {}", taskResponse);
+            setExitStatusCode(taskResponse.getExitStatusCode());
+            setAppIds(taskResponse.getAppIds());
+            setProcessId(taskResponse.getProcessId());
+            setVarPool(shellCommandExecutor.getVarPool());
+        } catch (InterruptedException e) {
+            logger.error("java task interrupted ", e);
+            setExitStatusCode(TaskConstants.EXIT_CODE_FAILURE);
+            Thread.currentThread().interrupt();
+        } catch (RunTypeNotFoundException e) {
+            logger.error(e.getMessage());
+            setExitStatusCode(TaskConstants.EXIT_CODE_FAILURE);
+            throw e;
+        } catch (Exception e) {
+            logger.error("java task failed ", e);
+            setExitStatusCode(TaskConstants.EXIT_CODE_FAILURE);
+            throw new TaskException("run java task error", e);
+        }
+    }
+
+    /**
+     * @description: Construct a shell command for the java Run mode
+     * @param: []
+     * @return: java.lang.String
+     **/
+    protected String buildJavaCommand() throws Exception {
+        String sourceCode = buildJavaSourceContent();
+        String className = compilerRawScript(sourceCode);
+        StringBuilder builder = new StringBuilder();
+        builder.append(getJavaCommandPath())
+                .append("java").append(" ")
+                .append(buildResourcePath())
+                .append(" ")
+                .append(className).append(" ")
+                .append(javaParameters.getMainArgs().trim()).append(" ")
+                .append(javaParameters.getJvmArgs().trim());
+        return builder.toString();
+    }
+
+    private void setMainJarName() {
+        ResourceInfo mainJar = javaParameters.getMainJar();
+        String resourceName = getResourceNameOfMainJar(mainJar);
+        mainJar.setRes(resourceName);
+        javaParameters.setMainJar(mainJar);
+    }
+
+    /**
+     * @description: Construct a shell command for the java -jar Run mode
+     * @param: []
+     * @return: java.lang.String
+     **/
+    protected String buildJarCommand() {
+        String fullName = javaParameters.getMainJar().getResourceName();
+        String mainJarName = fullName.substring(0, fullName.lastIndexOf('.'));
+        mainJarName = mainJarName.substring(mainJarName.lastIndexOf('.') + 1) + ".jar";
+        StringBuilder builder = new StringBuilder();
+        builder.append(getJavaCommandPath())
+                .append("java").append(" ")
+                .append(buildResourcePath()).append(" ")
+                .append("-jar").append(" ")
+                .append(taskRequest.getExecutePath())
+                .append(mainJarName).append(" ")
+                .append(javaParameters.getMainArgs().trim()).append(" ")
+                .append(javaParameters.getJvmArgs().trim());
+        return builder.toString();
+    }
+
+    private String getResourceNameOfMainJar(ResourceInfo mainJar) {
+        if (null == mainJar) {
+            throw new RuntimeException("The jar for the task is required.");
+        }
+        return mainJar.getId() == 0
+                ? mainJar.getRes()
+                // when update resource maybe has error
+                : mainJar.getResourceName().replaceFirst(SINGLE_SLASH, "");
+    }
+
+    @Override
+    public void cancelApplication(boolean cancelApplication) throws Exception {
+        // cancel process
+        shellCommandExecutor.cancelApplication();
+    }
+
+    @Override
+    public AbstractParameters getParameters() {
+        return javaParameters;
+    }
+
+    /**
+     * @description: Replaces placeholders such as local variables in source files
+     * @param: [java.lang.String]
+     * @return: java.lang.String
+     **/
+    protected static String convertJavaSourceCodePlaceholders(String rawScript) throws StringIndexOutOfBoundsException {
+        int len = "${setShareVar(${".length();
+        int scriptStart = 0;
+        while ((scriptStart = rawScript.indexOf("${setShareVar(${", scriptStart)) != -1) {
+            int start = -1;
+            int end = rawScript.indexOf('}', scriptStart + len);
+            String prop = rawScript.substring(scriptStart + len, end);
+
+            start = rawScript.indexOf(',', end);
+            end = rawScript.indexOf(')', start);
+
+            String value = rawScript.substring(start + 1, end);
+
+            start = rawScript.indexOf('}', start) + 1;
+            end = rawScript.length();
+
+            String replaceScript = String.format("print(\"${{setValue({},{})}}\".format(\"%s\",%s))", prop, value);
+
+            rawScript = rawScript.substring(0, scriptStart) + replaceScript + rawScript.substring(start, end);
+
+            scriptStart += replaceScript.length();
+        }
+        return rawScript;
+    }
+
+    /**
+     * @description: Creates a Java source file when it does not exist
+     * @param: [java.lang.String, java.lang.String]
+     * @return: java.lang.String
+     **/
+    protected void createJavaSourceFileIfNotExists(String sourceCode, String fileName) throws IOException {
+        logger.info("tenantCode: {}, task dir:{}", taskRequest.getTenantCode(), taskRequest.getExecutePath());
+
+        if (!Files.exists(Paths.get(fileName))) {
+            logger.info("generate java source file: {}", fileName);
+
+            StringBuilder sb = new StringBuilder();
+            sb.append(sourceCode);
+            logger.info(sb.toString());
+
+            // write data to file
+            FileUtils.writeStringToFile(new File(fileName),
+                    sb.toString(),
+                    StandardCharsets.UTF_8);

Review Comment:
   ```suggestion
               logger.info("The java source code", sourceCode);
   
               // write data to file
               FileUtils.writeStringToFile(new File(fileName),
                       sb,
                       StandardCharsets.UTF_8);
   ```
   Why do you use StringBuilder here?



##########
dolphinscheduler-task-plugin/dolphinscheduler-task-java/src/main/java/org/apache/dolphinscheduler/plugin/task/java/JavaTask.java:
##########
@@ -0,0 +1,422 @@
+/*
+ * 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 static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.SINGLE_SLASH;
+import static org.apache.dolphinscheduler.plugin.task.java.JavaConstants.JAVA_HOME_VAR;
+import static org.apache.dolphinscheduler.plugin.task.java.JavaConstants.PUBLIC_CLASS_NAME_REGEX;
+
+
+import org.apache.dolphinscheduler.plugin.task.api.AbstractTaskExecutor;
+import org.apache.dolphinscheduler.plugin.task.api.ShellCommandExecutor;
+import org.apache.dolphinscheduler.plugin.task.api.TaskConstants;
+import org.apache.dolphinscheduler.plugin.task.api.TaskException;
+import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext;
+import org.apache.dolphinscheduler.plugin.task.api.model.Property;
+import org.apache.dolphinscheduler.plugin.task.api.model.ResourceInfo;
+import org.apache.dolphinscheduler.plugin.task.api.model.TaskResponse;
+import org.apache.dolphinscheduler.plugin.task.api.parameters.AbstractParameters;
+import org.apache.dolphinscheduler.plugin.task.api.parser.ParamUtils;
+import org.apache.dolphinscheduler.plugin.task.api.parser.ParameterUtils;
+import org.apache.dolphinscheduler.plugin.task.api.utils.MapUtils;
+import org.apache.dolphinscheduler.plugin.task.java.exception.JavaSourceFileExistException;
+import org.apache.dolphinscheduler.plugin.task.java.exception.PublicClassNotFoundException;
+import org.apache.dolphinscheduler.plugin.task.java.exception.RunTypeNotFoundException;
+import org.apache.dolphinscheduler.spi.utils.JSONUtils;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.lang3.SystemUtils;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import com.google.common.base.Preconditions;
+
+/**
+ * java task
+ */
+public class JavaTask extends AbstractTaskExecutor {
+
+    /**
+     * Contains various parameters for this task
+     */
+    private JavaParameters javaParameters;
+
+    /**
+     * To run shell commands
+     */
+    private ShellCommandExecutor shellCommandExecutor;
+
+    /**
+     * task execution context
+     */
+    private TaskExecutionContext taskRequest;
+
+    /**
+     * class name regex pattern
+     */
+    private static final Pattern classNamePattern = Pattern.compile(PUBLIC_CLASS_NAME_REGEX);
+
+    /**
+     * @description: Construct a Java task
+     * @param: [org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext]
+     * @return: JavaTask
+     **/

Review Comment:
   This kind of comment is not needed.



##########
dolphinscheduler-task-plugin/dolphinscheduler-task-java/src/main/java/org/apache/dolphinscheduler/plugin/task/java/JavaTask.java:
##########
@@ -0,0 +1,422 @@
+/*
+ * 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 static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.SINGLE_SLASH;
+import static org.apache.dolphinscheduler.plugin.task.java.JavaConstants.JAVA_HOME_VAR;
+import static org.apache.dolphinscheduler.plugin.task.java.JavaConstants.PUBLIC_CLASS_NAME_REGEX;
+
+
+import org.apache.dolphinscheduler.plugin.task.api.AbstractTaskExecutor;
+import org.apache.dolphinscheduler.plugin.task.api.ShellCommandExecutor;
+import org.apache.dolphinscheduler.plugin.task.api.TaskConstants;
+import org.apache.dolphinscheduler.plugin.task.api.TaskException;
+import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext;
+import org.apache.dolphinscheduler.plugin.task.api.model.Property;
+import org.apache.dolphinscheduler.plugin.task.api.model.ResourceInfo;
+import org.apache.dolphinscheduler.plugin.task.api.model.TaskResponse;
+import org.apache.dolphinscheduler.plugin.task.api.parameters.AbstractParameters;
+import org.apache.dolphinscheduler.plugin.task.api.parser.ParamUtils;
+import org.apache.dolphinscheduler.plugin.task.api.parser.ParameterUtils;
+import org.apache.dolphinscheduler.plugin.task.api.utils.MapUtils;
+import org.apache.dolphinscheduler.plugin.task.java.exception.JavaSourceFileExistException;
+import org.apache.dolphinscheduler.plugin.task.java.exception.PublicClassNotFoundException;
+import org.apache.dolphinscheduler.plugin.task.java.exception.RunTypeNotFoundException;
+import org.apache.dolphinscheduler.spi.utils.JSONUtils;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.lang3.SystemUtils;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import com.google.common.base.Preconditions;
+
+/**
+ * java task
+ */
+public class JavaTask extends AbstractTaskExecutor {
+
+    /**
+     * Contains various parameters for this task
+     */
+    private JavaParameters javaParameters;
+
+    /**
+     * To run shell commands
+     */
+    private ShellCommandExecutor shellCommandExecutor;
+
+    /**
+     * task execution context
+     */
+    private TaskExecutionContext taskRequest;
+
+    /**
+     * class name regex pattern
+     */
+    private static final Pattern classNamePattern = Pattern.compile(PUBLIC_CLASS_NAME_REGEX);
+
+    /**
+     * @description: Construct a Java task
+     * @param: [org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext]
+     * @return: JavaTask
+     **/
+    public JavaTask(TaskExecutionContext taskRequest) {
+        super(taskRequest);
+        this.taskRequest = taskRequest;
+        this.shellCommandExecutor = new ShellCommandExecutor(this::logHandle,
+                taskRequest,
+                logger);
+    }
+
+    /**
+     * @description: Initializes a Java task
+     * @param: []
+     * @return: void
+     **/
+    @Override
+    public void init() {
+        logger.info("java task params {}", taskRequest.getTaskParams());
+        javaParameters = JSONUtils.parseObject(taskRequest.getTaskParams(), JavaParameters.class);
+        if (javaParameters == null || !javaParameters.checkParameters()) {
+            throw new TaskException("java task params is not valid");
+        }
+        if (javaParameters.getRunType().equals(JavaConstants.RUN_TYPE_JAR)) {
+            setMainJarName();
+        }
+    }
+
+    /**
+     * @description: Gets the Java source file that was initially processed
+     * @param: []
+     * @return: java.lang.String
+     **/
+    @Override
+    public String getPreScript() {
+        String rawJavaScript = javaParameters.getRawScript().replaceAll("\\r\\n", "\n");
+        try {
+            rawJavaScript = convertJavaSourceCodePlaceholders(rawJavaScript);
+        } catch (StringIndexOutOfBoundsException e) {
+            logger.error("setShareVar field format error, raw java script : {}", rawJavaScript);
+        }
+        return rawJavaScript;
+    }
+
+    /**
+     * @description: Execute Java tasks
+     * @param: []
+     * @return: void
+     **/
+    @Override
+    public void handle() throws Exception {
+        try {
+            // Step 1: judge if is java or jar run type.
+            // Step 2 case1: The jar run type builds the command directly, adding resource to the java -jar class when building the command
+            // Step 2 case2: The java run type, first replace the custom parameters, then compile the code, and then build the command will add resource
+            // Step 3: To run the command
+            String command = null;
+            switch (javaParameters.getRunType()) {
+                case JavaConstants.RUN_TYPE_JAVA:
+                    command = buildJavaCommand();
+                    break;
+                case JavaConstants.RUN_TYPE_JAR:
+                    command = buildJarCommand();
+                    break;
+                default:
+                    throw new RunTypeNotFoundException("run type is required, but it is null now.");
+            }
+            Preconditions.checkNotNull(command, "command not be null.");
+            TaskResponse taskResponse = shellCommandExecutor.run(command);
+            logger.info("java task run result : {}", taskResponse);
+            setExitStatusCode(taskResponse.getExitStatusCode());
+            setAppIds(taskResponse.getAppIds());
+            setProcessId(taskResponse.getProcessId());
+            setVarPool(shellCommandExecutor.getVarPool());
+        } catch (InterruptedException e) {
+            logger.error("java task interrupted ", e);
+            setExitStatusCode(TaskConstants.EXIT_CODE_FAILURE);
+            Thread.currentThread().interrupt();
+        } catch (RunTypeNotFoundException e) {
+            logger.error(e.getMessage());
+            setExitStatusCode(TaskConstants.EXIT_CODE_FAILURE);
+            throw e;
+        } catch (Exception e) {
+            logger.error("java task failed ", e);
+            setExitStatusCode(TaskConstants.EXIT_CODE_FAILURE);
+            throw new TaskException("run java task error", e);
+        }
+    }
+
+    /**
+     * @description: Construct a shell command for the java Run mode
+     * @param: []
+     * @return: java.lang.String
+     **/
+    protected String buildJavaCommand() throws Exception {
+        String sourceCode = buildJavaSourceContent();
+        String className = compilerRawScript(sourceCode);
+        StringBuilder builder = new StringBuilder();
+        builder.append(getJavaCommandPath())
+                .append("java").append(" ")
+                .append(buildResourcePath())
+                .append(" ")
+                .append(className).append(" ")
+                .append(javaParameters.getMainArgs().trim()).append(" ")
+                .append(javaParameters.getJvmArgs().trim());
+        return builder.toString();
+    }
+
+    private void setMainJarName() {
+        ResourceInfo mainJar = javaParameters.getMainJar();
+        String resourceName = getResourceNameOfMainJar(mainJar);
+        mainJar.setRes(resourceName);
+        javaParameters.setMainJar(mainJar);
+    }
+
+    /**
+     * @description: Construct a shell command for the java -jar Run mode
+     * @param: []
+     * @return: java.lang.String
+     **/
+    protected String buildJarCommand() {
+        String fullName = javaParameters.getMainJar().getResourceName();
+        String mainJarName = fullName.substring(0, fullName.lastIndexOf('.'));
+        mainJarName = mainJarName.substring(mainJarName.lastIndexOf('.') + 1) + ".jar";
+        StringBuilder builder = new StringBuilder();
+        builder.append(getJavaCommandPath())
+                .append("java").append(" ")
+                .append(buildResourcePath()).append(" ")
+                .append("-jar").append(" ")
+                .append(taskRequest.getExecutePath())
+                .append(mainJarName).append(" ")
+                .append(javaParameters.getMainArgs().trim()).append(" ")
+                .append(javaParameters.getJvmArgs().trim());
+        return builder.toString();
+    }
+
+    private String getResourceNameOfMainJar(ResourceInfo mainJar) {
+        if (null == mainJar) {
+            throw new RuntimeException("The jar for the task is required.");
+        }
+        return mainJar.getId() == 0
+                ? mainJar.getRes()
+                // when update resource maybe has error
+                : mainJar.getResourceName().replaceFirst(SINGLE_SLASH, "");
+    }
+
+    @Override
+    public void cancelApplication(boolean cancelApplication) throws Exception {
+        // cancel process
+        shellCommandExecutor.cancelApplication();
+    }
+
+    @Override
+    public AbstractParameters getParameters() {
+        return javaParameters;
+    }
+
+    /**
+     * @description: Replaces placeholders such as local variables in source files
+     * @param: [java.lang.String]
+     * @return: java.lang.String
+     **/
+    protected static String convertJavaSourceCodePlaceholders(String rawScript) throws StringIndexOutOfBoundsException {
+        int len = "${setShareVar(${".length();
+        int scriptStart = 0;
+        while ((scriptStart = rawScript.indexOf("${setShareVar(${", scriptStart)) != -1) {
+            int start = -1;
+            int end = rawScript.indexOf('}', scriptStart + len);
+            String prop = rawScript.substring(scriptStart + len, end);
+
+            start = rawScript.indexOf(',', end);
+            end = rawScript.indexOf(')', start);
+
+            String value = rawScript.substring(start + 1, end);
+
+            start = rawScript.indexOf('}', start) + 1;
+            end = rawScript.length();
+
+            String replaceScript = String.format("print(\"${{setValue({},{})}}\".format(\"%s\",%s))", prop, value);
+
+            rawScript = rawScript.substring(0, scriptStart) + replaceScript + rawScript.substring(start, end);
+
+            scriptStart += replaceScript.length();
+        }
+        return rawScript;
+    }
+
+    /**
+     * @description: Creates a Java source file when it does not exist
+     * @param: [java.lang.String, java.lang.String]
+     * @return: java.lang.String
+     **/
+    protected void createJavaSourceFileIfNotExists(String sourceCode, String fileName) throws IOException {
+        logger.info("tenantCode: {}, task dir:{}", taskRequest.getTenantCode(), taskRequest.getExecutePath());
+
+        if (!Files.exists(Paths.get(fileName))) {
+            logger.info("generate java source file: {}", fileName);
+
+            StringBuilder sb = new StringBuilder();
+            sb.append(sourceCode);
+            logger.info(sb.toString());
+
+            // write data to file
+            FileUtils.writeStringToFile(new File(fileName),
+                    sb.toString(),
+                    StandardCharsets.UTF_8);
+        } else {
+            throw new JavaSourceFileExistException("java source file exists, please report an issue on official.");
+        }
+    }
+
+    /**
+     * @description: Construct the full path name of the Java source file from the temporary execution path of the task
+     * @param: []
+     * @return: java.lang.String
+     **/
+    protected String buildJavaSourceCodeFileFullName(String publicClassName) {
+        return String.format(JavaConstants.JAVA_SOURCE_CODE_NAME_TEMPLATE, taskRequest.getExecutePath(), publicClassName);
+    }
+
+    /**
+     * @description: Construct a Classpath or module path based on isModulePath
+     * @param: []
+     * @return: java.lang.String
+     **/
+    protected String buildResourcePath() {
+        StringBuilder builder = new StringBuilder();
+        if (javaParameters.isModulePath()) {
+            builder.append("--module-path");
+        } else {
+            builder.append("--class-path");
+        }
+        builder.append(" ").append(JavaConstants.CLASSPATH_CURRENT_DIR)
+                .append(JavaConstants.PATH_SEPARATOR)
+                .append(taskRequest.getExecutePath());
+        for (ResourceInfo info : javaParameters.getResourceFilesList()) {
+            builder.append(JavaConstants.PATH_SEPARATOR);
+            builder.append(taskRequest.getExecutePath())
+                    .append(info.getResourceName());
+        }
+        return builder.toString();
+    }
+
+    /**
+     * @description: Compile the Java source file
+     * @param: [java.lang.String]
+     * @return: java.lang.String
+     **/
+    protected String compilerRawScript(String sourceCode) throws IOException, InterruptedException {
+        String publicClassName = getPublicClassName(sourceCode);
+        String fileName =  buildJavaSourceCodeFileFullName(publicClassName);
+        createJavaSourceFileIfNotExists(sourceCode, fileName);
+        String compileCommand = buildJavaCompileCommand(fileName, sourceCode);
+        Preconditions.checkNotNull(compileCommand, "command not be null.");
+        TaskResponse compileResponse = shellCommandExecutor.run(compileCommand);
+        // must drop the command file ,if do not ,the next command will not run. because be limited the ShellCommandExecutor's create file rules
+        dropShellCommandFile();

Review Comment:
   This should be a common logic for shell task?



##########
dolphinscheduler-task-plugin/dolphinscheduler-task-java/src/main/java/org/apache/dolphinscheduler/plugin/task/java/JavaTask.java:
##########
@@ -0,0 +1,422 @@
+/*
+ * 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 static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.SINGLE_SLASH;
+import static org.apache.dolphinscheduler.plugin.task.java.JavaConstants.JAVA_HOME_VAR;
+import static org.apache.dolphinscheduler.plugin.task.java.JavaConstants.PUBLIC_CLASS_NAME_REGEX;
+
+
+import org.apache.dolphinscheduler.plugin.task.api.AbstractTaskExecutor;
+import org.apache.dolphinscheduler.plugin.task.api.ShellCommandExecutor;
+import org.apache.dolphinscheduler.plugin.task.api.TaskConstants;
+import org.apache.dolphinscheduler.plugin.task.api.TaskException;
+import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext;
+import org.apache.dolphinscheduler.plugin.task.api.model.Property;
+import org.apache.dolphinscheduler.plugin.task.api.model.ResourceInfo;
+import org.apache.dolphinscheduler.plugin.task.api.model.TaskResponse;
+import org.apache.dolphinscheduler.plugin.task.api.parameters.AbstractParameters;
+import org.apache.dolphinscheduler.plugin.task.api.parser.ParamUtils;
+import org.apache.dolphinscheduler.plugin.task.api.parser.ParameterUtils;
+import org.apache.dolphinscheduler.plugin.task.api.utils.MapUtils;
+import org.apache.dolphinscheduler.plugin.task.java.exception.JavaSourceFileExistException;
+import org.apache.dolphinscheduler.plugin.task.java.exception.PublicClassNotFoundException;
+import org.apache.dolphinscheduler.plugin.task.java.exception.RunTypeNotFoundException;
+import org.apache.dolphinscheduler.spi.utils.JSONUtils;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.lang3.SystemUtils;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import com.google.common.base.Preconditions;
+
+/**
+ * java task
+ */
+public class JavaTask extends AbstractTaskExecutor {
+
+    /**
+     * Contains various parameters for this task
+     */
+    private JavaParameters javaParameters;
+
+    /**
+     * To run shell commands
+     */
+    private ShellCommandExecutor shellCommandExecutor;
+
+    /**
+     * task execution context
+     */
+    private TaskExecutionContext taskRequest;
+
+    /**
+     * class name regex pattern
+     */
+    private static final Pattern classNamePattern = Pattern.compile(PUBLIC_CLASS_NAME_REGEX);
+
+    /**
+     * @description: Construct a Java task
+     * @param: [org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext]
+     * @return: JavaTask
+     **/
+    public JavaTask(TaskExecutionContext taskRequest) {
+        super(taskRequest);
+        this.taskRequest = taskRequest;
+        this.shellCommandExecutor = new ShellCommandExecutor(this::logHandle,
+                taskRequest,
+                logger);
+    }
+
+    /**
+     * @description: Initializes a Java task
+     * @param: []
+     * @return: void
+     **/
+    @Override
+    public void init() {
+        logger.info("java task params {}", taskRequest.getTaskParams());
+        javaParameters = JSONUtils.parseObject(taskRequest.getTaskParams(), JavaParameters.class);
+        if (javaParameters == null || !javaParameters.checkParameters()) {
+            throw new TaskException("java task params is not valid");
+        }
+        if (javaParameters.getRunType().equals(JavaConstants.RUN_TYPE_JAR)) {
+            setMainJarName();
+        }
+    }
+
+    /**
+     * @description: Gets the Java source file that was initially processed
+     * @param: []
+     * @return: java.lang.String
+     **/
+    @Override
+    public String getPreScript() {
+        String rawJavaScript = javaParameters.getRawScript().replaceAll("\\r\\n", "\n");
+        try {
+            rawJavaScript = convertJavaSourceCodePlaceholders(rawJavaScript);
+        } catch (StringIndexOutOfBoundsException e) {
+            logger.error("setShareVar field format error, raw java script : {}", rawJavaScript);
+        }
+        return rawJavaScript;
+    }
+
+    /**
+     * @description: Execute Java tasks
+     * @param: []
+     * @return: void
+     **/
+    @Override
+    public void handle() throws Exception {
+        try {
+            // Step 1: judge if is java or jar run type.
+            // Step 2 case1: The jar run type builds the command directly, adding resource to the java -jar class when building the command
+            // Step 2 case2: The java run type, first replace the custom parameters, then compile the code, and then build the command will add resource
+            // Step 3: To run the command
+            String command = null;
+            switch (javaParameters.getRunType()) {
+                case JavaConstants.RUN_TYPE_JAVA:
+                    command = buildJavaCommand();
+                    break;
+                case JavaConstants.RUN_TYPE_JAR:
+                    command = buildJarCommand();
+                    break;
+                default:
+                    throw new RunTypeNotFoundException("run type is required, but it is null now.");
+            }
+            Preconditions.checkNotNull(command, "command not be null.");
+            TaskResponse taskResponse = shellCommandExecutor.run(command);
+            logger.info("java task run result : {}", taskResponse);
+            setExitStatusCode(taskResponse.getExitStatusCode());
+            setAppIds(taskResponse.getAppIds());
+            setProcessId(taskResponse.getProcessId());
+            setVarPool(shellCommandExecutor.getVarPool());
+        } catch (InterruptedException e) {
+            logger.error("java task interrupted ", e);
+            setExitStatusCode(TaskConstants.EXIT_CODE_FAILURE);
+            Thread.currentThread().interrupt();
+        } catch (RunTypeNotFoundException e) {
+            logger.error(e.getMessage());
+            setExitStatusCode(TaskConstants.EXIT_CODE_FAILURE);
+            throw e;
+        } catch (Exception e) {
+            logger.error("java task failed ", e);
+            setExitStatusCode(TaskConstants.EXIT_CODE_FAILURE);
+            throw new TaskException("run java task error", e);
+        }
+    }
+
+    /**
+     * @description: Construct a shell command for the java Run mode
+     * @param: []
+     * @return: java.lang.String
+     **/
+    protected String buildJavaCommand() throws Exception {

Review Comment:
   ```suggestion
       protected @Nonnull String buildJavaCommand() throws Exception {
   ```



##########
dolphinscheduler-task-plugin/dolphinscheduler-task-java/src/main/java/org/apache/dolphinscheduler/plugin/task/java/JavaTask.java:
##########
@@ -0,0 +1,422 @@
+/*
+ * 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 static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.SINGLE_SLASH;
+import static org.apache.dolphinscheduler.plugin.task.java.JavaConstants.JAVA_HOME_VAR;
+import static org.apache.dolphinscheduler.plugin.task.java.JavaConstants.PUBLIC_CLASS_NAME_REGEX;
+
+
+import org.apache.dolphinscheduler.plugin.task.api.AbstractTaskExecutor;
+import org.apache.dolphinscheduler.plugin.task.api.ShellCommandExecutor;
+import org.apache.dolphinscheduler.plugin.task.api.TaskConstants;
+import org.apache.dolphinscheduler.plugin.task.api.TaskException;
+import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext;
+import org.apache.dolphinscheduler.plugin.task.api.model.Property;
+import org.apache.dolphinscheduler.plugin.task.api.model.ResourceInfo;
+import org.apache.dolphinscheduler.plugin.task.api.model.TaskResponse;
+import org.apache.dolphinscheduler.plugin.task.api.parameters.AbstractParameters;
+import org.apache.dolphinscheduler.plugin.task.api.parser.ParamUtils;
+import org.apache.dolphinscheduler.plugin.task.api.parser.ParameterUtils;
+import org.apache.dolphinscheduler.plugin.task.api.utils.MapUtils;
+import org.apache.dolphinscheduler.plugin.task.java.exception.JavaSourceFileExistException;
+import org.apache.dolphinscheduler.plugin.task.java.exception.PublicClassNotFoundException;
+import org.apache.dolphinscheduler.plugin.task.java.exception.RunTypeNotFoundException;
+import org.apache.dolphinscheduler.spi.utils.JSONUtils;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.lang3.SystemUtils;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import com.google.common.base.Preconditions;
+
+/**
+ * java task
+ */

Review Comment:
   ```suggestion
   
   ```



##########
dolphinscheduler-task-plugin/dolphinscheduler-task-java/src/main/java/org/apache/dolphinscheduler/plugin/task/java/JavaTask.java:
##########
@@ -0,0 +1,422 @@
+/*
+ * 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 static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.SINGLE_SLASH;
+import static org.apache.dolphinscheduler.plugin.task.java.JavaConstants.JAVA_HOME_VAR;
+import static org.apache.dolphinscheduler.plugin.task.java.JavaConstants.PUBLIC_CLASS_NAME_REGEX;
+
+
+import org.apache.dolphinscheduler.plugin.task.api.AbstractTaskExecutor;
+import org.apache.dolphinscheduler.plugin.task.api.ShellCommandExecutor;
+import org.apache.dolphinscheduler.plugin.task.api.TaskConstants;
+import org.apache.dolphinscheduler.plugin.task.api.TaskException;
+import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext;
+import org.apache.dolphinscheduler.plugin.task.api.model.Property;
+import org.apache.dolphinscheduler.plugin.task.api.model.ResourceInfo;
+import org.apache.dolphinscheduler.plugin.task.api.model.TaskResponse;
+import org.apache.dolphinscheduler.plugin.task.api.parameters.AbstractParameters;
+import org.apache.dolphinscheduler.plugin.task.api.parser.ParamUtils;
+import org.apache.dolphinscheduler.plugin.task.api.parser.ParameterUtils;
+import org.apache.dolphinscheduler.plugin.task.api.utils.MapUtils;
+import org.apache.dolphinscheduler.plugin.task.java.exception.JavaSourceFileExistException;
+import org.apache.dolphinscheduler.plugin.task.java.exception.PublicClassNotFoundException;
+import org.apache.dolphinscheduler.plugin.task.java.exception.RunTypeNotFoundException;
+import org.apache.dolphinscheduler.spi.utils.JSONUtils;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.lang3.SystemUtils;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import com.google.common.base.Preconditions;
+
+/**
+ * java task
+ */
+public class JavaTask extends AbstractTaskExecutor {
+
+    /**
+     * Contains various parameters for this task
+     */
+    private JavaParameters javaParameters;
+
+    /**
+     * To run shell commands
+     */
+    private ShellCommandExecutor shellCommandExecutor;
+
+    /**
+     * task execution context
+     */
+    private TaskExecutionContext taskRequest;
+
+    /**
+     * class name regex pattern
+     */
+    private static final Pattern classNamePattern = Pattern.compile(PUBLIC_CLASS_NAME_REGEX);
+
+    /**
+     * @description: Construct a Java task
+     * @param: [org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext]
+     * @return: JavaTask
+     **/
+    public JavaTask(TaskExecutionContext taskRequest) {
+        super(taskRequest);
+        this.taskRequest = taskRequest;
+        this.shellCommandExecutor = new ShellCommandExecutor(this::logHandle,
+                taskRequest,
+                logger);
+    }
+
+    /**
+     * @description: Initializes a Java task
+     * @param: []
+     * @return: void
+     **/
+    @Override
+    public void init() {
+        logger.info("java task params {}", taskRequest.getTaskParams());
+        javaParameters = JSONUtils.parseObject(taskRequest.getTaskParams(), JavaParameters.class);
+        if (javaParameters == null || !javaParameters.checkParameters()) {
+            throw new TaskException("java task params is not valid");
+        }
+        if (javaParameters.getRunType().equals(JavaConstants.RUN_TYPE_JAR)) {
+            setMainJarName();
+        }
+    }
+
+    /**
+     * @description: Gets the Java source file that was initially processed
+     * @param: []
+     * @return: java.lang.String
+     **/
+    @Override
+    public String getPreScript() {
+        String rawJavaScript = javaParameters.getRawScript().replaceAll("\\r\\n", "\n");
+        try {
+            rawJavaScript = convertJavaSourceCodePlaceholders(rawJavaScript);
+        } catch (StringIndexOutOfBoundsException e) {
+            logger.error("setShareVar field format error, raw java script : {}", rawJavaScript);
+        }
+        return rawJavaScript;
+    }
+
+    /**
+     * @description: Execute Java tasks
+     * @param: []
+     * @return: void
+     **/
+    @Override
+    public void handle() throws Exception {
+        try {
+            // Step 1: judge if is java or jar run type.
+            // Step 2 case1: The jar run type builds the command directly, adding resource to the java -jar class when building the command
+            // Step 2 case2: The java run type, first replace the custom parameters, then compile the code, and then build the command will add resource
+            // Step 3: To run the command
+            String command = null;
+            switch (javaParameters.getRunType()) {
+                case JavaConstants.RUN_TYPE_JAVA:
+                    command = buildJavaCommand();
+                    break;
+                case JavaConstants.RUN_TYPE_JAR:
+                    command = buildJarCommand();
+                    break;
+                default:
+                    throw new RunTypeNotFoundException("run type is required, but it is null now.");
+            }
+            Preconditions.checkNotNull(command, "command not be null.");
+            TaskResponse taskResponse = shellCommandExecutor.run(command);
+            logger.info("java task run result : {}", taskResponse);
+            setExitStatusCode(taskResponse.getExitStatusCode());
+            setAppIds(taskResponse.getAppIds());
+            setProcessId(taskResponse.getProcessId());
+            setVarPool(shellCommandExecutor.getVarPool());
+        } catch (InterruptedException e) {
+            logger.error("java task interrupted ", e);
+            setExitStatusCode(TaskConstants.EXIT_CODE_FAILURE);
+            Thread.currentThread().interrupt();
+        } catch (RunTypeNotFoundException e) {
+            logger.error(e.getMessage());
+            setExitStatusCode(TaskConstants.EXIT_CODE_FAILURE);
+            throw e;

Review Comment:
   ```suggestion
           
   ```
   This catch is not needed, if you want to print the exception, it's better to print the thread stack rather than e.getMessage.



##########
dolphinscheduler-task-plugin/dolphinscheduler-task-java/src/main/java/org/apache/dolphinscheduler/plugin/task/java/JavaTask.java:
##########
@@ -0,0 +1,422 @@
+/*
+ * 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 static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.SINGLE_SLASH;
+import static org.apache.dolphinscheduler.plugin.task.java.JavaConstants.JAVA_HOME_VAR;
+import static org.apache.dolphinscheduler.plugin.task.java.JavaConstants.PUBLIC_CLASS_NAME_REGEX;
+
+
+import org.apache.dolphinscheduler.plugin.task.api.AbstractTaskExecutor;
+import org.apache.dolphinscheduler.plugin.task.api.ShellCommandExecutor;
+import org.apache.dolphinscheduler.plugin.task.api.TaskConstants;
+import org.apache.dolphinscheduler.plugin.task.api.TaskException;
+import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext;
+import org.apache.dolphinscheduler.plugin.task.api.model.Property;
+import org.apache.dolphinscheduler.plugin.task.api.model.ResourceInfo;
+import org.apache.dolphinscheduler.plugin.task.api.model.TaskResponse;
+import org.apache.dolphinscheduler.plugin.task.api.parameters.AbstractParameters;
+import org.apache.dolphinscheduler.plugin.task.api.parser.ParamUtils;
+import org.apache.dolphinscheduler.plugin.task.api.parser.ParameterUtils;
+import org.apache.dolphinscheduler.plugin.task.api.utils.MapUtils;
+import org.apache.dolphinscheduler.plugin.task.java.exception.JavaSourceFileExistException;
+import org.apache.dolphinscheduler.plugin.task.java.exception.PublicClassNotFoundException;
+import org.apache.dolphinscheduler.plugin.task.java.exception.RunTypeNotFoundException;
+import org.apache.dolphinscheduler.spi.utils.JSONUtils;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.lang3.SystemUtils;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import com.google.common.base.Preconditions;
+
+/**
+ * java task
+ */
+public class JavaTask extends AbstractTaskExecutor {
+
+    /**
+     * Contains various parameters for this task
+     */
+    private JavaParameters javaParameters;
+
+    /**
+     * To run shell commands
+     */
+    private ShellCommandExecutor shellCommandExecutor;
+
+    /**
+     * task execution context
+     */
+    private TaskExecutionContext taskRequest;
+
+    /**
+     * class name regex pattern
+     */
+    private static final Pattern classNamePattern = Pattern.compile(PUBLIC_CLASS_NAME_REGEX);
+
+    /**
+     * @description: Construct a Java task
+     * @param: [org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext]
+     * @return: JavaTask
+     **/
+    public JavaTask(TaskExecutionContext taskRequest) {
+        super(taskRequest);
+        this.taskRequest = taskRequest;
+        this.shellCommandExecutor = new ShellCommandExecutor(this::logHandle,
+                taskRequest,
+                logger);
+    }
+
+    /**
+     * @description: Initializes a Java task
+     * @param: []
+     * @return: void
+     **/
+    @Override
+    public void init() {
+        logger.info("java task params {}", taskRequest.getTaskParams());
+        javaParameters = JSONUtils.parseObject(taskRequest.getTaskParams(), JavaParameters.class);
+        if (javaParameters == null || !javaParameters.checkParameters()) {
+            throw new TaskException("java task params is not valid");
+        }
+        if (javaParameters.getRunType().equals(JavaConstants.RUN_TYPE_JAR)) {
+            setMainJarName();
+        }
+    }
+
+    /**
+     * @description: Gets the Java source file that was initially processed
+     * @param: []
+     * @return: java.lang.String
+     **/
+    @Override
+    public String getPreScript() {
+        String rawJavaScript = javaParameters.getRawScript().replaceAll("\\r\\n", "\n");
+        try {
+            rawJavaScript = convertJavaSourceCodePlaceholders(rawJavaScript);
+        } catch (StringIndexOutOfBoundsException e) {
+            logger.error("setShareVar field format error, raw java script : {}", rawJavaScript);

Review Comment:
   ```suggestion
               logger.error("setShareVar field format error, raw java script : {}", rawJavaScript, e);
   ```



##########
dolphinscheduler-task-plugin/dolphinscheduler-task-java/src/main/java/org/apache/dolphinscheduler/plugin/task/java/JavaTask.java:
##########
@@ -0,0 +1,422 @@
+/*
+ * 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 static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.SINGLE_SLASH;
+import static org.apache.dolphinscheduler.plugin.task.java.JavaConstants.JAVA_HOME_VAR;
+import static org.apache.dolphinscheduler.plugin.task.java.JavaConstants.PUBLIC_CLASS_NAME_REGEX;
+
+
+import org.apache.dolphinscheduler.plugin.task.api.AbstractTaskExecutor;
+import org.apache.dolphinscheduler.plugin.task.api.ShellCommandExecutor;
+import org.apache.dolphinscheduler.plugin.task.api.TaskConstants;
+import org.apache.dolphinscheduler.plugin.task.api.TaskException;
+import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext;
+import org.apache.dolphinscheduler.plugin.task.api.model.Property;
+import org.apache.dolphinscheduler.plugin.task.api.model.ResourceInfo;
+import org.apache.dolphinscheduler.plugin.task.api.model.TaskResponse;
+import org.apache.dolphinscheduler.plugin.task.api.parameters.AbstractParameters;
+import org.apache.dolphinscheduler.plugin.task.api.parser.ParamUtils;
+import org.apache.dolphinscheduler.plugin.task.api.parser.ParameterUtils;
+import org.apache.dolphinscheduler.plugin.task.api.utils.MapUtils;
+import org.apache.dolphinscheduler.plugin.task.java.exception.JavaSourceFileExistException;
+import org.apache.dolphinscheduler.plugin.task.java.exception.PublicClassNotFoundException;
+import org.apache.dolphinscheduler.plugin.task.java.exception.RunTypeNotFoundException;
+import org.apache.dolphinscheduler.spi.utils.JSONUtils;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.lang3.SystemUtils;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import com.google.common.base.Preconditions;
+
+/**
+ * java task
+ */
+public class JavaTask extends AbstractTaskExecutor {
+
+    /**
+     * Contains various parameters for this task
+     */
+    private JavaParameters javaParameters;
+
+    /**
+     * To run shell commands
+     */
+    private ShellCommandExecutor shellCommandExecutor;
+
+    /**
+     * task execution context
+     */
+    private TaskExecutionContext taskRequest;
+
+    /**
+     * class name regex pattern
+     */
+    private static final Pattern classNamePattern = Pattern.compile(PUBLIC_CLASS_NAME_REGEX);
+
+    /**
+     * @description: Construct a Java task
+     * @param: [org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext]
+     * @return: JavaTask
+     **/
+    public JavaTask(TaskExecutionContext taskRequest) {
+        super(taskRequest);
+        this.taskRequest = taskRequest;
+        this.shellCommandExecutor = new ShellCommandExecutor(this::logHandle,
+                taskRequest,
+                logger);
+    }
+
+    /**
+     * @description: Initializes a Java task
+     * @param: []
+     * @return: void
+     **/
+    @Override
+    public void init() {
+        logger.info("java task params {}", taskRequest.getTaskParams());
+        javaParameters = JSONUtils.parseObject(taskRequest.getTaskParams(), JavaParameters.class);
+        if (javaParameters == null || !javaParameters.checkParameters()) {
+            throw new TaskException("java task params is not valid");
+        }
+        if (javaParameters.getRunType().equals(JavaConstants.RUN_TYPE_JAR)) {
+            setMainJarName();
+        }
+    }
+
+    /**
+     * @description: Gets the Java source file that was initially processed
+     * @param: []
+     * @return: java.lang.String
+     **/
+    @Override
+    public String getPreScript() {
+        String rawJavaScript = javaParameters.getRawScript().replaceAll("\\r\\n", "\n");
+        try {
+            rawJavaScript = convertJavaSourceCodePlaceholders(rawJavaScript);
+        } catch (StringIndexOutOfBoundsException e) {
+            logger.error("setShareVar field format error, raw java script : {}", rawJavaScript);
+        }
+        return rawJavaScript;
+    }
+
+    /**
+     * @description: Execute Java tasks
+     * @param: []
+     * @return: void
+     **/
+    @Override
+    public void handle() throws Exception {
+        try {
+            // Step 1: judge if is java or jar run type.
+            // Step 2 case1: The jar run type builds the command directly, adding resource to the java -jar class when building the command
+            // Step 2 case2: The java run type, first replace the custom parameters, then compile the code, and then build the command will add resource
+            // Step 3: To run the command
+            String command = null;
+            switch (javaParameters.getRunType()) {
+                case JavaConstants.RUN_TYPE_JAVA:
+                    command = buildJavaCommand();
+                    break;
+                case JavaConstants.RUN_TYPE_JAR:
+                    command = buildJarCommand();
+                    break;
+                default:
+                    throw new RunTypeNotFoundException("run type is required, but it is null now.");
+            }
+            Preconditions.checkNotNull(command, "command not be null.");
+            TaskResponse taskResponse = shellCommandExecutor.run(command);
+            logger.info("java task run result : {}", taskResponse);
+            setExitStatusCode(taskResponse.getExitStatusCode());
+            setAppIds(taskResponse.getAppIds());
+            setProcessId(taskResponse.getProcessId());
+            setVarPool(shellCommandExecutor.getVarPool());
+        } catch (InterruptedException e) {
+            logger.error("java task interrupted ", e);
+            setExitStatusCode(TaskConstants.EXIT_CODE_FAILURE);
+            Thread.currentThread().interrupt();
+        } catch (RunTypeNotFoundException e) {
+            logger.error(e.getMessage());
+            setExitStatusCode(TaskConstants.EXIT_CODE_FAILURE);
+            throw e;
+        } catch (Exception e) {
+            logger.error("java task failed ", e);
+            setExitStatusCode(TaskConstants.EXIT_CODE_FAILURE);
+            throw new TaskException("run java task error", e);
+        }
+    }
+
+    /**
+     * @description: Construct a shell command for the java Run mode
+     * @param: []
+     * @return: java.lang.String
+     **/
+    protected String buildJavaCommand() throws Exception {
+        String sourceCode = buildJavaSourceContent();
+        String className = compilerRawScript(sourceCode);
+        StringBuilder builder = new StringBuilder();
+        builder.append(getJavaCommandPath())
+                .append("java").append(" ")
+                .append(buildResourcePath())
+                .append(" ")
+                .append(className).append(" ")
+                .append(javaParameters.getMainArgs().trim()).append(" ")
+                .append(javaParameters.getJvmArgs().trim());
+        return builder.toString();
+    }
+
+    private void setMainJarName() {
+        ResourceInfo mainJar = javaParameters.getMainJar();
+        String resourceName = getResourceNameOfMainJar(mainJar);
+        mainJar.setRes(resourceName);
+        javaParameters.setMainJar(mainJar);
+    }
+
+    /**
+     * @description: Construct a shell command for the java -jar Run mode
+     * @param: []
+     * @return: java.lang.String
+     **/

Review Comment:
   ```suggestion
        * @description: Construct a shell command for the java -jar Run mode
        * @return: java.lang.String
        **/
   ```



##########
dolphinscheduler-task-plugin/dolphinscheduler-task-java/src/main/java/org/apache/dolphinscheduler/plugin/task/java/JavaTask.java:
##########
@@ -0,0 +1,422 @@
+/*
+ * 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 static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.SINGLE_SLASH;
+import static org.apache.dolphinscheduler.plugin.task.java.JavaConstants.JAVA_HOME_VAR;
+import static org.apache.dolphinscheduler.plugin.task.java.JavaConstants.PUBLIC_CLASS_NAME_REGEX;
+
+
+import org.apache.dolphinscheduler.plugin.task.api.AbstractTaskExecutor;
+import org.apache.dolphinscheduler.plugin.task.api.ShellCommandExecutor;
+import org.apache.dolphinscheduler.plugin.task.api.TaskConstants;
+import org.apache.dolphinscheduler.plugin.task.api.TaskException;
+import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext;
+import org.apache.dolphinscheduler.plugin.task.api.model.Property;
+import org.apache.dolphinscheduler.plugin.task.api.model.ResourceInfo;
+import org.apache.dolphinscheduler.plugin.task.api.model.TaskResponse;
+import org.apache.dolphinscheduler.plugin.task.api.parameters.AbstractParameters;
+import org.apache.dolphinscheduler.plugin.task.api.parser.ParamUtils;
+import org.apache.dolphinscheduler.plugin.task.api.parser.ParameterUtils;
+import org.apache.dolphinscheduler.plugin.task.api.utils.MapUtils;
+import org.apache.dolphinscheduler.plugin.task.java.exception.JavaSourceFileExistException;
+import org.apache.dolphinscheduler.plugin.task.java.exception.PublicClassNotFoundException;
+import org.apache.dolphinscheduler.plugin.task.java.exception.RunTypeNotFoundException;
+import org.apache.dolphinscheduler.spi.utils.JSONUtils;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.lang3.SystemUtils;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import com.google.common.base.Preconditions;
+
+/**
+ * java task
+ */
+public class JavaTask extends AbstractTaskExecutor {
+
+    /**
+     * Contains various parameters for this task
+     */
+    private JavaParameters javaParameters;
+
+    /**
+     * To run shell commands
+     */
+    private ShellCommandExecutor shellCommandExecutor;
+
+    /**
+     * task execution context
+     */
+    private TaskExecutionContext taskRequest;
+
+    /**
+     * class name regex pattern
+     */
+    private static final Pattern classNamePattern = Pattern.compile(PUBLIC_CLASS_NAME_REGEX);
+
+    /**
+     * @description: Construct a Java task
+     * @param: [org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext]
+     * @return: JavaTask
+     **/
+    public JavaTask(TaskExecutionContext taskRequest) {
+        super(taskRequest);
+        this.taskRequest = taskRequest;
+        this.shellCommandExecutor = new ShellCommandExecutor(this::logHandle,
+                taskRequest,
+                logger);
+    }
+
+    /**
+     * @description: Initializes a Java task
+     * @param: []
+     * @return: void
+     **/
+    @Override
+    public void init() {
+        logger.info("java task params {}", taskRequest.getTaskParams());
+        javaParameters = JSONUtils.parseObject(taskRequest.getTaskParams(), JavaParameters.class);
+        if (javaParameters == null || !javaParameters.checkParameters()) {
+            throw new TaskException("java task params is not valid");
+        }
+        if (javaParameters.getRunType().equals(JavaConstants.RUN_TYPE_JAR)) {

Review Comment:
   ```suggestion
           if (JavaConstants.RUN_TYPE_JAR.equals(javaParameters.getRunType())) {
   ```



##########
dolphinscheduler-task-plugin/dolphinscheduler-task-java/src/main/java/org/apache/dolphinscheduler/plugin/task/java/JavaTask.java:
##########
@@ -0,0 +1,422 @@
+/*
+ * 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 static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.SINGLE_SLASH;
+import static org.apache.dolphinscheduler.plugin.task.java.JavaConstants.JAVA_HOME_VAR;
+import static org.apache.dolphinscheduler.plugin.task.java.JavaConstants.PUBLIC_CLASS_NAME_REGEX;
+
+
+import org.apache.dolphinscheduler.plugin.task.api.AbstractTaskExecutor;
+import org.apache.dolphinscheduler.plugin.task.api.ShellCommandExecutor;
+import org.apache.dolphinscheduler.plugin.task.api.TaskConstants;
+import org.apache.dolphinscheduler.plugin.task.api.TaskException;
+import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext;
+import org.apache.dolphinscheduler.plugin.task.api.model.Property;
+import org.apache.dolphinscheduler.plugin.task.api.model.ResourceInfo;
+import org.apache.dolphinscheduler.plugin.task.api.model.TaskResponse;
+import org.apache.dolphinscheduler.plugin.task.api.parameters.AbstractParameters;
+import org.apache.dolphinscheduler.plugin.task.api.parser.ParamUtils;
+import org.apache.dolphinscheduler.plugin.task.api.parser.ParameterUtils;
+import org.apache.dolphinscheduler.plugin.task.api.utils.MapUtils;
+import org.apache.dolphinscheduler.plugin.task.java.exception.JavaSourceFileExistException;
+import org.apache.dolphinscheduler.plugin.task.java.exception.PublicClassNotFoundException;
+import org.apache.dolphinscheduler.plugin.task.java.exception.RunTypeNotFoundException;
+import org.apache.dolphinscheduler.spi.utils.JSONUtils;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.lang3.SystemUtils;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import com.google.common.base.Preconditions;
+
+/**
+ * java task
+ */
+public class JavaTask extends AbstractTaskExecutor {
+
+    /**
+     * Contains various parameters for this task
+     */
+    private JavaParameters javaParameters;
+
+    /**
+     * To run shell commands
+     */
+    private ShellCommandExecutor shellCommandExecutor;
+
+    /**
+     * task execution context
+     */
+    private TaskExecutionContext taskRequest;
+
+    /**
+     * class name regex pattern
+     */
+    private static final Pattern classNamePattern = Pattern.compile(PUBLIC_CLASS_NAME_REGEX);
+
+    /**
+     * @description: Construct a Java task
+     * @param: [org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext]
+     * @return: JavaTask
+     **/
+    public JavaTask(TaskExecutionContext taskRequest) {
+        super(taskRequest);
+        this.taskRequest = taskRequest;
+        this.shellCommandExecutor = new ShellCommandExecutor(this::logHandle,
+                taskRequest,
+                logger);
+    }
+
+    /**
+     * @description: Initializes a Java task
+     * @param: []
+     * @return: void
+     **/
+    @Override
+    public void init() {
+        logger.info("java task params {}", taskRequest.getTaskParams());
+        javaParameters = JSONUtils.parseObject(taskRequest.getTaskParams(), JavaParameters.class);
+        if (javaParameters == null || !javaParameters.checkParameters()) {
+            throw new TaskException("java task params is not valid");
+        }
+        if (javaParameters.getRunType().equals(JavaConstants.RUN_TYPE_JAR)) {
+            setMainJarName();
+        }
+    }
+
+    /**
+     * @description: Gets the Java source file that was initially processed
+     * @param: []
+     * @return: java.lang.String
+     **/
+    @Override
+    public String getPreScript() {
+        String rawJavaScript = javaParameters.getRawScript().replaceAll("\\r\\n", "\n");
+        try {
+            rawJavaScript = convertJavaSourceCodePlaceholders(rawJavaScript);
+        } catch (StringIndexOutOfBoundsException e) {
+            logger.error("setShareVar field format error, raw java script : {}", rawJavaScript);
+        }
+        return rawJavaScript;
+    }
+
+    /**
+     * @description: Execute Java tasks
+     * @param: []
+     * @return: void
+     **/
+    @Override
+    public void handle() throws Exception {
+        try {
+            // Step 1: judge if is java or jar run type.
+            // Step 2 case1: The jar run type builds the command directly, adding resource to the java -jar class when building the command
+            // Step 2 case2: The java run type, first replace the custom parameters, then compile the code, and then build the command will add resource
+            // Step 3: To run the command
+            String command = null;
+            switch (javaParameters.getRunType()) {
+                case JavaConstants.RUN_TYPE_JAVA:
+                    command = buildJavaCommand();
+                    break;
+                case JavaConstants.RUN_TYPE_JAR:
+                    command = buildJarCommand();
+                    break;
+                default:
+                    throw new RunTypeNotFoundException("run type is required, but it is null now.");
+            }
+            Preconditions.checkNotNull(command, "command not be null.");
+            TaskResponse taskResponse = shellCommandExecutor.run(command);
+            logger.info("java task run result : {}", taskResponse);
+            setExitStatusCode(taskResponse.getExitStatusCode());
+            setAppIds(taskResponse.getAppIds());
+            setProcessId(taskResponse.getProcessId());
+            setVarPool(shellCommandExecutor.getVarPool());
+        } catch (InterruptedException e) {
+            logger.error("java task interrupted ", e);
+            setExitStatusCode(TaskConstants.EXIT_CODE_FAILURE);
+            Thread.currentThread().interrupt();
+        } catch (RunTypeNotFoundException e) {
+            logger.error(e.getMessage());
+            setExitStatusCode(TaskConstants.EXIT_CODE_FAILURE);
+            throw e;
+        } catch (Exception e) {
+            logger.error("java task failed ", e);
+            setExitStatusCode(TaskConstants.EXIT_CODE_FAILURE);
+            throw new TaskException("run java task error", e);
+        }
+    }
+
+    /**
+     * @description: Construct a shell command for the java Run mode
+     * @param: []
+     * @return: java.lang.String
+     **/
+    protected String buildJavaCommand() throws Exception {
+        String sourceCode = buildJavaSourceContent();
+        String className = compilerRawScript(sourceCode);
+        StringBuilder builder = new StringBuilder();
+        builder.append(getJavaCommandPath())
+                .append("java").append(" ")
+                .append(buildResourcePath())
+                .append(" ")
+                .append(className).append(" ")
+                .append(javaParameters.getMainArgs().trim()).append(" ")
+                .append(javaParameters.getJvmArgs().trim());
+        return builder.toString();
+    }
+
+    private void setMainJarName() {
+        ResourceInfo mainJar = javaParameters.getMainJar();
+        String resourceName = getResourceNameOfMainJar(mainJar);
+        mainJar.setRes(resourceName);
+        javaParameters.setMainJar(mainJar);
+    }
+
+    /**
+     * @description: Construct a shell command for the java -jar Run mode
+     * @param: []
+     * @return: java.lang.String
+     **/
+    protected String buildJarCommand() {
+        String fullName = javaParameters.getMainJar().getResourceName();
+        String mainJarName = fullName.substring(0, fullName.lastIndexOf('.'));
+        mainJarName = mainJarName.substring(mainJarName.lastIndexOf('.') + 1) + ".jar";
+        StringBuilder builder = new StringBuilder();
+        builder.append(getJavaCommandPath())
+                .append("java").append(" ")
+                .append(buildResourcePath()).append(" ")
+                .append("-jar").append(" ")
+                .append(taskRequest.getExecutePath())
+                .append(mainJarName).append(" ")
+                .append(javaParameters.getMainArgs().trim()).append(" ")
+                .append(javaParameters.getJvmArgs().trim());
+        return builder.toString();
+    }
+
+    private String getResourceNameOfMainJar(ResourceInfo mainJar) {
+        if (null == mainJar) {
+            throw new RuntimeException("The jar for the task is required.");
+        }
+        return mainJar.getId() == 0
+                ? mainJar.getRes()
+                // when update resource maybe has error
+                : mainJar.getResourceName().replaceFirst(SINGLE_SLASH, "");
+    }
+
+    @Override
+    public void cancelApplication(boolean cancelApplication) throws Exception {
+        // cancel process
+        shellCommandExecutor.cancelApplication();
+    }
+
+    @Override
+    public AbstractParameters getParameters() {
+        return javaParameters;
+    }
+
+    /**
+     * @description: Replaces placeholders such as local variables in source files
+     * @param: [java.lang.String]
+     * @return: java.lang.String

Review Comment:
   AFAIK, this is not the standard javadoc?



##########
dolphinscheduler-task-plugin/dolphinscheduler-task-java/src/main/java/org/apache/dolphinscheduler/plugin/task/java/JavaTask.java:
##########
@@ -0,0 +1,422 @@
+/*
+ * 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 static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.SINGLE_SLASH;
+import static org.apache.dolphinscheduler.plugin.task.java.JavaConstants.JAVA_HOME_VAR;
+import static org.apache.dolphinscheduler.plugin.task.java.JavaConstants.PUBLIC_CLASS_NAME_REGEX;
+
+
+import org.apache.dolphinscheduler.plugin.task.api.AbstractTaskExecutor;
+import org.apache.dolphinscheduler.plugin.task.api.ShellCommandExecutor;
+import org.apache.dolphinscheduler.plugin.task.api.TaskConstants;
+import org.apache.dolphinscheduler.plugin.task.api.TaskException;
+import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext;
+import org.apache.dolphinscheduler.plugin.task.api.model.Property;
+import org.apache.dolphinscheduler.plugin.task.api.model.ResourceInfo;
+import org.apache.dolphinscheduler.plugin.task.api.model.TaskResponse;
+import org.apache.dolphinscheduler.plugin.task.api.parameters.AbstractParameters;
+import org.apache.dolphinscheduler.plugin.task.api.parser.ParamUtils;
+import org.apache.dolphinscheduler.plugin.task.api.parser.ParameterUtils;
+import org.apache.dolphinscheduler.plugin.task.api.utils.MapUtils;
+import org.apache.dolphinscheduler.plugin.task.java.exception.JavaSourceFileExistException;
+import org.apache.dolphinscheduler.plugin.task.java.exception.PublicClassNotFoundException;
+import org.apache.dolphinscheduler.plugin.task.java.exception.RunTypeNotFoundException;
+import org.apache.dolphinscheduler.spi.utils.JSONUtils;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.lang3.SystemUtils;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import com.google.common.base.Preconditions;
+
+/**
+ * java task
+ */
+public class JavaTask extends AbstractTaskExecutor {
+
+    /**
+     * Contains various parameters for this task
+     */
+    private JavaParameters javaParameters;
+
+    /**
+     * To run shell commands
+     */
+    private ShellCommandExecutor shellCommandExecutor;
+
+    /**
+     * task execution context
+     */
+    private TaskExecutionContext taskRequest;
+
+    /**
+     * class name regex pattern
+     */
+    private static final Pattern classNamePattern = Pattern.compile(PUBLIC_CLASS_NAME_REGEX);
+
+    /**
+     * @description: Construct a Java task
+     * @param: [org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext]
+     * @return: JavaTask
+     **/
+    public JavaTask(TaskExecutionContext taskRequest) {
+        super(taskRequest);
+        this.taskRequest = taskRequest;
+        this.shellCommandExecutor = new ShellCommandExecutor(this::logHandle,
+                taskRequest,
+                logger);
+    }
+
+    /**
+     * @description: Initializes a Java task
+     * @param: []
+     * @return: void
+     **/
+    @Override
+    public void init() {
+        logger.info("java task params {}", taskRequest.getTaskParams());
+        javaParameters = JSONUtils.parseObject(taskRequest.getTaskParams(), JavaParameters.class);
+        if (javaParameters == null || !javaParameters.checkParameters()) {
+            throw new TaskException("java task params is not valid");
+        }
+        if (javaParameters.getRunType().equals(JavaConstants.RUN_TYPE_JAR)) {
+            setMainJarName();
+        }
+    }
+
+    /**
+     * @description: Gets the Java source file that was initially processed
+     * @param: []
+     * @return: java.lang.String
+     **/
+    @Override
+    public String getPreScript() {
+        String rawJavaScript = javaParameters.getRawScript().replaceAll("\\r\\n", "\n");
+        try {
+            rawJavaScript = convertJavaSourceCodePlaceholders(rawJavaScript);
+        } catch (StringIndexOutOfBoundsException e) {
+            logger.error("setShareVar field format error, raw java script : {}", rawJavaScript);
+        }
+        return rawJavaScript;
+    }
+
+    /**
+     * @description: Execute Java tasks
+     * @param: []
+     * @return: void
+     **/
+    @Override
+    public void handle() throws Exception {
+        try {
+            // Step 1: judge if is java or jar run type.
+            // Step 2 case1: The jar run type builds the command directly, adding resource to the java -jar class when building the command
+            // Step 2 case2: The java run type, first replace the custom parameters, then compile the code, and then build the command will add resource
+            // Step 3: To run the command
+            String command = null;
+            switch (javaParameters.getRunType()) {
+                case JavaConstants.RUN_TYPE_JAVA:
+                    command = buildJavaCommand();
+                    break;
+                case JavaConstants.RUN_TYPE_JAR:
+                    command = buildJarCommand();
+                    break;
+                default:
+                    throw new RunTypeNotFoundException("run type is required, but it is null now.");
+            }
+            Preconditions.checkNotNull(command, "command not be null.");
+            TaskResponse taskResponse = shellCommandExecutor.run(command);
+            logger.info("java task run result : {}", taskResponse);
+            setExitStatusCode(taskResponse.getExitStatusCode());
+            setAppIds(taskResponse.getAppIds());
+            setProcessId(taskResponse.getProcessId());
+            setVarPool(shellCommandExecutor.getVarPool());
+        } catch (InterruptedException e) {
+            logger.error("java task interrupted ", e);
+            setExitStatusCode(TaskConstants.EXIT_CODE_FAILURE);
+            Thread.currentThread().interrupt();
+        } catch (RunTypeNotFoundException e) {
+            logger.error(e.getMessage());
+            setExitStatusCode(TaskConstants.EXIT_CODE_FAILURE);
+            throw e;
+        } catch (Exception e) {
+            logger.error("java task failed ", e);
+            setExitStatusCode(TaskConstants.EXIT_CODE_FAILURE);
+            throw new TaskException("run java task error", e);
+        }
+    }
+
+    /**
+     * @description: Construct a shell command for the java Run mode
+     * @param: []
+     * @return: java.lang.String
+     **/
+    protected String buildJavaCommand() throws Exception {
+        String sourceCode = buildJavaSourceContent();
+        String className = compilerRawScript(sourceCode);
+        StringBuilder builder = new StringBuilder();
+        builder.append(getJavaCommandPath())
+                .append("java").append(" ")
+                .append(buildResourcePath())
+                .append(" ")
+                .append(className).append(" ")
+                .append(javaParameters.getMainArgs().trim()).append(" ")
+                .append(javaParameters.getJvmArgs().trim());
+        return builder.toString();
+    }
+
+    private void setMainJarName() {
+        ResourceInfo mainJar = javaParameters.getMainJar();
+        String resourceName = getResourceNameOfMainJar(mainJar);
+        mainJar.setRes(resourceName);
+        javaParameters.setMainJar(mainJar);
+    }
+
+    /**
+     * @description: Construct a shell command for the java -jar Run mode
+     * @param: []
+     * @return: java.lang.String
+     **/
+    protected String buildJarCommand() {
+        String fullName = javaParameters.getMainJar().getResourceName();
+        String mainJarName = fullName.substring(0, fullName.lastIndexOf('.'));
+        mainJarName = mainJarName.substring(mainJarName.lastIndexOf('.') + 1) + ".jar";
+        StringBuilder builder = new StringBuilder();
+        builder.append(getJavaCommandPath())
+                .append("java").append(" ")
+                .append(buildResourcePath()).append(" ")
+                .append("-jar").append(" ")
+                .append(taskRequest.getExecutePath())
+                .append(mainJarName).append(" ")
+                .append(javaParameters.getMainArgs().trim()).append(" ")
+                .append(javaParameters.getJvmArgs().trim());
+        return builder.toString();
+    }
+
+    private String getResourceNameOfMainJar(ResourceInfo mainJar) {
+        if (null == mainJar) {
+            throw new RuntimeException("The jar for the task is required.");
+        }
+        return mainJar.getId() == 0
+                ? mainJar.getRes()
+                // when update resource maybe has error
+                : mainJar.getResourceName().replaceFirst(SINGLE_SLASH, "");
+    }
+
+    @Override
+    public void cancelApplication(boolean cancelApplication) throws Exception {
+        // cancel process
+        shellCommandExecutor.cancelApplication();
+    }
+
+    @Override
+    public AbstractParameters getParameters() {
+        return javaParameters;
+    }
+
+    /**
+     * @description: Replaces placeholders such as local variables in source files
+     * @param: [java.lang.String]
+     * @return: java.lang.String
+     **/
+    protected static String convertJavaSourceCodePlaceholders(String rawScript) throws StringIndexOutOfBoundsException {

Review Comment:
   Can we directly use `ParameterUtils.convertParameterPlaceholders`?



##########
dolphinscheduler-task-plugin/dolphinscheduler-task-java/src/main/java/org/apache/dolphinscheduler/plugin/task/java/JavaTask.java:
##########
@@ -0,0 +1,422 @@
+/*
+ * 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 static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.SINGLE_SLASH;
+import static org.apache.dolphinscheduler.plugin.task.java.JavaConstants.JAVA_HOME_VAR;
+import static org.apache.dolphinscheduler.plugin.task.java.JavaConstants.PUBLIC_CLASS_NAME_REGEX;
+
+
+import org.apache.dolphinscheduler.plugin.task.api.AbstractTaskExecutor;
+import org.apache.dolphinscheduler.plugin.task.api.ShellCommandExecutor;
+import org.apache.dolphinscheduler.plugin.task.api.TaskConstants;
+import org.apache.dolphinscheduler.plugin.task.api.TaskException;
+import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext;
+import org.apache.dolphinscheduler.plugin.task.api.model.Property;
+import org.apache.dolphinscheduler.plugin.task.api.model.ResourceInfo;
+import org.apache.dolphinscheduler.plugin.task.api.model.TaskResponse;
+import org.apache.dolphinscheduler.plugin.task.api.parameters.AbstractParameters;
+import org.apache.dolphinscheduler.plugin.task.api.parser.ParamUtils;
+import org.apache.dolphinscheduler.plugin.task.api.parser.ParameterUtils;
+import org.apache.dolphinscheduler.plugin.task.api.utils.MapUtils;
+import org.apache.dolphinscheduler.plugin.task.java.exception.JavaSourceFileExistException;
+import org.apache.dolphinscheduler.plugin.task.java.exception.PublicClassNotFoundException;
+import org.apache.dolphinscheduler.plugin.task.java.exception.RunTypeNotFoundException;
+import org.apache.dolphinscheduler.spi.utils.JSONUtils;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.lang3.SystemUtils;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import com.google.common.base.Preconditions;
+
+/**
+ * java task
+ */
+public class JavaTask extends AbstractTaskExecutor {
+
+    /**
+     * Contains various parameters for this task
+     */
+    private JavaParameters javaParameters;
+
+    /**
+     * To run shell commands
+     */
+    private ShellCommandExecutor shellCommandExecutor;
+
+    /**
+     * task execution context
+     */
+    private TaskExecutionContext taskRequest;
+
+    /**
+     * class name regex pattern
+     */
+    private static final Pattern classNamePattern = Pattern.compile(PUBLIC_CLASS_NAME_REGEX);
+
+    /**
+     * @description: Construct a Java task
+     * @param: [org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext]
+     * @return: JavaTask
+     **/
+    public JavaTask(TaskExecutionContext taskRequest) {
+        super(taskRequest);
+        this.taskRequest = taskRequest;
+        this.shellCommandExecutor = new ShellCommandExecutor(this::logHandle,
+                taskRequest,
+                logger);
+    }
+
+    /**
+     * @description: Initializes a Java task
+     * @param: []
+     * @return: void
+     **/
+    @Override
+    public void init() {
+        logger.info("java task params {}", taskRequest.getTaskParams());
+        javaParameters = JSONUtils.parseObject(taskRequest.getTaskParams(), JavaParameters.class);
+        if (javaParameters == null || !javaParameters.checkParameters()) {
+            throw new TaskException("java task params is not valid");
+        }
+        if (javaParameters.getRunType().equals(JavaConstants.RUN_TYPE_JAR)) {
+            setMainJarName();
+        }
+    }
+
+    /**
+     * @description: Gets the Java source file that was initially processed
+     * @param: []
+     * @return: java.lang.String
+     **/
+    @Override
+    public String getPreScript() {
+        String rawJavaScript = javaParameters.getRawScript().replaceAll("\\r\\n", "\n");
+        try {
+            rawJavaScript = convertJavaSourceCodePlaceholders(rawJavaScript);
+        } catch (StringIndexOutOfBoundsException e) {
+            logger.error("setShareVar field format error, raw java script : {}", rawJavaScript);
+        }
+        return rawJavaScript;
+    }
+
+    /**
+     * @description: Execute Java tasks
+     * @param: []
+     * @return: void
+     **/
+    @Override
+    public void handle() throws Exception {
+        try {
+            // Step 1: judge if is java or jar run type.
+            // Step 2 case1: The jar run type builds the command directly, adding resource to the java -jar class when building the command
+            // Step 2 case2: The java run type, first replace the custom parameters, then compile the code, and then build the command will add resource
+            // Step 3: To run the command
+            String command = null;
+            switch (javaParameters.getRunType()) {
+                case JavaConstants.RUN_TYPE_JAVA:
+                    command = buildJavaCommand();
+                    break;
+                case JavaConstants.RUN_TYPE_JAR:
+                    command = buildJarCommand();
+                    break;
+                default:
+                    throw new RunTypeNotFoundException("run type is required, but it is null now.");
+            }
+            Preconditions.checkNotNull(command, "command not be null.");
+            TaskResponse taskResponse = shellCommandExecutor.run(command);
+            logger.info("java task run result : {}", taskResponse);
+            setExitStatusCode(taskResponse.getExitStatusCode());
+            setAppIds(taskResponse.getAppIds());
+            setProcessId(taskResponse.getProcessId());
+            setVarPool(shellCommandExecutor.getVarPool());
+        } catch (InterruptedException e) {
+            logger.error("java task interrupted ", e);
+            setExitStatusCode(TaskConstants.EXIT_CODE_FAILURE);
+            Thread.currentThread().interrupt();
+        } catch (RunTypeNotFoundException e) {
+            logger.error(e.getMessage());
+            setExitStatusCode(TaskConstants.EXIT_CODE_FAILURE);
+            throw e;
+        } catch (Exception e) {
+            logger.error("java task failed ", e);
+            setExitStatusCode(TaskConstants.EXIT_CODE_FAILURE);
+            throw new TaskException("run java task error", e);
+        }
+    }
+
+    /**
+     * @description: Construct a shell command for the java Run mode
+     * @param: []
+     * @return: java.lang.String
+     **/

Review Comment:
   ```suggestion
        * @description: Construct a shell command for the java Run mode
        * @return: java.lang.String
        **/
   ```



-- 
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


[GitHub] [dolphinscheduler] 106umao commented on a diff in pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
106umao commented on code in PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#discussion_r945302204


##########
dolphinscheduler-task-plugin/dolphinscheduler-task-java/src/main/java/org/apache/dolphinscheduler/plugin/task/java/JavaTask.java:
##########
@@ -0,0 +1,422 @@
+/*
+ * 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 static org.apache.dolphinscheduler.plugin.task.api.TaskConstants.SINGLE_SLASH;
+import static org.apache.dolphinscheduler.plugin.task.java.JavaConstants.JAVA_HOME_VAR;
+import static org.apache.dolphinscheduler.plugin.task.java.JavaConstants.PUBLIC_CLASS_NAME_REGEX;
+
+
+import org.apache.dolphinscheduler.plugin.task.api.AbstractTaskExecutor;
+import org.apache.dolphinscheduler.plugin.task.api.ShellCommandExecutor;
+import org.apache.dolphinscheduler.plugin.task.api.TaskConstants;
+import org.apache.dolphinscheduler.plugin.task.api.TaskException;
+import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext;
+import org.apache.dolphinscheduler.plugin.task.api.model.Property;
+import org.apache.dolphinscheduler.plugin.task.api.model.ResourceInfo;
+import org.apache.dolphinscheduler.plugin.task.api.model.TaskResponse;
+import org.apache.dolphinscheduler.plugin.task.api.parameters.AbstractParameters;
+import org.apache.dolphinscheduler.plugin.task.api.parser.ParamUtils;
+import org.apache.dolphinscheduler.plugin.task.api.parser.ParameterUtils;
+import org.apache.dolphinscheduler.plugin.task.api.utils.MapUtils;
+import org.apache.dolphinscheduler.plugin.task.java.exception.JavaSourceFileExistException;
+import org.apache.dolphinscheduler.plugin.task.java.exception.PublicClassNotFoundException;
+import org.apache.dolphinscheduler.plugin.task.java.exception.RunTypeNotFoundException;
+import org.apache.dolphinscheduler.spi.utils.JSONUtils;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.lang3.SystemUtils;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import com.google.common.base.Preconditions;
+
+/**
+ * java task
+ */
+public class JavaTask extends AbstractTaskExecutor {
+
+    /**
+     * Contains various parameters for this task
+     */
+    private JavaParameters javaParameters;
+
+    /**
+     * To run shell commands
+     */
+    private ShellCommandExecutor shellCommandExecutor;
+
+    /**
+     * task execution context
+     */
+    private TaskExecutionContext taskRequest;
+
+    /**
+     * class name regex pattern
+     */
+    private static final Pattern classNamePattern = Pattern.compile(PUBLIC_CLASS_NAME_REGEX);
+
+    /**
+     * @description: Construct a Java task
+     * @param: [org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext]
+     * @return: JavaTask
+     **/

Review Comment:
   sure



-- 
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


[GitHub] [dolphinscheduler] SbloodyS commented on a diff in pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
SbloodyS commented on code in PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#discussion_r943193469


##########
docs/docs/zh/guide/task/java.md:
##########
@@ -0,0 +1,50 @@
+# JAVA 节点
+
+## 综述
+
+该节点用于执行 java 类型的任务,支持使用单文件和jar包作为程序入口。
+
+## 创建任务
+
+- 点击项目管理 -> 项目名称 -> 工作流定义,点击”创建工作流”按钮,进入 DAG 编辑页面:
+
+- 拖动工具栏的JAVA任务节点到画板中。
+
+## 任务参数
+
+- 节点名称:设置任务的名称。一个工作流定义中的节点名称是唯一的。
+- 运行标志:标识这个节点是否能正常调度,如果不需要执行,可以打开禁止执行开关。
+- 描述:描述该节点的功能。
+- 任务优先级:worker 线程数不足时,根据优先级从高到低依次执行,优先级一样时根据先进先出原则执行。
+- Worker 分组:任务分配给 worker 组的机器机执行,选择 Default,会随机选择一台 worker 机执行。
+- 环境名称:配置运行任务的环境。
+- 失败重试次数:任务失败重新提交的次数,支持下拉和手填。
+- 失败重试间隔:任务失败重新提交任务的时间间隔,支持下拉和手填。
+- 延迟执行时间:任务延迟执行的时间,以分为单位。
+- 超时告警:勾选超时告警、超时失败,当任务超过"超时时长"后,会发送告警邮件并且任务执行失败。
+- 模块路劲:开启使用JAVA9+的模块化特性,把所有资源放入--module-path中,要求您的worker中的JDK版本支持模块化。

Review Comment:
   ```suggestion
   - 模块路径:开启使用JAVA9+的模块化特性,把所有资源放入--module-path中,要求您的worker中的JDK版本支持模块化。
   ```



-- 
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


[GitHub] [dolphinscheduler] EricGao888 commented on a diff in pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
EricGao888 commented on code in PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#discussion_r940828235


##########
dolphinscheduler-task-plugin/dolphinscheduler-task-java/src/main/java/org/apache/dolphinscheduler/plugin/task/java/JavaParameters.java:
##########
@@ -0,0 +1,89 @@
+/*
+ * 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 org.apache.dolphinscheduler.plugin.task.api.model.ResourceInfo;
+import org.apache.dolphinscheduler.plugin.task.api.parameters.AbstractParameters;
+
+import java.util.List;
+
+import lombok.Getter;
+import lombok.Setter;
+import lombok.ToString;
+
+@Getter

Review Comment:
   Sorry for the trouble, could you please use `@Data` here? We have fixed the `sonar` to exclude generated code and we'd better keep things consistent as discussed in https://github.com/apache/dolphinscheduler/issues/11074
   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


[GitHub] [dolphinscheduler] sonarcloud[bot] commented on pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
sonarcloud[bot] commented on PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#issuecomment-1240171956

   SonarCloud Quality Gate failed.&nbsp; &nbsp; [![Quality Gate failed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/failed-16px.png 'Quality Gate failed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=10689)
   
   [![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png 'Bug')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG)  
   [![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png 'Vulnerability')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY)  
   [![Security Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png 'Security Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT)  
   [![Code Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png 'Code Smell')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL) [8 Code Smells](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL)
   
   [![0.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/0-16px.png '0.0%')](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_coverage&view=list) [0.0% Coverage](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_coverage&view=list)  
   [![2.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3-16px.png '2.0%')](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_duplicated_lines_density&view=list) [2.0% Duplication](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_duplicated_lines_density&view=list)
   
   


-- 
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


[GitHub] [dolphinscheduler] zhuangchong commented on pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
zhuangchong commented on PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#issuecomment-1239887269

   Please solve the ci check license error.


-- 
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


[GitHub] [dolphinscheduler] sonarcloud[bot] commented on pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
sonarcloud[bot] commented on PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#issuecomment-1240175275

   SonarCloud Quality Gate failed.&nbsp; &nbsp; [![Quality Gate failed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/failed-16px.png 'Quality Gate failed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=10689)
   
   [![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png 'Bug')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG)  
   [![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png 'Vulnerability')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY)  
   [![Security Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png 'Security Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT)  
   [![Code Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png 'Code Smell')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL) [8 Code Smells](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL)
   
   [![0.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/0-16px.png '0.0%')](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_coverage&view=list) [0.0% Coverage](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_coverage&view=list)  
   [![2.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3-16px.png '2.0%')](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_duplicated_lines_density&view=list) [2.0% Duplication](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_duplicated_lines_density&view=list)
   
   


-- 
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


[GitHub] [dolphinscheduler] 106umao commented on a diff in pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
106umao commented on code in PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#discussion_r921247226


##########
dolphinscheduler-task-plugin/dolphinscheduler-task-java/src/main/java/org/apache/dolphinscheduler/plugin/task/java/JavaTask.java:
##########
@@ -0,0 +1,343 @@
+/*
+ * 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 org.apache.dolphinscheduler.plugin.task.api.AbstractTaskExecutor;
+import org.apache.dolphinscheduler.plugin.task.api.ShellCommandExecutor;
+import org.apache.dolphinscheduler.plugin.task.api.TaskConstants;
+import org.apache.dolphinscheduler.plugin.task.api.TaskException;
+import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext;
+import org.apache.dolphinscheduler.plugin.task.api.model.Property;
+import org.apache.dolphinscheduler.plugin.task.api.model.ResourceInfo;
+import org.apache.dolphinscheduler.plugin.task.api.model.TaskResponse;
+import org.apache.dolphinscheduler.plugin.task.api.parameters.AbstractParameters;
+import org.apache.dolphinscheduler.plugin.task.api.parser.ParamUtils;
+import org.apache.dolphinscheduler.plugin.task.api.parser.ParameterUtils;
+import org.apache.dolphinscheduler.plugin.task.api.utils.MapUtils;
+import org.apache.dolphinscheduler.plugin.task.java.exception.JavaSourceFileExistException;
+import org.apache.dolphinscheduler.plugin.task.java.exception.PublicClassNotFoundException;
+import org.apache.dolphinscheduler.plugin.task.java.exception.RunTypeNotFoundException;
+import org.apache.dolphinscheduler.spi.utils.JSONUtils;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.lang3.SystemUtils;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import com.google.common.base.Preconditions;
+
+/**
+ * java task
+ */
+public class JavaTask extends AbstractTaskExecutor {
+
+    /**
+     * java parameters
+     */
+    private JavaParameters javaParameters;
+
+    /**
+     * shell command executor
+     */
+    private ShellCommandExecutor shellCommandExecutor;
+
+    private TaskExecutionContext taskRequest;
+
+    /**
+     * constructor
+     *
+     * @param taskRequest taskRequest
+     */
+    public JavaTask(TaskExecutionContext taskRequest) {
+        super(taskRequest);
+        this.taskRequest = taskRequest;
+        this.shellCommandExecutor = new ShellCommandExecutor(this::logHandle,
+                taskRequest,
+                logger);
+    }
+
+    @Override
+    public void init() {
+        logger.info("java task params {}", taskRequest.getTaskParams());
+        javaParameters = JSONUtils.parseObject(taskRequest.getTaskParams(), JavaParameters.class);
+        if (javaParameters == null || !javaParameters.checkParameters()) {
+            throw new TaskException("java task params is not valid");
+        }
+        if (javaParameters.getRunType().equals(JavaConstants.RUN_TYPE_JAR)) {
+            setMainJarName();
+        }
+    }
+
+    @Override
+    public String getPreScript() {
+        String rawJavaScript = javaParameters.getRawScript().replaceAll("\\r\\n", "\n");
+        try {
+            rawJavaScript = convertJavaSourceCodePlaceholders(rawJavaScript);
+        } catch (StringIndexOutOfBoundsException e) {
+            logger.error("setShareVar field format error, raw java script : {}", rawJavaScript);
+        }
+        return rawJavaScript;
+    }
+
+    @Override
+    public void handle() throws Exception {
+        try {
+            // Step 1 judge if is java or jar run type.
+            // The  jar run type builds the command directly, adding resource to the java -jar class when building the command
+            // The java run type, first replace the custom parameters, then compile the code, and then build the command will add resource
+            // To run the coma
+            String command = null;
+            switch (javaParameters.getRunType()) {
+                case JavaConstants.RUN_TYPE_JAVA:
+                    command = buildJavaCommand();
+                    break;
+                case JavaConstants.RUN_TYPE_JAR:
+                    command = buildJarCommand();
+                    break;
+                default:
+                    throw new RunTypeNotFoundException("run type is required, but it is null now.");
+            }
+            Preconditions.checkNotNull(command, "command not be null.");
+            TaskResponse taskResponse = shellCommandExecutor.run(command);
+            logger.info("java task run result : " + taskResponse);
+            setExitStatusCode(taskResponse.getExitStatusCode());
+            setAppIds(taskResponse.getAppIds());
+            setProcessId(taskResponse.getProcessId());
+            setVarPool(shellCommandExecutor.getVarPool());
+        } catch (InterruptedException e) {
+            logger.error("java task interrupted ", e);
+            setExitStatusCode(TaskConstants.EXIT_CODE_FAILURE);
+            Thread.currentThread().interrupt();
+        } catch (Exception e) {
+            logger.error("java task failed ", e);
+            setExitStatusCode(TaskConstants.EXIT_CODE_FAILURE);
+            throw new TaskException("run java task error", e);
+        }
+    }
+
+    protected String buildJavaCommand() throws Exception {
+        String sourceCode = buildJavaSourceContent();
+        String className = compilerRawScript(sourceCode);
+        StringBuilder builder = new StringBuilder();
+        builder.append(getJavaHomeBinAbsolutePath())
+                .append("java").append(" ")
+                .append(buildResourcePath())
+                .append(" ")
+                .append(className).append(" ")
+                .append(javaParameters.getMainArgs().trim()).append(" ")
+                .append(javaParameters.getJvmArgs().trim());
+        return builder.toString();
+    }
+
+    private void setMainJarName() {
+        ResourceInfo mainJar = javaParameters.getMainJar();
+        String resourceName = getResourceNameOfMainJar(mainJar);
+        mainJar.setRes(resourceName);
+        javaParameters.setMainJar(mainJar);
+    }
+
+    private String getResourceNameOfMainJar(ResourceInfo mainJar) {
+        if (null == mainJar) {
+            throw new RuntimeException("The jar for the task is required.");
+        }
+
+        return mainJar.getId() == 0
+                ? mainJar.getRes()
+                // when update resource maybe has error
+                : mainJar.getResourceName().replaceFirst("/", "");
+    }
+
+    protected String buildJarCommand() {
+        String fullName = javaParameters.getMainJar().getResourceName();
+        String mainJarName = fullName.substring(0, fullName.lastIndexOf('.'));
+        mainJarName = mainJarName.substring(mainJarName.lastIndexOf('.') + 1) + ".jar";
+        StringBuilder builder = new StringBuilder();
+        builder.append(getJavaHomeBinAbsolutePath())
+                .append("java").append(" ")
+                .append(buildResourcePath()).append(" ")
+                .append("-jar").append(" ")
+                .append(taskRequest.getExecutePath())
+                .append(mainJarName).append(" ")
+                .append(javaParameters.getMainArgs().trim()).append(" ")
+                .append(javaParameters.getJvmArgs().trim());
+        return builder.toString();
+    }
+    
+    @Override
+    public void cancelApplication(boolean cancelApplication) throws Exception {
+        // cancel process
+        shellCommandExecutor.cancelApplication();
+    }
+
+    @Override
+    public AbstractParameters getParameters() {
+        return javaParameters;
+    }
+
+    /**
+     * convertJavaScriptPlaceholders
+     *
+     * @param rawScript rawScript
+     * @return String
+     * @throws StringIndexOutOfBoundsException StringIndexOutOfBoundsException
+     */
+    protected static String convertJavaSourceCodePlaceholders(String rawScript) throws StringIndexOutOfBoundsException {
+        int len = "${setShareVar(${".length();
+        int scriptStart = 0;
+        while ((scriptStart = rawScript.indexOf("${setShareVar(${", scriptStart)) != -1) {
+            int start = -1;
+            int end = rawScript.indexOf('}', scriptStart + len);
+            String prop = rawScript.substring(scriptStart + len, end);
+
+            start = rawScript.indexOf(',', end);
+            end = rawScript.indexOf(')', start);
+
+            String value = rawScript.substring(start + 1, end);
+
+            start = rawScript.indexOf('}', start) + 1;
+            end = rawScript.length();
+
+            String replaceScript = String.format("print(\"${{setValue({},{})}}\".format(\"%s\",%s))", prop, value);
+
+            rawScript = rawScript.substring(0, scriptStart) + replaceScript + rawScript.substring(start, end);
+
+            scriptStart += replaceScript.length();
+        }
+        return rawScript;
+    }
+
+    protected void createJavaSourceFileIfNotExists(String sourceCode, String fileName) throws IOException {
+        logger.info("tenantCode :{}, task dir:{}", taskRequest.getTenantCode(), taskRequest.getExecutePath());
+
+        if (!Files.exists(Paths.get(fileName))) {
+            logger.info("generate java source file:{}", fileName);
+
+            StringBuilder sb = new StringBuilder();
+            sb.append(sourceCode);
+            logger.info(sb.toString());
+
+            // write data to file
+            FileUtils.writeStringToFile(new File(fileName),
+                    sb.toString(),
+                    StandardCharsets.UTF_8);
+        } else {
+            throw new JavaSourceFileExistException("java source file exists, please report an issue on official.");
+        }
+    }
+
+    protected String buildJavaSourceCodeFileFullName(String publicClassName) {
+        return String.format(JavaConstants.JAVA_SOURCE_CODE_NAME_TEMPLATE, taskRequest.getExecutePath(), publicClassName);
+    }
+
+    protected String buildResourcePath() {
+        StringBuilder builder = new StringBuilder();
+        if (javaParameters.isModulePath()) {
+            builder.append("--module-path");
+        } else {
+            builder.append("--class-path");
+        }
+        builder.append(" ").append(JavaConstants.CLASSPATH_CURRENT_DIR)
+                .append(JavaConstants.PATH_SEPARATOR)
+                .append(taskRequest.getExecutePath());
+        for (ResourceInfo info : javaParameters.getResourceFilesList()) {
+            builder.append(JavaConstants.PATH_SEPARATOR);
+            builder.append(taskRequest.getExecutePath())
+                    .append(info.getResourceName());
+        }
+        return builder.toString();
+    }
+
+    protected String compilerRawScript(String sourceCode) throws IOException, InterruptedException {
+        String publicClassName = getPublicClassName(sourceCode);
+        String fileName =  buildJavaSourceCodeFileFullName(publicClassName);
+        createJavaSourceFileIfNotExists(sourceCode, fileName);
+        String compileCommand = buildJavaCompileCommand(fileName, sourceCode);
+        Preconditions.checkNotNull(compileCommand, "command not be null.");
+        TaskResponse compileResponse = shellCommandExecutor.run(compileCommand);
+        // must drop the command file ,if do not ,the next command will not run. because be limited the ShellCommandExecutor's create file rules
+        dropShellCommandFile();
+        shellCommandExecutor = new ShellCommandExecutor(this::logHandle,
+                taskRequest,
+                logger);
+        logger.info("java task code compile result : " + compileResponse);
+        return publicClassName;
+    }
+
+    private void dropShellCommandFile() throws IOException {
+        String commandFilePath = String.format("%s/%s.%s"
+                , taskRequest.getExecutePath()
+                , taskRequest.getTaskAppId()
+                , SystemUtils.IS_OS_WINDOWS ? "bat" : "command");
+        Path path = Paths.get(commandFilePath);
+        if (Files.exists(path)) {
+            Files.delete(path);
+        }
+    }
+
+    protected String buildJavaCompileCommand(String fileName, String sourceCode) throws IOException {
+
+        StringBuilder compilerCommand = new StringBuilder()
+                .append(getJavaHomeBinAbsolutePath())
+                .append("javac").append(" ")
+                .append(buildResourcePath()).append(" ")
+                .append(fileName);
+        return compilerCommand.toString();
+    }
+
+    protected String buildJavaSourceContent() {
+        String rawJavaScript = javaParameters.getRawScript().replaceAll("\\r\\n", "\n");
+        // replace placeholder
+
+        Map<String, Property> paramsMap = taskRequest.getPrepareParamsMap();
+        if (MapUtils.isEmpty(paramsMap)) {
+            paramsMap = new HashMap<>();
+        }
+        if (MapUtils.isNotEmpty(taskRequest.getParamsMap())) {
+            paramsMap.putAll(taskRequest.getParamsMap());
+        }
+        rawJavaScript = ParameterUtils.convertParameterPlaceholders(rawJavaScript, ParamUtils.convert(paramsMap));
+        logger.info("raw java script : {}", javaParameters.getRawScript());
+        return rawJavaScript;
+    }
+
+    private String getJavaHomeBinAbsolutePath() {
+        String javaHomeAbsolutePath = System.getenv(JavaConstants.JAVA_HOME);
+        Preconditions.checkNotNull(javaHomeAbsolutePath, "not find the java home in the version. ");
+        return javaHomeAbsolutePath + System.getProperty("file.separator") + "bin" + System.getProperty("file.separator");
+    }
+
+    public String getPublicClassName(String sourceCode) {
+        String pattern = "(.*\\s+public\\s+class\\s+)([a-zA-Z_]+[//w_]*)([.\\s\\S]*)";
+        Pattern compile = Pattern.compile(pattern);

Review Comment:
   good idea, have done.



-- 
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


[GitHub] [dolphinscheduler] sonarcloud[bot] commented on pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
sonarcloud[bot] commented on PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#issuecomment-1197886404

   SonarCloud Quality Gate failed.&nbsp; &nbsp; [![Quality Gate failed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/failed-16px.png 'Quality Gate failed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=10689)
   
   [![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png 'Bug')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG)  
   [![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png 'Vulnerability')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY)  
   [![Security Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png 'Security Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT)  
   [![Code Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png 'Code Smell')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL) [15 Code Smells](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL)
   
   [![0.4%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/0-16px.png '0.4%')](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_coverage&view=list) [0.4% Coverage](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_coverage&view=list)  
   [![1.9%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3-16px.png '1.9%')](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_duplicated_lines_density&view=list) [1.9% Duplication](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_duplicated_lines_density&view=list)
   
   


-- 
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


[GitHub] [dolphinscheduler] sonarcloud[bot] commented on pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
sonarcloud[bot] commented on PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#issuecomment-1196726886

   SonarCloud Quality Gate failed.&nbsp; &nbsp; [![Quality Gate failed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/failed-16px.png 'Quality Gate failed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=10689)
   
   [![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png 'Bug')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG)  
   [![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png 'Vulnerability')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY)  
   [![Security Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png 'Security Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT)  
   [![Code Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png 'Code Smell')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL) [14 Code Smells](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL)
   
   [![0.4%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/0-16px.png '0.4%')](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_coverage&view=list) [0.4% Coverage](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_coverage&view=list)  
   [![1.9%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3-16px.png '1.9%')](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_duplicated_lines_density&view=list) [1.9% Duplication](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_duplicated_lines_density&view=list)
   
   


-- 
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


[GitHub] [dolphinscheduler] EricGao888 commented on a diff in pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
EricGao888 commented on code in PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#discussion_r931756959


##########
dolphinscheduler-task-plugin/dolphinscheduler-task-java/src/main/java/org/apache/dolphinscheduler/plugin/task/java/exception/JavaSourceFileExistException.java:
##########
@@ -0,0 +1,39 @@
+/*
+ * 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.exception;
+
+public class JavaSourceFileExistException extends RuntimeException {

Review Comment:
   It would be better if we could have those exceptions covered in UTs.



-- 
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


[GitHub] [dolphinscheduler] sonarcloud[bot] commented on pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
sonarcloud[bot] commented on PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#issuecomment-1199791763

   SonarCloud Quality Gate failed.&nbsp; &nbsp; [![Quality Gate failed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/failed-16px.png 'Quality Gate failed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=10689)
   
   [![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png 'Bug')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG)  
   [![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png 'Vulnerability')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY)  
   [![Security Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png 'Security Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT)  
   [![Code Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png 'Code Smell')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL) [15 Code Smells](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL)
   
   [![0.4%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/0-16px.png '0.4%')](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_coverage&view=list) [0.4% Coverage](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_coverage&view=list)  
   [![1.9%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3-16px.png '1.9%')](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_duplicated_lines_density&view=list) [1.9% Duplication](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_duplicated_lines_density&view=list)
   
   


-- 
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


[GitHub] [dolphinscheduler] sonarcloud[bot] commented on pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
sonarcloud[bot] commented on PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#issuecomment-1203004292

   SonarCloud Quality Gate failed.&nbsp; &nbsp; [![Quality Gate failed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/failed-16px.png 'Quality Gate failed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=10689)
   
   [![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png 'Bug')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG)  
   [![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png 'Vulnerability')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY)  
   [![Security Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png 'Security Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT)  
   [![Code Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png 'Code Smell')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL) [13 Code Smells](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL)
   
   [![0.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/0-16px.png '0.0%')](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_coverage&view=list) [0.0% Coverage](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_coverage&view=list)  
   [![1.8%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3-16px.png '1.8%')](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_duplicated_lines_density&view=list) [1.8% Duplication](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_duplicated_lines_density&view=list)
   
   


-- 
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


[GitHub] [dolphinscheduler] Amy0104 commented on a diff in pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
Amy0104 commented on code in PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#discussion_r945387424


##########
dolphinscheduler-ui/src/views/projects/task/constants/task-type.ts:
##########
@@ -47,6 +48,9 @@ export type TaskType =
 export type TaskExecuteType = 'STREAM' | 'BATCH'
 
 export const TASK_TYPES_MAP = {
+  JAVA: {
+    alias: 'JAVA'
+  },

Review Comment:
   Does it have a document, if not, you need to set helperLinkDisable to true.



##########
dolphinscheduler-ui/src/views/projects/task/components/node/fields/use-java.ts:
##########
@@ -0,0 +1,86 @@
+/*
+ * 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.
+ */
+import { computed } from 'vue'
+import { useI18n } from 'vue-i18n'
+import { useCustomParams, useResources ,useJavaTaskMainJar} from '.'
+import type { IJsonItem } from '../types'
+
+export function useJava(model: { [field: string]: any }): IJsonItem[] {
+  const { t } = useI18n()
+  const rawScriptSpan = computed(() => (model.runType === 'JAR' ? 0 : 24))
+  return [
+    {
+        type: 'select',
+        field: 'runType',
+        span: 12,
+        name: t('project.node.run_type'),
+        options: RUN_TYPES,
+        value: model.runType
+      },
+      {
+          type: 'switch',
+          field: 'isModulePath',
+          span: 24,
+          name: t('project.node.is_module_path'),
+          value: model.isModulePath
+      },
+      {
+        type: 'input',
+        field: 'mainArgs',
+        name: t('project.node.main_arguments'),
+        props: {
+          type: 'textarea',
+          placeholder: t('project.node.main_arguments_tips')
+        }
+      },
+      {
+        type: 'input',
+        field: 'jvmArgs',
+        name: t('project.node.jvm_args'),
+        props: {
+          type: 'textarea',
+          placeholder: t('project.node.jvm_args_tips')
+        }
+      },
+      useJavaTaskMainJar(model),
+    {
+      type: 'editor',
+      field: 'rawScript',
+      span: rawScriptSpan,
+      name: t('project.node.script'),
+      validate: {
+        trigger: ['input', 'trigger'],
+        required: true,
+        message: t('project.node.script_tips')

Review Comment:
   Does it have a language? The default language of the editor is shell.



##########
dolphinscheduler-ui/src/views/projects/task/components/node/fields/use-java-task-main-jar.ts:
##########
@@ -0,0 +1,80 @@
+/*
+ * 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.
+ */
+import { computed, ref, onMounted, watch } from 'vue'
+import { useI18n } from 'vue-i18n'
+import { queryResourceByProgramType } from '@/service/modules/resources'
+import { useTaskNodeStore } from '@/store/project/task-node'
+import utils from '@/utils'
+import type { IJsonItem, ProgramType, IMainJar } from '../types'
+
+export function useJavaTaskMainJar(model: { [field: string]: any }): IJsonItem {
+  const { t } = useI18n()
+  const mainJarOptions = ref([] as IMainJar[])
+  const taskStore = useTaskNodeStore()
+
+  const mainJarSpan = computed(() => (model.runType === 'JAVA' ? 0 : 24))
+  const getMainJars = async (programType: ProgramType) => {
+    const storeMainJar = taskStore.getMainJar(programType)
+    if (storeMainJar) {
+      mainJarOptions.value = storeMainJar
+      return
+    }
+    const res = await queryResourceByProgramType({
+      type: 'FILE',
+      programType
+    })
+    utils.removeUselessChildren(res)
+    mainJarOptions.value = res || []
+    taskStore.updateMainJar(programType, res)
+  }
+
+  onMounted(() => {
+    getMainJars(model.programType)
+  })
+
+  watch(
+    () => model.programType,
+    (value) => {
+        getMainJars(value)
+    }
+  )
+
+  return {
+    type: 'tree-select',
+    field: 'mainJar',
+    name: t('project.node.main_package'),
+    span: mainJarSpan,
+    props: {
+      cascade: true,
+      showPath: true,
+      checkStrategy: 'child',
+      placeholder: t('project.node.main_package_tips'),
+      keyField: 'id',
+      labelField: 'fullName'
+    },
+    validate: {
+      trigger: ['input', 'blur'],
+      required: true,
+      validator(validate: any, value: string) {
+        if (!value) {
+          return new Error(t('project.node.main_package_tips'))
+        }
+      }
+    },
+    options: mainJarOptions
+  }
+}

Review Comment:
   It already has a useMainJar hook, so it don't need to create a new one.



-- 
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


[GitHub] [dolphinscheduler] ruanwenjun commented on a diff in pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
ruanwenjun commented on code in PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#discussion_r965522248


##########
dolphinscheduler-task-plugin/dolphinscheduler-task-java/src/main/java/org/apache/dolphinscheduler/plugin/task/java/JavaParameters.java:
##########
@@ -68,7 +69,7 @@ public class JavaParameters extends AbstractParameters {
      */
     @Override
     public boolean checkParameters() {
-        return runType != null && (rawScript != null && !rawScript.isEmpty()) || mainJar != null;
+        return runType != null && StringUtils.isNotBlank(rawScript) || mainJar != null;

Review Comment:
   ```suggestion
           return runType != null && (StringUtils.isNotBlank(rawScript) || mainJar != null);
   ```
   
   When the runType is jar you need to check if the `mainJar != null`, when the runType is script you need to check if the `rawScript != null`



-- 
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


[GitHub] [dolphinscheduler] codecov-commenter commented on pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
codecov-commenter commented on PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#issuecomment-1170789446

   # [Codecov](https://codecov.io/gh/apache/dolphinscheduler/pull/10689?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#10689](https://codecov.io/gh/apache/dolphinscheduler/pull/10689?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (bcf35bd) into [dev](https://codecov.io/gh/apache/dolphinscheduler/commit/a90e5746fc3d6103c00ad39715f58ed54eb1700f?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (a90e574) will **not change** coverage.
   > The diff coverage is `0.00%`.
   
   > :exclamation: Current head bcf35bd differs from pull request most recent head da80057. Consider uploading reports for the commit da80057 to get more accurate results
   
   ```diff
   @@            Coverage Diff            @@
   ##                dev   #10689   +/-   ##
   =========================================
     Coverage     40.89%   40.89%           
     Complexity     4830     4830           
   =========================================
     Files           897      897           
     Lines         36157    36157           
     Branches       4006     4003    -3     
   =========================================
     Hits          14788    14788           
     Misses        19898    19898           
     Partials       1471     1471           
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/dolphinscheduler/pull/10689?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [...nscheduler/plugin/task/api/model/TaskResponse.java](https://codecov.io/gh/apache/dolphinscheduler/pull/10689/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZG9scGhpbnNjaGVkdWxlci10YXNrLXBsdWdpbi9kb2xwaGluc2NoZWR1bGVyLXRhc2stYXBpL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9kb2xwaGluc2NoZWR1bGVyL3BsdWdpbi90YXNrL2FwaS9tb2RlbC9UYXNrUmVzcG9uc2UuamF2YQ==) | `21.42% <0.00%> (-0.80%)` | :arrow_down: |
   | [.../dolphinscheduler/plugin/task/datax/DataxTask.java](https://codecov.io/gh/apache/dolphinscheduler/pull/10689/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZG9scGhpbnNjaGVkdWxlci10YXNrLXBsdWdpbi9kb2xwaGluc2NoZWR1bGVyLXRhc2stZGF0YXgvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2RvbHBoaW5zY2hlZHVsZXIvcGx1Z2luL3Rhc2svZGF0YXgvRGF0YXhUYXNrLmphdmE=) | `0.00% <0.00%> (ø)` | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/dolphinscheduler/pull/10689?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/dolphinscheduler/pull/10689?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [a90e574...da80057](https://codecov.io/gh/apache/dolphinscheduler/pull/10689?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   


-- 
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


[GitHub] [dolphinscheduler] sonarcloud[bot] commented on pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
sonarcloud[bot] commented on PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#issuecomment-1171015726

   SonarCloud Quality Gate failed.&nbsp; &nbsp; [![Quality Gate failed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/failed-16px.png 'Quality Gate failed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=10689)
   
   [![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png 'Bug')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG)  
   [![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png 'Vulnerability')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY)  
   [![Security Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png 'Security Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT) [![E](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/E-16px.png 'E')](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT) [1 Security Hotspot](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT)  
   [![Code Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png 'Code Smell')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL) [24 Code Smells](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL)
   
   [![0.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/0-16px.png '0.0%')](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_coverage&view=list) [0.0% Coverage](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_coverage&view=list)  
   [![2.1%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3-16px.png '2.1%')](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_duplicated_lines_density&view=list) [2.1% Duplication](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_duplicated_lines_density&view=list)
   
   


-- 
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


[GitHub] [dolphinscheduler] zhuangchong commented on pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
zhuangchong commented on PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#issuecomment-1185076963

   @Amy0104 Please help code review.


-- 
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


[GitHub] [dolphinscheduler] sonarcloud[bot] commented on pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
sonarcloud[bot] commented on PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#issuecomment-1193264982

   SonarCloud Quality Gate failed.&nbsp; &nbsp; [![Quality Gate failed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/failed-16px.png 'Quality Gate failed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=10689)
   
   [![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png 'Bug')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG)  
   [![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png 'Vulnerability')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY)  
   [![Security Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png 'Security Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT)  
   [![Code Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png 'Code Smell')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL) [14 Code Smells](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL)
   
   [![0.4%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/0-16px.png '0.4%')](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_coverage&view=list) [0.4% Coverage](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_coverage&view=list)  
   [![1.9%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3-16px.png '1.9%')](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_duplicated_lines_density&view=list) [1.9% Duplication](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_duplicated_lines_density&view=list)
   
   


-- 
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


[GitHub] [dolphinscheduler] sonarcloud[bot] commented on pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
sonarcloud[bot] commented on PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#issuecomment-1193264759

   SonarCloud Quality Gate failed.&nbsp; &nbsp; [![Quality Gate failed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/failed-16px.png 'Quality Gate failed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=10689)
   
   [![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png 'Bug')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG)  
   [![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png 'Vulnerability')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY)  
   [![Security Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png 'Security Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT)  
   [![Code Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png 'Code Smell')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL) [14 Code Smells](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL)
   
   [![0.4%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/0-16px.png '0.4%')](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_coverage&view=list) [0.4% Coverage](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_coverage&view=list)  
   [![1.9%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3-16px.png '1.9%')](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_duplicated_lines_density&view=list) [1.9% Duplication](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_duplicated_lines_density&view=list)
   
   


-- 
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


[GitHub] [dolphinscheduler] 106umao commented on a diff in pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
106umao commented on code in PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#discussion_r928151115


##########
dolphinscheduler-task-plugin/dolphinscheduler-task-java/src/main/java/org/apache/dolphinscheduler/plugin/task/java/JavaParameters.java:
##########
@@ -0,0 +1,64 @@
+/*
+ * 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 org.apache.dolphinscheduler.plugin.task.api.model.ResourceInfo;
+import org.apache.dolphinscheduler.plugin.task.api.parameters.AbstractParameters;
+
+import java.util.List;
+
+import lombok.Data;
+
+@Data

Review Comment:
   thx, have done.



-- 
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


[GitHub] [dolphinscheduler] sonarcloud[bot] commented on pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
sonarcloud[bot] commented on PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#issuecomment-1171459644

   SonarCloud Quality Gate failed.&nbsp; &nbsp; [![Quality Gate failed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/failed-16px.png 'Quality Gate failed')](https://sonarcloud.io/dashboard?id=apache-dolphinscheduler&pullRequest=10689)
   
   [![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png 'Bug')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=BUG)  
   [![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png 'Vulnerability')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=VULNERABILITY)  
   [![Security Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png 'Security Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT) [![E](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/E-16px.png 'E')](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT) [1 Security Hotspot](https://sonarcloud.io/project/security_hotspots?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=SECURITY_HOTSPOT)  
   [![Code Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png 'Code Smell')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL) [24 Code Smells](https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&pullRequest=10689&resolved=false&types=CODE_SMELL)
   
   [![0.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/0-16px.png '0.0%')](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_coverage&view=list) [0.0% Coverage](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_coverage&view=list)  
   [![2.1%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3-16px.png '2.1%')](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_duplicated_lines_density&view=list) [2.1% Duplication](https://sonarcloud.io/component_measures?id=apache-dolphinscheduler&pullRequest=10689&metric=new_duplicated_lines_density&view=list)
   
   


-- 
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


[GitHub] [dolphinscheduler] zhongjiajie commented on a diff in pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
zhongjiajie commented on code in PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#discussion_r940821164


##########
dolphinscheduler-task-plugin/dolphinscheduler-task-java/src/main/java/org/apache/dolphinscheduler/plugin/task/java/JavaParameters.java:
##########
@@ -0,0 +1,89 @@
+/*
+ * 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 org.apache.dolphinscheduler.plugin.task.api.model.ResourceInfo;
+import org.apache.dolphinscheduler.plugin.task.api.parameters.AbstractParameters;
+
+import java.util.List;
+
+import lombok.Getter;
+import lombok.Setter;
+import lombok.ToString;
+
+@Getter
+@Setter
+@ToString
+public class JavaParameters extends AbstractParameters {
+    /**
+     * origin java script
+     */
+    private String rawScript;
+
+    /**
+     * run in jar file
+     */
+    private ResourceInfo mainJar;
+
+    /**
+     * Marks the current task running mode
+     */
+    private String runType;
+
+    /**
+     * main method args
+     **/
+    private String mainArgs;
+
+    /**
+     * java virtual machine args
+     **/
+    private String jvmArgs;
+
+    /**
+     * module path or class path flag
+     **/
+    private boolean isModulePath;
+
+    /**
+     * resource list
+     */
+    private List<ResourceInfo> resourceList;
+
+    /**
+     * @description: Check that the parameters are valid
+     * @date: 7/22/22 2:35 AM

Review Comment:
   I think we should remove the `date` comment for all new adding or change files



##########
dolphinscheduler-task-plugin/dolphinscheduler-task-java/src/main/java/org/apache/dolphinscheduler/plugin/task/java/JavaTask.java:
##########
@@ -0,0 +1,438 @@
+/*
+ * 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 static org.apache.dolphinscheduler.plugin.task.java.JavaConstants.JAVA_HOME_VAR;
+import static org.apache.dolphinscheduler.plugin.task.java.JavaConstants.PUBLIC_CLASS_NAME_REGEX;
+
+import org.apache.dolphinscheduler.plugin.task.api.AbstractTaskExecutor;
+import org.apache.dolphinscheduler.plugin.task.api.ShellCommandExecutor;
+import org.apache.dolphinscheduler.plugin.task.api.TaskConstants;
+import org.apache.dolphinscheduler.plugin.task.api.TaskException;
+import org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext;
+import org.apache.dolphinscheduler.plugin.task.api.model.Property;
+import org.apache.dolphinscheduler.plugin.task.api.model.ResourceInfo;
+import org.apache.dolphinscheduler.plugin.task.api.model.TaskResponse;
+import org.apache.dolphinscheduler.plugin.task.api.parameters.AbstractParameters;
+import org.apache.dolphinscheduler.plugin.task.api.parser.ParamUtils;
+import org.apache.dolphinscheduler.plugin.task.api.parser.ParameterUtils;
+import org.apache.dolphinscheduler.plugin.task.api.utils.MapUtils;
+import org.apache.dolphinscheduler.plugin.task.java.exception.JavaSourceFileExistException;
+import org.apache.dolphinscheduler.plugin.task.java.exception.PublicClassNotFoundException;
+import org.apache.dolphinscheduler.plugin.task.java.exception.RunTypeNotFoundException;
+import org.apache.dolphinscheduler.spi.utils.JSONUtils;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.lang3.SystemUtils;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import com.google.common.base.Preconditions;
+
+/**
+ * java task
+ */
+public class JavaTask extends AbstractTaskExecutor {
+
+    /**
+     * Contains various parameters for this task
+     */
+    private JavaParameters javaParameters;
+
+    /**
+     * To run shell commands
+     */
+    private ShellCommandExecutor shellCommandExecutor;
+
+    /**
+     * task execution context
+     */
+    private TaskExecutionContext taskRequest;
+
+    /**
+     * class name regex pattern
+     */
+    private static final Pattern classNamePattern = Pattern.compile(PUBLIC_CLASS_NAME_REGEX);
+
+    /**
+     * @description: Construct a Java task
+     * @date: 7/22/22 2:36 AM
+     * @param: [org.apache.dolphinscheduler.plugin.task.api.TaskExecutionContext]
+     * @return: JavaTask
+     **/
+    public JavaTask(TaskExecutionContext taskRequest) {
+        super(taskRequest);
+        this.taskRequest = taskRequest;
+        this.shellCommandExecutor = new ShellCommandExecutor(this::logHandle,
+                taskRequest,
+                logger);
+    }
+
+    /**
+     * @description: Initializes a Java task
+     * @date: 7/22/22 2:36 AM
+     * @param: []
+     * @return: void
+     **/
+    @Override
+    public void init() {
+        logger.info("java task params {}", taskRequest.getTaskParams());
+        javaParameters = JSONUtils.parseObject(taskRequest.getTaskParams(), JavaParameters.class);
+        if (javaParameters == null || !javaParameters.checkParameters()) {
+            throw new TaskException("java task params is not valid");
+        }
+        if (javaParameters.getRunType().equals(JavaConstants.RUN_TYPE_JAR)) {
+            setMainJarName();
+        }
+    }
+
+    /**
+     * @description: Gets the Java source file that was initially processed
+     * @date: 7/22/22 2:36 AM
+     * @param: []
+     * @return: java.lang.String
+     **/
+    @Override
+    public String getPreScript() {
+        String rawJavaScript = javaParameters.getRawScript().replaceAll("\\r\\n", "\n");
+        try {
+            rawJavaScript = convertJavaSourceCodePlaceholders(rawJavaScript);
+        } catch (StringIndexOutOfBoundsException e) {
+            logger.error("setShareVar field format error, raw java script : {}", rawJavaScript);
+        }
+        return rawJavaScript;
+    }
+
+    /**
+     * @description: Execute Java tasks
+     * @date: 7/22/22 2:36 AM
+     * @param: []
+     * @return: void
+     **/
+    @Override
+    public void handle() throws Exception {
+        try {
+            // Step 1: judge if is java or jar run type.
+            // Step 2 case1: The jar run type builds the command directly, adding resource to the java -jar class when building the command
+            // Step 2 case2: The java run type, first replace the custom parameters, then compile the code, and then build the command will add resource
+            // Step 3: To run the command
+            String command = null;
+            switch (javaParameters.getRunType()) {
+                case JavaConstants.RUN_TYPE_JAVA:
+                    command = buildJavaCommand();
+                    break;
+                case JavaConstants.RUN_TYPE_JAR:
+                    command = buildJarCommand();
+                    break;
+                default:
+                    throw new RunTypeNotFoundException("run type is required, but it is null now.");
+            }
+            Preconditions.checkNotNull(command, "command not be null.");
+            TaskResponse taskResponse = shellCommandExecutor.run(command);
+            logger.info("java task run result : {}", taskResponse);
+            setExitStatusCode(taskResponse.getExitStatusCode());
+            setAppIds(taskResponse.getAppIds());
+            setProcessId(taskResponse.getProcessId());
+            setVarPool(shellCommandExecutor.getVarPool());
+        } catch (InterruptedException e) {
+            logger.error("java task interrupted ", e);
+            setExitStatusCode(TaskConstants.EXIT_CODE_FAILURE);
+            Thread.currentThread().interrupt();
+        } catch (RunTypeNotFoundException e) {
+            logger.error(e.getMessage());
+            setExitStatusCode(TaskConstants.EXIT_CODE_FAILURE);
+            throw e;
+        } catch (Exception e) {
+            logger.error("java task failed ", e);
+            setExitStatusCode(TaskConstants.EXIT_CODE_FAILURE);
+            throw new TaskException("run java task error", e);
+        }
+    }
+
+    /**
+     * @description: Construct a shell command for the java Run mode
+     * @date: 7/22/22 2:36 AM
+     * @param: []
+     * @return: java.lang.String
+     **/
+    protected String buildJavaCommand() throws Exception {
+        String sourceCode = buildJavaSourceContent();
+        String className = compilerRawScript(sourceCode);
+        StringBuilder builder = new StringBuilder();
+        builder.append(getJavaCommandPath())
+                .append("java").append(" ")
+                .append(buildResourcePath())
+                .append(" ")
+                .append(className).append(" ")
+                .append(javaParameters.getMainArgs().trim()).append(" ")
+                .append(javaParameters.getJvmArgs().trim());
+        return builder.toString();
+    }
+
+    private void setMainJarName() {
+        ResourceInfo mainJar = javaParameters.getMainJar();
+        String resourceName = getResourceNameOfMainJar(mainJar);
+        mainJar.setRes(resourceName);
+        javaParameters.setMainJar(mainJar);
+    }
+
+    /**
+     * @description: Construct a shell command for the java -jar Run mode
+     * @date: 7/22/22 2:36 AM
+     * @param: []
+     * @return: java.lang.String
+     **/
+    protected String buildJarCommand() {
+        String fullName = javaParameters.getMainJar().getResourceName();
+        String mainJarName = fullName.substring(0, fullName.lastIndexOf('.'));
+        mainJarName = mainJarName.substring(mainJarName.lastIndexOf('.') + 1) + ".jar";
+        StringBuilder builder = new StringBuilder();
+        builder.append(getJavaCommandPath())
+                .append("java").append(" ")
+                .append(buildResourcePath()).append(" ")
+                .append("-jar").append(" ")
+                .append(taskRequest.getExecutePath())
+                .append(mainJarName).append(" ")
+                .append(javaParameters.getMainArgs().trim()).append(" ")
+                .append(javaParameters.getJvmArgs().trim());
+        return builder.toString();
+    }
+
+    private String getResourceNameOfMainJar(ResourceInfo mainJar) {
+        if (null == mainJar) {
+            throw new RuntimeException("The jar for the task is required.");
+        }
+
+        return mainJar.getId() == 0
+                ? mainJar.getRes()
+                // when update resource maybe has error
+                : mainJar.getResourceName().replaceFirst("/", "");

Review Comment:
   we have slash in class constant, so as
   * `PERIOD` for `"."`
   * `SPACE` for `" "`
   ```suggestion
                   : mainJar.getResourceName().replaceFirst(Constants.SINGLE_SLASH, "");
   ```



-- 
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


[GitHub] [dolphinscheduler] 106umao commented on a diff in pull request #10689: [Feature-10683][Task Plugin] Add Java Task Plugin.

Posted by GitBox <gi...@apache.org>.
106umao commented on code in PR #10689:
URL: https://github.com/apache/dolphinscheduler/pull/10689#discussion_r915777999


##########
dolphinscheduler-task-plugin/dolphinscheduler-task-java/src/main/java/org/apache/dolphinscheduler/plugin/task/java/JavaParameters.java:
##########
@@ -0,0 +1,114 @@
+/*
+ * 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 org.apache.dolphinscheduler.plugin.task.api.model.ResourceInfo;
+import org.apache.dolphinscheduler.plugin.task.api.parameters.AbstractParameters;
+
+import java.util.List;
+
+public class JavaParameters extends AbstractParameters {
+    /**
+     * origin java script
+     */
+    private String rawScript;
+
+    private ResourceInfo mainJar;
+
+    private String runType;
+
+    private String mainArgs;
+
+    private String jvmArgs;
+    private boolean isModulePath;
+
+
+    public boolean isModulePath() {
+        return isModulePath;
+    }
+
+    public void setModulePath(boolean modulePath) {
+        isModulePath = modulePath;
+    }
+
+
+
+    /**
+     * resource list
+     */
+    private List<ResourceInfo> resourceList;
+
+    public String getRawScript() {

Review Comment:
   thx, it is done



-- 
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