Search in sources :

Example 11 with PlatformHelper

use of org.curioswitch.gradle.helpers.platform.PlatformHelper in project curiostack by curioswitch.

the class PulumiSetupPlugin method apply.

@Override
public void apply(Project project) {
    checkState(project.getParent() == null, "PulumiSetupPlugin can only be applied to the root project.");
    var toolDownloaderPlugin = project.getPlugins().apply(ToolDownloaderPlugin.class);
    toolDownloaderPlugin.registerToolIfAbsent("pulumi", tool -> {
        tool.getVersion().set(ToolDependencies.getPulumiVersion(project));
        tool.getBaseUrl().set("https://get.pulumi.com/releases/sdk/");
        tool.getArtifactPattern().set("[artifact]-v[revision]-[classifier].[ext]");
        var osClassifiers = tool.getOsClassifiers();
        osClassifiers.getLinux().set("linux-x64");
        osClassifiers.getMac().set("darwin-x64");
        osClassifiers.getWindows().set("windows-x64");
        switch(new PlatformHelper().getOs()) {
            case LINUX:
            case MAC_OSX:
                tool.getPathSubDirs().add("pulumi");
                break;
            case WINDOWS:
                tool.getPathSubDirs().add("Pulumi/bin");
                break;
            case UNKNOWN:
                throw new IllegalStateException("Unsupported OS");
        }
    });
}
Also used : PlatformHelper(org.curioswitch.gradle.helpers.platform.PlatformHelper)

Aggregations

PlatformHelper (org.curioswitch.gradle.helpers.platform.PlatformHelper)11 Path (java.nio.file.Path)6 OperatingSystem (org.curioswitch.gradle.helpers.platform.OperatingSystem)6 TaskAction (org.gradle.api.tasks.TaskAction)6 IOException (java.io.IOException)3 DownloadedToolManager (org.curioswitch.gradle.tooldownloader.DownloadedToolManager)3 Project (org.gradle.api.Project)3 Preconditions.checkState (com.google.common.base.Preconditions.checkState)2 ImmutableList.toImmutableList (com.google.common.collect.ImmutableList.toImmutableList)2 File (java.io.File)2 UncheckedIOException (java.io.UncheckedIOException)2 Files (java.nio.file.Files)2 Paths (java.nio.file.Paths)2 List (java.util.List)2 ToolDependencies (org.curioswitch.gradle.plugins.curiostack.ToolDependencies)2 ToolDownloaderPlugin (org.curioswitch.gradle.tooldownloader.ToolDownloaderPlugin)2 DownloadToolUtil (org.curioswitch.gradle.tooldownloader.util.DownloadToolUtil)2 DefaultTask (org.gradle.api.DefaultTask)2 Plugin (org.gradle.api.Plugin)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1