@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())); }); }
@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 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())); }); }
@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 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); }); }