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(); }
@Override public void execute(final ExecSpec it) { it.setExecutable(cache.getBashFile()); it.setArgs(Arrays.asList("--login", "-c", "exit 0")); } }).rethrowFailure();
private void doPush(File file) { if (file == null || !file.exists() || !file.isFile()) { throw new RuntimeException("Failed to generate nuget package. Nothing to publish."); } LOGGER.quiet("Publishing '{}' to repository '{}'", file.getAbsoluteFile(), _repository); DotnetExtension ext = getExtension(); getProject().exec(execSpec -> { execSpec.setExecutable(ext.getExecutable()); List<String> args = new ArrayList<>(); args.add("nuget"); args.add("push"); args.add(file.getAbsolutePath()); args.add("--source"); args.add(_repository); args.add("--api-key"); args.add(_apiKey); execSpec.setArgs(args); }); }
@Override public void execute(ExecSpec execSpec) { execSpec.setExecutable(ext.getBinPath()); execSpec.setArgs(args); } }
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); } }
@TaskAction void action() { getProject().exec(execSpec -> { execSpec.setExecutable(getZipAlignExe()); execSpec.setArgs(Arrays.asList( "-f", "4", getInputFile().getAbsolutePath(), getOutputFile().getAbsolutePath() )); }); } }
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); } }
@TaskAction void exec() { getProject().exec(execSpec -> { execSpec.setExecutable(getExtension().getExecutable()); execSpec.setArgs(Arrays.asList("--info")); }); } }
private void runTest(File file) { DotnetExtension ext = getExtension(); getProject().exec(execSpec -> { execSpec.setExecutable(ext.getExecutable()); List<String> args = new ArrayList<>(); args.add("test"); args.add(file.getAbsolutePath()); whenHasValue(ext.getConfiguration(), addNamedParameter(args, "--configuration")); whenHasValue(ext.getFramework(), addNamedParameter(args, "--framework")); args.add("--no-restore"); args.add("--no-build"); args.add("--logger"); args.add(String.format(Locale.US, "\"trx;LogFileName=%s.trx\"", file.getName())); args.add("--results-directory"); args.add("../TestResults"); execSpec.setArgs(args); }); }
args.add("-NonInteractive"); execSpec.setArgs(args); execSpec.setStandardOutput(out); });
@TaskAction void generateKey() throws IOException { String pathKeyFile = this.outputDir + File.separatorChar + this.keyFile; // execute openssl cmd to create private key getProject().exec(execSpec -> { execSpec.setIgnoreExitValue(true); execSpec.workingDir("."); execSpec.setExecutable("openssl"); List<String> args = Arrays.asList( "genrsa", "-des3", "-out", pathKeyFile, "-passout", "pass:"+this.keyPassword ); execSpec.setArgs(args); }); }
@TaskAction void generateCert() { String pathCertFile = this.outputDir + File.separatorChar + this.certFile; String pathKeyFile = this.outputDir + File.separatorChar + this.keyFile; // execute openssl cmd to create public cert getProject().exec(execSpec -> { execSpec.setIgnoreExitValue(true); execSpec.workingDir("."); execSpec.setExecutable("openssl"); List<String> args = Arrays.asList( "req", "-new", "-x509", "-key", pathKeyFile, "-out", pathCertFile, "-passin", "pass:"+this.keyPassword, "-subj", "/C=US" ); execSpec.setArgs(args); }); }
@TaskAction void generateJKS() { String pathJksFile = this.outputDir + File.separatorChar + this.jksFile; String pathPkcs12File = this.outputDir + File.separatorChar + this.pkcs12File; getProject().exec(execSpec -> { execSpec.setIgnoreExitValue(true); execSpec.workingDir("."); execSpec.setExecutable("keytool"); List<String> args = Arrays.asList( "-importkeystore", "-srcstoretype", "PKCS12", "-srckeystore", pathPkcs12File, "-srcstorepass", this.pkcs12Password, "-destkeystore", pathJksFile, "-storepass", this.jksPassword ); execSpec.setArgs(args); }); }
@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); }); }
@TaskAction void generatePKCS12() { String pathPKCS12File = this.outputDir + File.separatorChar + this.pkcs12File; String pathKeyFile = this.outputDir + File.separatorChar + this.keyFile; String pathCertFile = this.outputDir + File.separatorChar + this.certFile; // execute openssl cmd to create pkcs12 keystore getProject().exec(execSpec -> { execSpec.setIgnoreExitValue(true); execSpec.workingDir("."); execSpec.setExecutable("openssl"); List<String> args = Arrays.asList( "pkcs12", "-inkey", pathKeyFile, "-in", pathCertFile, "-export", "-out", pathPKCS12File, "-passin", "pass:"+this.keyPassword, "-password", "pass:"+this.pkcs12Password, "-name", this.keystoreAlias ); execSpec.setArgs(args); }); }
appendParameters(args); execSpec.setArgs(args); execSpec.setStandardOutput(out); execSpec.setErrorOutput(err);
@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); }); }
@TaskAction void exec() { DotnetExtension ext = getExtension(); getProject().exec(execSpec -> { execSpec.setExecutable(ext.getExecutable()); List<String> args = new ArrayList<>(); args.add("clean"); whenHasValue(ext.getSolution(), args::add); whenHasValue(ext.getConfiguration(), addNamedParameter(args, "--configuration")); whenHasValue(ext.getFramework(), addNamedParameter(args, "--framework")); whenHasValue(ext.getRuntime(), addNamedParameter(args, "--runtime")); execSpec.setArgs(args); }); cleanPackages(); getProject().delete(getProject().getProjectDir().toPath().resolve("TestResults")); getProject().delete(getProject().getBuildDir()); }
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); }); }