Skip to content

Commit

Permalink
fix-udf-bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Zzm0809 committed Nov 6, 2023
1 parent 9457bf8 commit 829d37b
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
29 changes: 27 additions & 2 deletions dinky-admin/src/main/java/org/dinky/utils/MavenUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -102,7 +103,7 @@ public static boolean build(
s = DateUtil.date().toMsStr() + " - " + s + "\n";
consumer.accept(s);
},
log::error);
consumer::accept);
return waitValue == 0;
}

Expand Down Expand Up @@ -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<String> goals,
List<String> args) {
projectDir = StrUtil.wrap(projectDir, "\"");
settingsPath = StrUtil.wrap(settingsPath, "\"");
List<String> 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");
}
Expand Down
6 changes: 4 additions & 2 deletions dinky-admin/src/main/java/org/dinky/utils/RuntimeUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -61,7 +62,8 @@ public static int run(String shell, Consumer<String> outputConsumer, Consumer<St
reader.close();
inputStream.close();
} catch (IOException e) {
e.printStackTrace();
errorConsumer.accept(ExceptionUtil.stacktraceToOneLineString(e));
RUNNING.remove(process);
}
})
.start();
Expand All @@ -74,7 +76,7 @@ public static int run(String shell, Consumer<String> outputConsumer, Consumer<St
Opt.ofNullable(errorConsumer).ifPresent(x -> x.accept(errMsg));
}
} catch (IOException | InterruptedException e) {
e.printStackTrace();
errorConsumer.accept(ExceptionUtil.stacktraceToOneLineString(e));
}
return waitValue;
}
Expand Down

0 comments on commit 829d37b

Please sign in to comment.