From 829d37b04e9f07ed96009164ae11ee886a8f43c6 Mon Sep 17 00:00:00 2001 From: zhu-mingye <934230207@qq.com> Date: Mon, 6 Nov 2023 13:46:57 +0800 Subject: [PATCH] fix-udf-bug --- .../resource/impl/ResourceServiceImpl.java | 2 +- .../main/java/org/dinky/utils/MavenUtil.java | 29 +++++++++++++++++-- .../java/org/dinky/utils/RuntimeUtils.java | 6 ++-- 3 files changed, 32 insertions(+), 5 deletions(-) diff --git a/dinky-admin/src/main/java/org/dinky/service/resource/impl/ResourceServiceImpl.java b/dinky-admin/src/main/java/org/dinky/service/resource/impl/ResourceServiceImpl.java index 2043142561..6edab021fa 100644 --- a/dinky-admin/src/main/java/org/dinky/service/resource/impl/ResourceServiceImpl.java +++ b/dinky-admin/src/main/java/org/dinky/service/resource/impl/ResourceServiceImpl.java @@ -169,7 +169,7 @@ public File getFile(Integer id) { Resources resources = getById(id); Assert.notNull(resources, () -> new BusException(Status.RESOURCE_DIR_OR_FILE_NOT_EXIST)); Assert.isFalse(resources.getSize() > ALLOW_MAX_CAT_CONTENT_SIZE, () -> new BusException("file is too large!")); - return URLUtils.toFile("rs:" + resources.getFullName()); + return URLUtils.toFile("rs://" + resources.getFullName()); } @Transactional(rollbackFor = Exception.class) diff --git a/dinky-admin/src/main/java/org/dinky/utils/MavenUtil.java b/dinky-admin/src/main/java/org/dinky/utils/MavenUtil.java index 63a0289f5f..eb41b3741c 100644 --- a/dinky-admin/src/main/java/org/dinky/utils/MavenUtil.java +++ b/dinky-admin/src/main/java/org/dinky/utils/MavenUtil.java @@ -93,7 +93,8 @@ public static boolean build( } else { localRepositoryDirectory = repositoryDir; } - String mavenCommandLine = getMavenCommandLine(pom, mavenHome, localRepositoryDirectory, setting, goals, args); + String mavenCommandLine = + getMavenCommandLineByMvn(pom, mavenHome, localRepositoryDirectory, setting, goals, args); Opt.ofNullable(consumer).ifPresent(c -> c.accept("Executing command: " + mavenCommandLine + "\n")); int waitValue = RuntimeUtils.run( @@ -102,7 +103,7 @@ public static boolean build( s = DateUtil.date().toMsStr() + " - " + s + "\n"; consumer.accept(s); }, - log::error); + consumer::accept); return waitValue == 0; } @@ -149,6 +150,30 @@ public static String getMavenCommandLine( return StrUtil.join(" ", commandLine); } + public static String getMavenCommandLineByMvn( + String projectDir, + String mavenHome, + String repositoryDir, + String settingsPath, + List goals, + List args) { + projectDir = StrUtil.wrap(projectDir, "\""); + settingsPath = StrUtil.wrap(settingsPath, "\""); + List commandLine = new LinkedList<>(); + + commandLine.add(mavenHome + "/bin/mvn"); + commandLine.add("-Dmaven.multiModuleProjectDirectory=" + projectDir); + commandLine.add("-Dmaven.home=" + StrUtil.wrap(mavenHome, "\"")); + Opt.ofBlankAble(repositoryDir) + .ifPresent(x -> commandLine.add("-Dmaven.repo.local=" + StrUtil.wrap(repositoryDir, "\""))); + commandLine.add("-Dclassworlds.conf=" + StrUtil.wrap(mavenHome + "/bin/m2.conf", "\"")); + commandLine.add("-s " + settingsPath); + commandLine.add("-f " + projectDir); + commandLine.add(StrUtil.join(" ", args)); + commandLine.add(StrUtil.join(" ", goals)); + return StrUtil.join(" ", commandLine); + } + public static String getMavenVersion() { return RuntimeUtil.execForStr(getMavenHome() + "/bin/" + EXECTOR + " -v"); } diff --git a/dinky-admin/src/main/java/org/dinky/utils/RuntimeUtils.java b/dinky-admin/src/main/java/org/dinky/utils/RuntimeUtils.java index c30f28b356..87f4ebeeaf 100644 --- a/dinky-admin/src/main/java/org/dinky/utils/RuntimeUtils.java +++ b/dinky-admin/src/main/java/org/dinky/utils/RuntimeUtils.java @@ -29,6 +29,7 @@ import java.util.function.Consumer; import java.util.stream.Collectors; +import cn.hutool.core.exceptions.ExceptionUtil; import cn.hutool.core.lang.Opt; import lombok.extern.slf4j.Slf4j; @@ -61,7 +62,8 @@ public static int run(String shell, Consumer outputConsumer, Consumer outputConsumer, Consumer x.accept(errMsg)); } } catch (IOException | InterruptedException e) { - e.printStackTrace(); + errorConsumer.accept(ExceptionUtil.stacktraceToOneLineString(e)); } return waitValue; }