org.gradle.api.Project.exec()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(9.6k)|赞(0)|评价(0)|浏览(301)

本文整理了Java中org.gradle.api.Project.exec()方法的一些代码示例,展示了Project.exec()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Project.exec()方法的具体详情如下:
包路径:org.gradle.api.Project
类名称:Project
方法名:exec

Project.exec介绍

暂无

代码示例

代码示例来源:origin: linkedin/pygradle

@Override
  public ExecResult exec(Action<? super ExecSpec> action) {
    return project.exec(action);
  }
}

代码示例来源:origin: gradle.plugin.com.linkedin.pygradle/pygradle-plugin

@Override
  public ExecResult exec(Action<? super ExecSpec> action) {
    return project.exec(action);
  }
}

代码示例来源:origin: gradle.plugin.me.taku_k.gradle.yarn/gradle-yarn-plugin

public void exec(List<String> args) {
    project.exec(new YarnExecAction(project, args));
  }
}

代码示例来源:origin: com.amazon.device.tools.build/gradle-core

@TaskAction
public void zipAlign() {
  getProject().exec(new Action<ExecSpec>() {
    @Override
    public void execute(ExecSpec execSpec) {
      execSpec.executable(getZipAlignExe());
      execSpec.args("-f", "4");
      execSpec.args(getInputFile());
      execSpec.args(getOutputFile());
    }
  });
}

代码示例来源:origin: gradle.plugin.net.karlmartens.gitversion/gitversion-plugin

private static String exec(Project project, String executable, String... args) {
  ByteArrayOutputStream out = new ByteArrayOutputStream();
  project.exec(execSpec -> {
    execSpec.setExecutable(executable);
    execSpec.setArgs(Arrays.asList(args));
    execSpec.setStandardOutput(out);
  });
  return out.toString();
}

代码示例来源:origin: com.palantir.gradle.conjure/gradle-conjure

@TaskAction
  public final void generate() {
    getProject().exec(execSpec -> {
      ImmutableList.Builder<String> commandArgsBuilder = ImmutableList.builder();
      commandArgsBuilder.add(
          executablePath.get().getAbsolutePath(),
          "compile",
          inputDirectory.get().getAbsolutePath(),
          outputFile.getAbsolutePath());

      List<String> args = commandArgsBuilder.build();
      getLogger().info("Running compiler with args: {}", args);
      execSpec.commandLine(args.toArray());
    });
  }
}

代码示例来源:origin: com.android.tools.build/gradle-core

@Override
  public void process(final String split, final File file) {
    final File out = new File(getOutputDirectory(),
        archivesBaseName + "-" + outputBaseName + "_" + split + ".apk");
    getProject().exec(new Action<ExecSpec>() {
      @Override
      public void execute(ExecSpec execSpec) {
        execSpec.setExecutable(getZipAlignExe());
        execSpec.args("-f", "4");
        execSpec.args(file.getAbsolutePath());
        execSpec.args(out);
      }
    });
  }
};

代码示例来源:origin: linkedin/pygradle

public static PythonVersion parsePythonVersion(final Project project, final File pythonInterpreter) {
    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();

    ExecResult execResult = project.exec(execSpec -> {
      execSpec.setExecutable(pythonInterpreter.getAbsolutePath());
      execSpec.setArgs(Collections.singletonList("--version"));
      execSpec.setStandardOutput(outputStream);
      execSpec.setErrorOutput(outputStream);
      execSpec.setIgnoreExitValue(true);
    });

    String output = outputStream.toString();
    if (execResult.getExitValue() != 0) {
      throw new GradleException(output);
    }

    String versionString = output.trim().split(" ")[1];
    return new PythonVersion(versionString);
  }
}

代码示例来源:origin: javafxports/javafxmobile-plugin

