From 82b5e91716e3a59b6a46fb4658504d744c9f352a Mon Sep 17 00:00:00 2001 From: ailiujiarui <2477354249@qq.com> Date: Wed, 25 Sep 2024 13:30:27 +0800 Subject: [PATCH] Standardize Code Formatting --- .../plugin/task/java/JavaParameters.java | 3 ++- .../plugin/task/java/JavaTask.java | 21 ++++++++----------- .../plugin/task/java/MainClassExtractor.java | 1 + .../plugin/task/java/JavaTaskTest.java | 11 +++++----- .../node/fields/use-java-task-normal-jar.ts | 5 +++-- .../task/components/node/fields/use-java.ts | 3 +-- .../task/components/node/format-data.ts | 5 ++++- 7 files changed, 25 insertions(+), 24 deletions(-) diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-java/src/main/java/org/apache/dolphinscheduler/plugin/task/java/JavaParameters.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-java/src/main/java/org/apache/dolphinscheduler/plugin/task/java/JavaParameters.java index c31cc55e29ac..fa7f6f97f130 100644 --- a/dolphinscheduler-task-plugin/dolphinscheduler-task-java/src/main/java/org/apache/dolphinscheduler/plugin/task/java/JavaParameters.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-java/src/main/java/org/apache/dolphinscheduler/plugin/task/java/JavaParameters.java @@ -17,10 +17,11 @@ package org.apache.dolphinscheduler.plugin.task.java; -import org.apache.commons.lang3.StringUtils; import org.apache.dolphinscheduler.plugin.task.api.model.ResourceInfo; import org.apache.dolphinscheduler.plugin.task.api.parameters.AbstractParameters; +import org.apache.commons.lang3.StringUtils; + import java.util.List; import lombok.Data; diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-java/src/main/java/org/apache/dolphinscheduler/plugin/task/java/JavaTask.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-java/src/main/java/org/apache/dolphinscheduler/plugin/task/java/JavaTask.java index 2f90b692afb0..bc0fe71fc006 100644 --- a/dolphinscheduler-task-plugin/dolphinscheduler-task-java/src/main/java/org/apache/dolphinscheduler/plugin/task/java/JavaTask.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-java/src/main/java/org/apache/dolphinscheduler/plugin/task/java/JavaTask.java @@ -35,9 +35,10 @@ import org.apache.dolphinscheduler.plugin.task.java.exception.RunTypeNotFoundException; import java.io.File; + import lombok.extern.slf4j.Slf4j; -import com.google.common.base.Preconditions; +import com.google.common.base.Preconditions; @Slf4j public class JavaTask extends AbstractTask { @@ -57,7 +58,6 @@ public class JavaTask extends AbstractTask { */ private TaskExecutionContext taskRequest; - public JavaTask(TaskExecutionContext taskRequest) { super(taskRequest); this.taskRequest = taskRequest; @@ -88,9 +88,11 @@ public void init() { public void handle(TaskCallBack taskCallBack) throws TaskException { try { // Step 1: judge if is java or jar run type. - // Step 2 case1: the fat jar run type builds the command directly, adding resource to the java -jar class when + // Step 2 case1: the fat jar run type builds the command directly, adding resource to the java -jar class + // when // building the command - // Step 2 case2: the normal jar run type builds the command directly, adding resource to the java -cp class when + // Step 2 case2: the normal jar run type builds the command directly, adding resource to the java -cp class + // when // building the command // Step 3: to run the command String command = null; @@ -129,7 +131,6 @@ public void handle(TaskCallBack taskCallBack) throws TaskException { } } - /** * Construct a shell command for the java -jar Run mode * @@ -151,7 +152,6 @@ protected String buildJarCommand() { return builder.toString(); } - /** * Construct a shell command for the java -cp run mode * @@ -163,11 +163,10 @@ protected String buildNormalJarCommand() { javaParameters.getMainJar() .getResourceName()) .getResourceAbsolutePathInLocal(); - String mainJarName=null; - try{ + String mainJarName = null; + try { mainJarName = MainClassExtractor.getMainClassName(mainJarAbsolutePathInLocal); - } - catch (Exception e){ + } catch (Exception e) { e.printStackTrace(); } StringBuilder builder = new StringBuilder(); @@ -220,7 +219,6 @@ protected String buildResourcePath() { return builder.toString(); } - /** * Gets the operating system absolute path to the Java command * @@ -230,5 +228,4 @@ private String getJavaCommandPath() { return JAVA_HOME_VAR + File.separator + "bin" + File.separator; } - } diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-java/src/main/java/org/apache/dolphinscheduler/plugin/task/java/MainClassExtractor.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-java/src/main/java/org/apache/dolphinscheduler/plugin/task/java/MainClassExtractor.java index adb324e7115c..62932bd7be93 100644 --- a/dolphinscheduler-task-plugin/dolphinscheduler-task-java/src/main/java/org/apache/dolphinscheduler/plugin/task/java/MainClassExtractor.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-java/src/main/java/org/apache/dolphinscheduler/plugin/task/java/MainClassExtractor.java @@ -14,6 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.apache.dolphinscheduler.plugin.task.java; import java.io.File; diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-java/src/test/java/org/apache/dolphinscheduler/plugin/task/java/JavaTaskTest.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-java/src/test/java/org/apache/dolphinscheduler/plugin/task/java/JavaTaskTest.java index 67f1d9fba53a..5d91bf61a632 100644 --- a/dolphinscheduler-task-plugin/dolphinscheduler-task-java/src/test/java/org/apache/dolphinscheduler/plugin/task/java/JavaTaskTest.java +++ b/dolphinscheduler-task-plugin/dolphinscheduler-task-java/src/test/java/org/apache/dolphinscheduler/plugin/task/java/JavaTaskTest.java @@ -56,11 +56,11 @@ public void buildJarCommand() { @Test public void buildNormalJarCommand() { JavaTask javaTask = runNormalJarType(); - try{ - assertThat(javaTask.buildNormalJarCommand()) - .isEqualTo("${JAVA_HOME}/bin/java -classpath .:/tmp/dolphinscheduler/test/executepath:/tmp/dolphinscheduler/test/executepath/opt/share/jar/resource2.jar:/tmp/dolphinscheduler/test/executepath/opt/share/jar/main.jar HelloWorldWithGuava -host 127.0.0.1 -port 8080 -xms:50m"); - } - catch(Exception e){ + try { + assertThat(javaTask.buildNormalJarCommand()) + .isEqualTo( + "${JAVA_HOME}/bin/java -classpath .:/tmp/dolphinscheduler/test/executepath:/tmp/dolphinscheduler/test/executepath/opt/share/jar/resource2.jar:/tmp/dolphinscheduler/test/executepath/opt/share/jar/main.jar HelloWorldWithGuava -host 127.0.0.1 -port 8080 -xms:50m"); + } catch (Exception e) { e.printStackTrace(); } @@ -99,7 +99,6 @@ public JavaParameters createNormalJarJavaParameters(String runType) { return javaParameters; } - /** * Add the fat jar parameters * diff --git a/dolphinscheduler-ui/src/views/projects/task/components/node/fields/use-java-task-normal-jar.ts b/dolphinscheduler-ui/src/views/projects/task/components/node/fields/use-java-task-normal-jar.ts index e9efcbd3576d..c642a9905e62 100644 --- a/dolphinscheduler-ui/src/views/projects/task/components/node/fields/use-java-task-normal-jar.ts +++ b/dolphinscheduler-ui/src/views/projects/task/components/node/fields/use-java-task-normal-jar.ts @@ -21,7 +21,9 @@ import { useTaskNodeStore } from '@/store/project/task-node' import utils from '@/utils' import type { IJsonItem, ProgramType, IMainJar } from '../types' -export function useJavaTaskNormalJar(model: { [field: string]: any }): IJsonItem { +export function useJavaTaskNormalJar(model: { + [field: string]: any +}): IJsonItem { const { t } = useI18n() const mainJarOptions = ref([] as IMainJar[]) const taskStore = useTaskNodeStore() @@ -42,7 +44,6 @@ export function useJavaTaskNormalJar(model: { [field: string]: any }): IJsonItem taskStore.updateMainJar(programType, res) } - onMounted(() => { getMainJars(model.programType) }) diff --git a/dolphinscheduler-ui/src/views/projects/task/components/node/fields/use-java.ts b/dolphinscheduler-ui/src/views/projects/task/components/node/fields/use-java.ts index 2017f663cfb0..e227a8ad3580 100644 --- a/dolphinscheduler-ui/src/views/projects/task/components/node/fields/use-java.ts +++ b/dolphinscheduler-ui/src/views/projects/task/components/node/fields/use-java.ts @@ -17,7 +17,7 @@ import { useI18n } from 'vue-i18n' import { useCustomParams, useResources, useJavaTaskMainJar } from '.' import type { IJsonItem } from '../types' -import {useJavaTaskNormalJar} from "@/views/projects/task/components/node/fields/use-java-task-normal-jar"; +import { useJavaTaskNormalJar } from '@/views/projects/task/components/node/fields/use-java-task-normal-jar' export function useJava(model: { [field: string]: any }): IJsonItem[] { const { t } = useI18n() @@ -71,5 +71,4 @@ export const RUN_TYPES = [ label: 'NORMAL_JAR', value: 'NORMAL_JAR' } - ] diff --git a/dolphinscheduler-ui/src/views/projects/task/components/node/format-data.ts b/dolphinscheduler-ui/src/views/projects/task/components/node/format-data.ts index 5c67858dd8a4..f7c228f9546b 100644 --- a/dolphinscheduler-ui/src/views/projects/task/components/node/format-data.ts +++ b/dolphinscheduler-ui/src/views/projects/task/components/node/format-data.ts @@ -43,7 +43,10 @@ export function formatParams(data: INodeData): { taskParams.mainArgs = data.mainArgs taskParams.jvmArgs = data.jvmArgs taskParams.isModulePath = data.isModulePath - if ((data.runType === 'FAT_JAR'||data.runType=== 'NORMAL_JAR') && data.mainJar) { + if ( + (data.runType === 'FAT_JAR' || data.runType === 'NORMAL_JAR') && + data.mainJar + ) { taskParams.mainJar = { resourceName: data.mainJar } } }