Search in sources :

Example 1 with GcloudExtension

use of org.curioswitch.gradle.plugins.gcloud.GcloudExtension in project curiostack by curioswitch.

the class GcloudTask method exec.

@TaskAction
public void exec() {
    GcloudExtension config = getProject().getRootProject().getExtensions().getByType(GcloudExtension.class);
    var toolManager = DownloadedToolManager.get(getProject());
    String command = Os.isFamily(Os.FAMILY_WINDOWS) ? COMMAND + ".cmd" : COMMAND;
    Path executable = toolManager.getBinDir("gcloud").resolve(command);
    List<Object> fullArgs = ImmutableList.builder().add("--project=" + config.getClusterProject().get()).add("--quiet").addAll(args.get().stream().map(o -> o instanceof Provider ? ((Provider) o).get() : o)::iterator).build();
    getProject().exec(exec -> {
        exec.executable(executable);
        exec.args(fullArgs);
        toolManager.addAllToPath(exec);
        exec.environment("CLOUDSDK_PYTHON", toolManager.getBinDir("miniconda-build").resolve("python"));
        exec.environment("CLOUDSDK_PYTHON_SITEPACKAGES", "1");
        exec.setStandardInput(System.in);
    });
}
Also used : Path(java.nio.file.Path) TaskAction(org.gradle.api.tasks.TaskAction) List(java.util.List) Provider(org.gradle.api.provider.Provider) Os(org.apache.tools.ant.taskdefs.condition.Os) ImmutableList(com.google.common.collect.ImmutableList) GcloudExtension(org.curioswitch.gradle.plugins.gcloud.GcloudExtension) DownloadedToolManager(org.curioswitch.gradle.tooldownloader.DownloadedToolManager) ListProperty(org.gradle.api.provider.ListProperty) DefaultTask(org.gradle.api.DefaultTask) DownloadToolUtil(org.curioswitch.gradle.tooldownloader.util.DownloadToolUtil) Path(java.nio.file.Path) GcloudExtension(org.curioswitch.gradle.plugins.gcloud.GcloudExtension) Provider(org.gradle.api.provider.Provider) TaskAction(org.gradle.api.tasks.TaskAction)

Aggregations

ImmutableList (com.google.common.collect.ImmutableList)1 Path (java.nio.file.Path)1 List (java.util.List)1 Os (org.apache.tools.ant.taskdefs.condition.Os)1 GcloudExtension (org.curioswitch.gradle.plugins.gcloud.GcloudExtension)1 DownloadedToolManager (org.curioswitch.gradle.tooldownloader.DownloadedToolManager)1 DownloadToolUtil (org.curioswitch.gradle.tooldownloader.util.DownloadToolUtil)1 DefaultTask (org.gradle.api.DefaultTask)1 ListProperty (org.gradle.api.provider.ListProperty)1 Provider (org.gradle.api.provider.Provider)1 TaskAction (org.gradle.api.tasks.TaskAction)1