public void doCall(JavaExecSpec javaExecSpec) { javaExecSpec.setMain("org.apache.axis.wsdl.WSDL2Java") .args(arguments) .setClasspath(getProject().getConfigurations().getByName("compile")); } });
@Override public void execute(JavaExecSpec javaExecSpec) { javaExecSpec.classpath(new File(javaProcessInfo.getClasspath())); javaExecSpec.setMain(javaProcessInfo.getMainClass()); javaExecSpec.args(javaProcessInfo.getArgs()); javaExecSpec.jvmArgs(javaProcessInfo.getJvmArgs()); javaExecSpec.environment(javaProcessInfo.getEnvironment()); javaExecSpec.setStandardOutput(processOutput.getStandardOutput()); javaExecSpec.setErrorOutput(processOutput.getErrorOutput()); // we run by default in headless mode, so the forked JVM doesn't steal focus. javaExecSpec.systemProperty("java.awt.headless", "true"); // we want the caller to be able to do its own thing. javaExecSpec.setIgnoreExitValue(true); } }
@Override public void execute(JavaExecSpec exec) { exec.classpath(forkedClasspath); exec.setMain(FernFlowerInvoker.class.getName()); exec.setJvmArgs(ImmutableList.of("-Xmx3G")); // pass the temporary file exec.args(data); // Forward std streams exec.setStandardOutput(System.out); exec.setErrorOutput(System.err); } });
@Override public void execute(JavaExecSpec executor) { executor.classpath(classpath); executor.setMain("org.javacc.jjdoc.JJDocMain"); executor.args((Object[]) arguments.toArray()); executor.setIgnoreExitValue(true); } }
@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); } }
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()); }); }
javaExecSpec.setWorkingDir((Object) _project.getProjectDir()); // Gradle 4.0 overloads ProcessForkOptions#setWorkingDir; must upcast to Object for backwards compatibility setJvmArgs(javaExecSpec, _options.getForkOptions()); javaExecSpec.setMain("gw.gosudoc.cli.Gosudoc") .setClasspath(_project.files(classpathJar)) .setArgs((Iterable<?>) gosudocArgs); // Gradle 4.0 overloads JavaExecSpec#setArgs; must upcast to Iterable<?> for backwards compatibility javaExecSpec.setStandardOutput(stdout); javaExecSpec.setErrorOutput(stderr); javaExecSpec.setIgnoreExitValue(true); //otherwise fails immediately before displaying output });
javaExecSpec.setMain(main); javaExecSpec.setDebug(isDebug()); javaExecSpec.setMinHeapSize(getMinHeapSize()); javaExecSpec.setMaxHeapSize(getMaxHeapSize()); javaExecSpec.environment("CLASSPATH", classpath.getAsPath()); } else { javaExecSpec.setClasspath(classpath); javaExecSpec.jvmArgs(jvmArgs); javaExecSpec.args(args); javaExecSpec.args(getModules());
@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); }
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); } }); }
@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; }
private void execute(Action<JavaExecSpec> execSpecAction, TestResultProcessor resultProcessor) { Object rootTestId = "eta-test-root"; Object testId = "eta-test"; resultProcessor.started (new DefaultTestSuiteDescriptor(rootTestId, "Eta Root"), new TestStartEvent(System.currentTimeMillis())); resultProcessor.started (new DefaultTestDescriptor(testId, "eta.main", "Default Eta Test"), new TestStartEvent(System.currentTimeMillis())); ExecResult execResult = project.javaexec(execSpec -> { execSpecAction.execute(execSpec); execSpec.setMain("eta.main"); }); ResultType resultType = (execResult.getExitValue() == 0)? ResultType.SUCCESS : ResultType.FAILURE; resultProcessor.completed (testId, new TestCompleteEvent(System.currentTimeMillis(), resultType)); resultProcessor.completed (rootTestId, new TestCompleteEvent(System.currentTimeMillis(), resultType)); } }
private void execute(Test test, TestResultProcessor resultProcessor) { execute(execSpec -> { test.copyTo(execSpec); execSpec.setClasspath(test.getClasspath()); }, resultProcessor); }
/** 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); } }
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()); }); }
@Override public void execute(JavaExecSpec executor) { executor.classpath(classpath); executor.setMain("org.javacc.jjtree.Main"); executor.args((Object[]) arguments.toArray()); executor.setIgnoreExitValue(true); } }
javaExecSpec.setWorkingDir((Object) _project.getProjectDir()); // Gradle 4.0 overloads ProcessForkOptions#setWorkingDir; must upcast to Object for backwards compatibility setJvmArgs(javaExecSpec, _spec.getGosuCompileOptions().getForkOptions()); javaExecSpec.setMain("gw.lang.gosuc.cli.CommandLineCompiler") .setClasspath(spec.getGosuClasspath().call().plus(_project.files(Util.findToolsJar()))) .setArgs((Iterable<?>) gosucArgs); // Gradle 4.0 overloads JavaExecSpec#setArgs; must upcast to Iterable<?> for backwards compatibility javaExecSpec.setStandardOutput(stdout); javaExecSpec.setErrorOutput(stderr); javaExecSpec.setIgnoreExitValue(true); //otherwise fails immediately before displaying output });
exec.setClasspath(project.files(retrolambdaConfig)); exec.setMain("net.orfjackal.retrolambda.Main"); exec.setJvmArgs(Arrays.asList( "-Dretrolambda.inputDir=" + inputDir, "-Dretrolambda.outputDir=" + outputDir, boolean requiresJavaAgent = !requireVersion(retrolambdaVersion, "1.6.0", false); if (requiresJavaAgent) { exec.getJvmArgs().add("-javaagent:" + exec.getClasspath().getAsPath()); exec.getJvmArgs().add("-Dretrolambda.classpathFile=" + classpathFile.getAbsolutePath()); } catch (IOException e) { exec.getJvmArgs().add("-Dretrolambda.classpath=" + path); exec.getJvmArgs().add("-Dretrolambda.includedFilesFile=" + includedFile.getAbsolutePath()); } catch (IOException e) { String includedArg = includedFiles.getFiles().stream().map(f -> f.toString()) .collect(Collectors.joining(File.pathSeparator)); exec.getJvmArgs().add(includedArg); project.getLogger().quiet(includedArg); exec.getJvmArgs().add("-Dretrolambda.defaultMethods=true"); exec.getJvmArgs().add(arg);
private void execute(JvmTestExecutionSpec spec, TestResultProcessor resultProcessor) { execute(execSpec -> { spec.getJavaForkOptions().copyTo(execSpec); execSpec.setClasspath(project.files(spec.getClasspath())); }, resultProcessor); }
execSpec.setMain(JavaExecable.class.getName()); execSpec.args(tempFile.getAbsolutePath()); execSpec.setClasspath(classpath);