Skip to content

Commit cad8df0

Browse files
authored
[DSIP-27][Task Plugin] Some improvements of JAVA task plugin (#16542)
1 parent 80c5f59 commit cad8df0

File tree

23 files changed

+778
-398
lines changed

23 files changed

+778
-398
lines changed

docs/docs/en/guide/task/java.md

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Overview
22

3-
This node is for executing java-type tasks and supports using files and jar packages as program entries.
3+
This node is used to execute tasks of the `Java` type and supports running `jar` packages of the `FAT_JAR` and `NORMAL_JAR` types.
44

55
# Create Tasks
66

@@ -20,24 +20,38 @@ This node is for executing java-type tasks and supports using files and jar pack
2020
| 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. |
2121
| Main Parameter | Java program main method entry parameter. |
2222
| Java VM Parameters | JVM startup parameters. |
23-
| 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. |
23+
| Main Class Name | Fully Qualified Name of the Main Class (Optional) |
24+
| Main Package | Select the main program package to run the application. |
2425
| 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. |
2526

2627
## Example
2728

28-
Java type tasks have two modes of execution, here is a demonstration of executing tasks in Java mode.
29+
There are two execution modes for Java task types, which will be demonstrated separately here.
2930

3031
The main configuration parameters are as follows:
3132
- Run Type
3233
- Module Path
3334
- Main Parameters
3435
- Java VM Parameters
35-
- Script
36+
- Main Package
37+
- Resources
3638

37-
![java_task](../../../../img/tasks/demo/java_task02.png)
39+
As shown in the figure.
40+
41+
- FAT_JAR
42+
43+
![java_task](../../../../img/tasks/demo/java_fat.png)
44+
45+
`FAT_JAR` is also known as `uber-jar`, where the dependencies and code are contained within the same `jar`. You only need to select this one `jar`.
46+
47+
- NORMAL_JAR
48+
49+
![java_task](../../../../img/tasks/demo/java_normal.png)
50+
51+
`normal1.jar` is the entry point of the program, and `normal2.jar` contains the required dependencies. The entry point of the program must be specified in the main program package, and all the dependencies along with the program entry `jar` files should be selected in the resource file to ensure correct execution.
3852

3953
## Note
4054

41-
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.
55+
1. For security reasons, when executing JAVA tasks, please use the environment management module to configure the JDK environment, such as `JAVA_HOME` and other environment variables.
56+
2. NORMAL_JAR should provide the main class name (optional), while FAT_JAR does not need to provide the main class name.
4257

43-
For security reasons, when executing JAVA tasks, please use the environment management module to configure the JDK environment, such as `JAVA_HOME` and other environment variables.

docs/docs/zh/guide/task/java.md

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## 综述
44

5-
该节点用于执行 java 类型的任务,支持使用单文件和jar包作为程序入口
5+
该节点用于执行`Java`类型的任务,支持使用`FAT_JAR`类型和`NORMAL_JAR`类型的`jar`包运行
66

77
## 创建任务
88

@@ -22,25 +22,39 @@
2222
| 模块路径 | 开启使用JAVA9+的模块化特性,把所有资源放入--module-path中,要求您的worker中的JDK版本支持模块化 |
2323
| 主程序参数 | 作为普通Java程序main方法入口参数 |
2424
| 虚拟机参数 | 配置启动虚拟机参数 |
25-
| 脚本 | 若使用JAVA运行类型则需要编写JAVA代码。代码中必须存在public类,不用写package语句 |
25+
| 主类名 | 启动类的完整主类名(可选) |
26+
| 主程序包 | 选择要运行程序的主程序包 |
2627
| 资源 | 可以是外部JAR包也可以是其他资源文件,它们都会被加入到类路径或模块路径中,您可以在自己的JAVA脚本中轻松获取 |
2728

2829
## 任务样例
2930

30-
java任务类型有两种运行模式,这里以JAVA模式为例进行演示
31+
java任务类型有两种运行模式,这里进行分别进行演示
3132

3233
主要配置参数如下:
3334

3435
- 运行类型
3536
- 模块路径
3637
- 主程序参数
3738
- 虚拟机参数
38-
- 脚本文件
39+
- 主程序包
40+
- 资源文件
3941

40-
![java_task](../../../../img/tasks/demo/java_task02.png)
42+
如图所示
43+
44+
- FAT_JAR类型
45+
46+
![java_task](../../../../img/tasks/demo/java_fat.png)
47+
48+
`FAT_JAR``uber-jar`,依赖和代码都在同一个`jar`中,只需选择这一个`jar`即可
49+
50+
- NORMAL_JAR类型
51+
52+
![java_task](../../../../img/tasks/demo/java_normal.png)
53+
54+
`normal1.jar`是程序运行的入口,`normal2.jar`是所需的依赖,需要用主程序包指定程序的入口,并且在资源文件中选择所有依赖和程序入口的`jar`文件,才能正确运行
4155

4256
## 注意事项
4357

44-
使用JAVA运行类型时代码中必须存在public类,可以不写package语句
58+
1. 基于安全原因,执行JAVA任务时,请使用环境管理功能配置JDK环境,例如`JAVA_HOME`等环境变量
59+
2. `NORMAL_JAR` 应该提供主类名(可选),`FAT_JAR` 不需要提供主类名。
4560

46-
基于安全原因,执行JAVA任务时,请使用环境管理功能配置JDK环境,例如`JAVA_HOME`等环境变量

docs/img/tasks/demo/java_fat.png

48.7 KB
Loading
51.3 KB
Loading
-280 KB
Binary file not shown.

0 commit comments

Comments
 (0)