Skip to content

Commit

Permalink
[Optimization]Optimize the environment check of git project build (#3265
Browse files Browse the repository at this point in the history
)
  • Loading branch information
Zzm0809 authored Mar 9, 2024
1 parent 53e72f1 commit cfb99b6
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 9 deletions.
3 changes: 2 additions & 1 deletion dinky-admin/src/main/java/org/dinky/sse/git/HeadStepSse.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

package org.dinky.sse.git;

import org.dinky.data.enums.Status;
import org.dinky.data.model.GitProject;
import org.dinky.sse.StepSse;
import org.dinky.utils.MavenUtil;
Expand Down Expand Up @@ -67,7 +68,7 @@ private void checkJava() {
String mavenHome = MavenUtil.getMavenHome();

if (StrUtil.isBlank(mavenHome)) {
addFileMsg("Please set the environment variable:MAVEN_HOME");
addFileMsg(Status.GIT_MAVEN_HOME_NOT_SET.getMessage());
setFinish(false);
}
String mavenVersionMsg = MavenUtil.getMavenVersion();
Expand Down
15 changes: 7 additions & 8 deletions dinky-admin/src/main/java/org/dinky/utils/MavenUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

package org.dinky.utils;

import org.dinky.data.enums.Status;
import org.dinky.data.exception.BusException;
import org.dinky.data.exception.DinkyException;
import org.dinky.data.model.SystemConfiguration;
import org.dinky.function.constant.PathConstant;
Expand Down Expand Up @@ -181,11 +183,8 @@ public static String getMavenVersion() {
public static String getMavenHome() {
String mavenHome = SystemUtil.get("MAVEN_HOME");
if (StrUtil.isNotBlank(mavenHome)) {
return mavenHome;
}
String searchCmd = SystemUtil.getOsInfo().isWindows() ? "where" : "which";
mavenHome = RuntimeUtil.execForStr(searchCmd + " " + EXECTOR).trim();
if (StrUtil.isNotBlank(mavenHome)) {
String searchCmd = SystemUtil.getOsInfo().isWindows() ? "where" : "which";
mavenHome = RuntimeUtil.execForStr(searchCmd + " " + EXECTOR).trim();
try {
return new File(mavenHome)
.toPath()
Expand All @@ -194,11 +193,11 @@ public static String getMavenHome() {
.getParent()
.toString();
} catch (IOException e) {
e.printStackTrace();
return null;
throw new RuntimeException(e);
}
} else {
throw new BusException(Status.GIT_MAVEN_HOME_NOT_SET);
}
return null;
}

public static List<File> getJars(File pom) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ public enum Status {
GIT_BRANCH_NOT_FOUND(16003, "git.branch.not.found"),
GIT_BUILDING(16004, "git.building"),
GIT_BUILD_SUCCESS(16005, "git.build.success"),
GIT_MAVEN_HOME_NOT_SET(16006, "git.maven.home.not.set"),

/**
* dolphin scheduler
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ schedule.status.unknown=Unknown Status: {0}
user.binding.role.delete.all=User Binding Role Delete All
modify.failed=Update Failed
git.build.success=Pre-update status success, start executing the build process
git.maven.home.not.set=Maven Home Not Set, Please Set MAVEN_HOME Environment Variable First
menu.has.child=Menu Has Child, Can Not Delete
tenant.already.exists=Tenant Already Exists
save.failed=Save Failed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ schedule.status.unknown=未知状态: {0}
user.binding.role.delete.all=用户绑定角色删除所有
modify.failed=修改失败
git.build.success=预更新状态成功,开始执行构建流程
git.maven.home.not.set=未设置 Maven Home,请先设置 MAVEN_HOME 环境变量
menu.has.child=存在子菜单 不允许删除
tenant.already.exists=租户已存在
save.failed=保存失败
Expand Down

0 comments on commit cfb99b6

Please sign in to comment.