use of org.curioswitch.gradle.helpers.platform.PlatformHelper in project curiostack by curioswitch.
the class UpdateIntelliJSdksTask method exec.
@TaskAction
public void exec() throws IOException {
final Path intelliJConfigFolder;
switch(new PlatformHelper().getOs()) {
case LINUX:
intelliJConfigFolder = Paths.get(System.getProperty("user.home"), ".config", "JetBrains");
break;
case MAC_OSX:
intelliJConfigFolder = Paths.get(System.getProperty("user.home"), "Library", "Application Support", "JetBrains");
break;
case WINDOWS:
intelliJConfigFolder = Paths.get(System.getProperty("user.home"), "AppData", "Roaming", "JetBrains");
break;
case UNKNOWN:
default:
throw new GradleException("Unsupported OS");
}
final List<Path> intelliJFolders;
try (var files = Files.list(intelliJConfigFolder)) {
intelliJFolders = files.filter(path -> Files.isDirectory(path) && (path.getFileName().toString().startsWith(".IntelliJIdea") || path.getFileName().toString().startsWith(".IdeaIC"))).sorted().collect(toImmutableList());
}
final Path intelliJFolder;
if (!intelliJFolders.isEmpty()) {
intelliJFolder = Iterables.getLast(intelliJFolders);
} else {
getProject().getLogger().info("No IntelliJ config folder found, writing to default location.");
intelliJFolder = intelliJConfigFolder.resolve(LATEST_INTELLIJ_CONFIG_FOLDER);
}
getProject().getLogger().info("Updating IntelliJ folder {}, found folders {}", intelliJFolder, intelliJFolders);
String majorVersion = ToolDependencies.getOpenJdkVersion(getProject());
String javaVersion = Files.readString(getProject().getRootProject().file(".gradle/jdk-release-name.txt").toPath());
var jdkTable = Files.createDirectories(intelliJFolder.resolve("config/options")).resolve("jdk.table.xml");
updateConfig(jdkTable, "jdk-" + javaVersion, majorVersion, "curiostack/openjdk-intellij-table-snippet.template.xml", ImmutableMap.of("javaVersion", javaVersion, "javaModules", JAVA_MODULES, "majorVersion", majorVersion), getProject());
// We optimistically update Go SDKs as well even if the build doesn't use Go. The worst that
// could happen is a couple of red SDKs in the IntelliJ lists.
updateGoSdk(intelliJFolder, getProject());
updateGoPath(intelliJFolder, getProject());
}
use of org.curioswitch.gradle.helpers.platform.PlatformHelper in project curiostack by curioswitch.
the class FetchCodeCovCacheTask method exec.
@TaskAction
public void exec() {
ExternalExecUtil.exec(getProject(), workerExecutor, exec -> {
var toolManager = DownloadedToolManager.get(getProject());
String gsutil = new PlatformHelper().getOs() == OperatingSystem.WINDOWS ? "gsutil.cmd" : "gsutil";
exec.executable("bash");
exec.args("-c", gsutil + " cp " + src.get() + " - | tar -xpz --skip-old-files");
exec.setIgnoreExitValue(true);
toolManager.addAllToPath(exec);
});
}
use of org.curioswitch.gradle.helpers.platform.PlatformHelper in project curiostack by curioswitch.
the class InstallCondaPackagesTask method exec.
@TaskAction
void exec() {
Path toolDir = toolManager.getToolDir(name);
getProject().exec(exec -> {
OperatingSystem operatingSystem = new PlatformHelper().getOs();
if (operatingSystem == OperatingSystem.WINDOWS) {
exec.executable(toolDir.resolve("Scripts").resolve("conda.exe"));
} else {
exec.executable(toolDir.resolve("bin").resolve("conda"));
}
exec.args("install", "-y");
exec.args(packages.get());
toolManager.addAllToPath(exec);
});
getProject().delete(toolDir.resolve("pkgs"));
}
use of org.curioswitch.gradle.helpers.platform.PlatformHelper in project curiostack by curioswitch.
the class AwsSetupPlugin method apply.
@Override
public void apply(Project project) {
checkState(project.getParent() == null, "AwsSetupPlugin must be applied to root project.");
var toolDownloaderPlugin = project.getPlugins().apply(ToolDownloaderPlugin.class);
var operatingSystem = new PlatformHelper().getOs();
toolDownloaderPlugin.registerToolIfAbsent("awscli", tool -> {
tool.getVersion().set(ToolDependencies.getAwsCliVersion(project));
tool.getBaseUrl().set("https://awscli.amazonaws.com/");
tool.getArtifactPattern().set("[artifact].[ext]");
if (operatingSystem == OperatingSystem.LINUX) {
tool.getArtifact().set("awscli-exe-linux-x86_64");
} else {
tool.getArtifact().set("AWSCLIV2");
}
var osExtensions = tool.getOsExtensions();
osExtensions.getLinux().set("zip");
osExtensions.getMac().set("pkg");
osExtensions.getWindows().set("msi");
if (operatingSystem == OperatingSystem.WINDOWS) {
tool.getPathSubDirs().add("Amazon/AWSCLIV2");
}
});
if (operatingSystem != OperatingSystem.LINUX) {
var downloadTool = DownloadToolUtil.getDownloadTask(project, "awscli");
downloadTool.configure(t -> {
t.setArchiveExtractAction(archive -> {
var toolDir = toolDownloaderPlugin.toolManager().getToolDir("awscli");
if (operatingSystem == OperatingSystem.WINDOWS) {
project.exec(exec -> {
exec.executable("cmd");
exec.args("/c", "start /wait msiexec /a " + archive.getAbsolutePath() + " TARGETDIR=" + toolDir.toAbsolutePath().toString() + " /qn");
});
}
});
});
}
}
use of org.curioswitch.gradle.helpers.platform.PlatformHelper in project curiostack by curioswitch.
the class NodeTask method exec.
@TaskAction
public void exec() {
ExternalExecUtil.exec(getProject(), workerExecutor, exec -> {
var toolManager = DownloadedToolManager.get(getProject());
String command = this.command.get();
if (new PlatformHelper().getOs() == OperatingSystem.WINDOWS) {
if (command.equals("node")) {
command += ".exe";
} else {
command += ".cmd";
}
}
Path binDir = toolManager.getBinDir("node");
exec.executable(binDir.resolve(command));
exec.args(args.get());
toolManager.addAllToPath(exec, getProject().getRootProject().file("node_modules/.bin").toPath());
execOverrides.forEach(o -> o.execute(exec));
CondaExecUtil.condaExec(exec, getProject());
});
}
Aggregations