ailiujiarui commented on code in PR #16542:
URL:
https://github.com/apache/dolphinscheduler/pull/16542#discussion_r1811609348
##########
dolphinscheduler-task-plugin/dolphinscheduler-task-java/src/main/java/org/apache/dolphinscheduler/plugin/task/java/JavaTask.java:
##########
@@ -150,43 +132,48 @@ public void handle(TaskCallBack taskCallBack) throws
TaskException {
}
/**
- * Construct a shell command for the java Run mode
+ * Construct a shell command for the java -jar Run mode
*
* @return String
- * @throws Exception
**/
- protected String buildJavaCommand() throws Exception {
+ protected String buildJarCommand() {
+ ResourceContext resourceContext = taskRequest.getResourceContext();
+ String mainJarAbsolutePathInLocal = resourceContext
+ .getResourceItem(javaParameters.getMainJar().getResourceName())
+ .getResourceAbsolutePathInLocal();
StringBuilder builder = new StringBuilder();
- String sourceCode = buildJavaSourceContent();
- builder.append(buildJavaCompileCommand(sourceCode))
- .append(";")
- .append(getJavaCommandPath())
+ builder.append(getJavaCommandPath())
.append("java").append(" ")
- .append(buildResourcePath())
- .append(" ")
- .append(getPublicClassName(sourceCode))
- .append(" ")
+ .append(buildResourcePath()).append(" ")
+ .append("-jar").append(" ")
+ .append(mainJarAbsolutePathInLocal).append(" ")
.append(javaParameters.getMainArgs().trim()).append(" ")
.append(javaParameters.getJvmArgs().trim());
return builder.toString();
}
/**
- * Construct a shell command for the java -jar Run mode
+ * Construct a shell command for the java -cp run mode
*
* @return String
**/
- protected String buildJarCommand() {
+ protected String buildNormalJarCommand() {
ResourceContext resourceContext = taskRequest.getResourceContext();
- String mainJarAbsolutePathInLocal = resourceContext
- .getResourceItem(javaParameters.getMainJar().getResourceName())
+ String mainJarAbsolutePathInLocal = resourceContext.getResourceItem(
+ javaParameters.getMainJar()
+ .getResourceName())
.getResourceAbsolutePathInLocal();
+ String mainJarName = null;
+ try {
+ mainJarName =
MainClassExtractor.getMainClassName(mainJarAbsolutePathInLocal);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
StringBuilder builder = new StringBuilder();
builder.append(getJavaCommandPath())
.append("java").append(" ")
.append(buildResourcePath()).append(" ")
- .append("-jar").append(" ")
- .append(mainJarAbsolutePathInLocal).append(" ")
+ .append(mainJarName).append(" ")
Review Comment:
Updated
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]