@TaskAction
  void action() {
    getProject().exec(execSpec -> {
      execSpec.setExecutable(getZipAlignExe());
      execSpec.setArgs(Arrays.asList(
          "-f", "4", getInputFile().getAbsolutePath(), getOutputFile().getAbsolutePath()
      ));
    });
  }
}

代码示例来源:origin: gradle.plugin.net.karlmartens.dotnet/dotnet-plugin

@TaskAction
  void exec() {
    getProject().exec(execSpec -> {
      execSpec.setExecutable(getExtension().getExecutable());
      execSpec.setArgs(Arrays.asList("--info"));
    });
  }
}

代码示例来源:origin: gradle.plugin.com.palantir.graal/gradle-graal

@TaskAction
public final void extractGraal() {
  if (!graalVersion.isPresent()) {
    throw new IllegalStateException("extract task requires graal.graalVersion to be defined.");
  }
  // ideally this would be a CopyTask, but through Gradle 4.9 CopyTask fails to correctly extract symlinks
  getProject().exec(spec -> {
    spec.executable("tar");
    spec.args("-xzf", inputTgz.get().getAsFile().getAbsolutePath());
    spec.workingDir(cacheDir.get().resolve(graalVersion.get()));
  });
}

代码示例来源:origin: org.shipkit/shipkit

public void execCommands(Collection<ExecCommand> execCommands, Project project) {
    for (final ExecCommand execCommand : execCommands) {
      ExecResult result = project.exec(new Action<ExecSpec>() {
        @Override
        public void execute(ExecSpec spec) {
          spec.setIgnoreExitValue(true);
          spec.commandLine(execCommand.getCommandLine());
          spec.setStandardOutput(new ExternalProcessStream(execCommand.getLoggingPrefix(), System.out));
          spec.setErrorOutput(new ExternalProcessStream(execCommand.getLoggingPrefix(), System.err));

          execCommand.getSetupAction().execute(spec);

          LOG.lifecycle("  " + execCommand.getDescription() + ":\n    " + StringUtil.join(execCommand.getCommandLine(), " "));
        }
      });
      LOG.lifecycle("  External process {} completed.", execCommand.getLoggingPrefix().trim());
      execCommand.getResultAction().execute(result);
    }
  }
}

代码示例来源:origin: mockito/shipkit

public void execCommands(Collection<ExecCommand> execCommands, Project project) {
    for (final ExecCommand execCommand : execCommands) {
      ExecResult result = project.exec(new Action<ExecSpec>() {
        @Override
        public void execute(ExecSpec spec) {
          spec.setIgnoreExitValue(true);
          spec.commandLine(execCommand.getCommandLine());
          spec.setStandardOutput(new ExternalProcessStream(execCommand.getLoggingPrefix(), System.out));
          spec.setErrorOutput(new ExternalProcessStream(execCommand.getLoggingPrefix(), System.err));

          execCommand.getSetupAction().execute(spec);

          LOG.lifecycle("  " + execCommand.getDescription() + ":\n    " + StringUtil.join(execCommand.getCommandLine(), " "));
        }
      });
      LOG.lifecycle("  External process {} completed.", execCommand.getLoggingPrefix().trim());
      execCommand.getResultAction().execute(result);
    }
  }
}

代码示例来源:origin: palantir/gradle-graal

@TaskAction
public final void extractGraal() {
  if (!graalVersion.isPresent()) {
    throw new IllegalStateException("extract task requires graal.graalVersion to be defined.");
  }
  // ideally this would be a CopyTask, but through Gradle 4.9 CopyTask fails to correctly extract symlinks
  getProject().exec(spec -> {
    spec.executable("tar");
    spec.args("-xzf", inputTgz.get().getAsFile().getAbsolutePath());
    spec.workingDir(cacheDir.get().resolve(graalVersion.get()));
  });
}

代码示例来源:origin: gradle.plugin.com.github.rmee/kubernetes

