@SuppressFBWarnings(value = "RV_RETURN_VALUE_IGNORED_NO_SIDE_EFFECT", justification = "FindBugs thinks that setClasspath() doesn't have a side effect, but it actually does.") private void modifyClassPath(JavaExecSpec execSpec) { if (workingDirectory != null) { execSpec.setWorkingDir(workingDirectory); } FileCollection classpath = execSpec.getClasspath(); execSpec.setClasspath(classpath.filter(file -> { String name = file.getName(); if (name.startsWith("org.eclipse") && !name.startsWith("org.eclipse.osgi")) { return false; } else { return true; } })); if (vmArgs != null) { execSpec.jvmArgs(vmArgs); } }
private void execute(Test test, TestResultProcessor resultProcessor) { execute(execSpec -> { test.copyTo(execSpec); execSpec.setClasspath(test.getClasspath()); }, resultProcessor); }
public void exec() { project.javaexec(exec -> { exec.setClasspath(project.getBuildscript().getConfigurations().getByName("classpath")); String path = retrobufferClasspath.getAsPath(); exec.setMain("org.javafxports.retrobuffer.Main"); exec.setJvmArgs(Arrays.asList( "-Dretrobuffer.inputDir=" + inputDir, "-Dretrobuffer.outputDir=" + outputDir, "-Dretrobuffer.classpath=" + path )); if (classpathLengthGreaterThanLimit(path)) { try { File classpathFile = File.createTempFile("inc-", ".path"); try (BufferedWriter writer = Files.newBufferedWriter(classpathFile.toPath(), StandardCharsets.UTF_8)) { for (File item : this.retrobufferClasspath) { writer.write(item.toString() + "\n"); } } classpathFile.deleteOnExit(); exec.getJvmArgs().add("-Dretrobuffer.classpathFile=" + classpathFile.getAbsolutePath()); } catch (IOException e) { } } else { exec.getJvmArgs().add("-Dretrobuffer.classpath=" + path); } for (String arg : jvmArgs) { exec.getJvmArgs().add(arg); } }); }
public void doCall(JavaExecSpec javaExecSpec) { javaExecSpec.setMain("org.apache.axis.wsdl.WSDL2Java") .args(arguments) .setClasspath(getProject().getConfigurations().getByName("compile")); } });
public void exec(ClojureExecSpec cljSpec) { FileCollection fullClasspath = cljSpec.getClasspath(); project.javaexec(spec -> { spec.setMain("clojure.main"); spec.args("-m", cljSpec.getMain()); String ednArgs = Edn.print(Arrays.asList(cljSpec.getArgs())); ByteArrayInputStream input = new ByteArrayInputStream(ednArgs.getBytes(StandardCharsets.UTF_8)); spec.setStandardInput(input); spec.setClasspath(fullClasspath); cljSpec.getConfigureFork().forEach(forkAction -> forkAction.execute(spec)); spec.systemProperty("gradle-clojure.tools.logger.level", getLogLevel()); }); }
public void exec(ClojureExecSpec cljSpec) { FileCollection fullClasspath = cljSpec.getClasspath(); project.javaexec(spec -> { spec.setMain("clojure.main"); spec.args("-m", cljSpec.getMain()); String ednArgs = Edn.print(Arrays.asList(cljSpec.getArgs())); ByteArrayInputStream input = new ByteArrayInputStream(ednArgs.getBytes(StandardCharsets.UTF_8)); spec.setStandardInput(input); spec.setClasspath(fullClasspath); cljSpec.getConfigureFork().forEach(forkAction -> forkAction.execute(spec)); spec.systemProperty("gradle-clojure.tools.logger.level", getLogLevel()); }); }
private void execute(JvmTestExecutionSpec spec, TestResultProcessor resultProcessor) { execute(execSpec -> { spec.getJavaForkOptions().copyTo(execSpec); execSpec.setClasspath(project.files(spec.getClasspath())); }, resultProcessor); }
exec.setClasspath(project.files(retrolambdaConfig)); exec.setMain("net.orfjackal.retrolambda.Main"); exec.setJvmArgs(Arrays.asList(
.setClasspath(_project.files(classpathJar))
execSpec.setClasspath(classpath);
.setClasspath(spec.getGosuClasspath().call().plus(_project.files(Util.findToolsJar())))
delombok.setClasspath(getLombokClasspath()); delombok.setMain("lombok.launch.Main"); delombok.args("delombok");
@Override public void execute(JavaExecSpec spec) { getLogger().lifecycle(CONFIG_MESSAGE, getFormat(), formatPath(getBaseDir()), formatPath(getDestDir())); getLogger().info("Using main class {}", getMainClass()); Configuration configuration = getProject().getConfigurations().getAt(CONFIGURATION_NAME); String toolPath = configuration.getAsPath(); spec.setIgnoreExitValue(true); spec.setClasspath(createToolClasspath(configuration)); spec.setMain(getMainClass()); spec.args(getFormat(), getBaseDir().getAbsolutePath(), getDestDir().getAbsolutePath(), toolPath); }
/** Calls javaExec() in a way which is friendly with windows classpath limitations. */ public static ExecResult javaExec(Project project, Action<JavaExecSpec> spec) throws IOException { if (OS.getNative().isWindows()) { Box.Nullable<File> classpathJarBox = Box.Nullable.ofNull(); ExecResult execResult = project.javaexec(execSpec -> { // handle the user spec.execute(execSpec); // create a jar which embeds the classpath File classpathJar = toJarWithClasspath(execSpec.getClasspath()); classpathJar.deleteOnExit(); // set the classpath to be just that one jar execSpec.setClasspath(project.files(classpathJar)); // save the jar so it can be deleted later classpathJarBox.set(classpathJar); }); // delete the jar after the task has finished Errors.suppress().run(() -> FileMisc.forceDelete(classpathJarBox.get())); return execResult; } else { return project.javaexec(spec); } }
@Override public WorkResult execute(JavaCompileSpec javaCompileSpec) { LOGGER.info("Compiling sources using eclipse compiler for java ["+this.ecjArtifact+"]"); final List<String> remainingArguments = new JavaCompilerArgumentsBuilder(javaCompileSpec).includeSourceFiles(true).build(); ExecResult result = project.javaexec(exec -> { exec.setWorkingDir(javaCompileSpec.getWorkingDir()); exec.setClasspath(compilerConfiguration); exec.setMain("org.eclipse.jdt.internal.compiler.batch.Main"); exec.args(shortenArgs(javaCompileSpec.getTempDir(), remainingArguments)); }); if (result.getExitValue() != 0) { throw new CompilationFailedException(result.getExitValue()); } return () -> true; }
javaExecSpec.environment("CLASSPATH", classpath.getAsPath()); } else { javaExecSpec.setClasspath(classpath);