use of org.curioswitch.gradle.tooldownloader.DownloadedToolManager in project curiostack by curioswitch.
the class SetupTask method exec.
@TaskAction
public void exec() throws Exception {
if ("true".equals(System.getenv("CI")) || toolName.equals("graalvm")) {
return;
}
DownloadedToolManager toolManager = DownloadToolUtil.getManager(getProject());
Path shimsPath = toolManager.getCuriostackDir().resolve("shims");
if (Files.exists(shimsPath)) {
try (var s = Files.walk(shimsPath)) {
s.sorted(Comparator.reverseOrder()).map(Path::toFile).forEach(File::delete);
}
}
getProject().mkdir(shimsPath);
final String shimTemplate;
try {
shimTemplate = Resources.toString(Resources.getResource("tooldownloader/shim-template.sh"), StandardCharsets.UTF_8);
} catch (IOException e) {
throw new UncheckedIOException("Could not open shim template.", e);
}
for (Path binDir : toolManager.getBinDirs(toolName)) {
try (Stream<Path> s = Files.list(binDir)) {
s.filter(Files::isExecutable).filter(p -> !p.getFileName().toString().startsWith("git")).filter(p -> !p.getFileName().endsWith(".dll")).filter(p -> !p.getFileName().endsWith(".pyd")).forEach(path -> workerExecutor.submit(WriteShim.class, config -> {
config.setIsolationMode(IsolationMode.NONE);
config.params(shimsPath.toString(), path.toString(), shimTemplate);
}));
} catch (IOException e) {
throw new UncheckedIOException("Could not open directory.", e);
}
}
}
Aggregations