public void exec(HelmExecSpec spec) {
  project.getLogger().warn("Executing: " + spec.getCommandLine());
  String[] args = spec.getCommandLine().split("\\s+");
  args[0] = getClient().getBinPath();
  project.exec(execSpec -> {
    String tillerNamespace = getTillerNamespace();
    Map<String, String> env = new HashMap();
    env.putAll(System.getenv());
    if (tillerNamespace != null) {
      env.put("TILLER_NAMESPACE", tillerNamespace);
    }
    execSpec.setEnvironment(env);
    execSpec.setIgnoreExitValue(spec.isIgnoreExitValue());
    execSpec.setCommandLine(Arrays.asList(args));
  });
}

代码示例来源:origin: gradle.plugin.net.karlmartens.dotnet/dotnet-plugin

@TaskAction
void exec() {
  getProject().exec(execSpec -> {
    DotnetExtension ext = getExtension();
    execSpec.setExecutable(ext.getExecutable());
    List<String> args = new ArrayList<>();
    args.add("restore");
    whenHasValue(ext.getSolution(), args::add);
    whenHasValue(ext.getRuntime(), addNamedParameter(args, "--runtime"));
    execSpec.setArgs(args);
  });
}

代码示例来源:origin: gradle.plugin.com.linkedin.pygradle/pygradle-plugin

public void buildEntryPoint(String name, String entry, Map<String, String> pipFreezeDependencies) {
    Map<String, String> dependencies = pipFreezeDependencies;
    // When called from outside buildEntryPoints above, this can be null
    if (dependencies == null) {
      dependencies = new PipFreezeAction(project).getDependencies();
    }
    PexExecSpecAction action = PexExecSpecAction.withEntryPoint(project, name, entry, pexOptions, dependencies);
    ExecResult exec = project.exec(action);
    new PexExecOutputParser(action, exec).validatePexBuildSuccessfully();
  }
}

代码示例来源:origin: linkedin/pygradle

public void buildEntryPoint(String name, String entry, Map<String, String> pipFreezeDependencies) {
    Map<String, String> dependencies = pipFreezeDependencies;
    // When called from outside buildEntryPoints above, this can be null
    if (dependencies == null) {
      dependencies = new PipFreezeAction(project).getDependencies();
    }
    PexExecSpecAction action = PexExecSpecAction.withEntryPoint(project, name, entry, pexOptions, dependencies);
    ExecResult exec = project.exec(action);
    new PexExecOutputParser(action, exec).validatePexBuildSuccessfully();
  }
}

代码示例来源:origin: gradle.plugin.net.karlmartens.dotnet/dotnet-plugin

@TaskAction
void exec() {
  getProject().exec(execSpec -> {
    DotnetExtension ext = getExtension();
    execSpec.setExecutable(ext.getExecutable());
    List<String> args = new ArrayList<>();
    args.add("build");
    whenHasValue(ext.getSolution(), args::add);
    whenHasValue(ext.getConfiguration(), addNamedParameter(args, "--configuration"));
    whenHasValue(ext.getFramework(), addNamedParameter(args, "--framework"));
    whenHasValue(ext.getRuntime(), addNamedParameter(args, "--runtime"));
    args.add("--no-restore");
    appendParameters(args);
    execSpec.setArgs(args);
  });
}

代码示例来源:origin: gradle.plugin.net.karlmartens.dotnet/dotnet-plugin

private void publish(String runtime) {
  getProject().exec(execSpec -> {
    DotnetExtension ext = getExtension();
    execSpec.setExecutable(ext.getExecutable());
    List<String> args = new ArrayList<>();
    args.add("publish");
    whenHasValue(ext.getSolution(), args::add);
    whenHasValue(ext.getConfiguration(), addNamedParameter(args, "--configuration"));
    whenHasValue(ext.getFramework(), addNamedParameter(args, "--framework"));
    whenHasValue(runtime, addNamedParameter(args, "--runtime"));
    appendParameters(args);
    execSpec.setArgs(args);
  });
}

相关文章