org.gradle.process.JavaExecSpec Java Examples
The following examples show how to use
org.gradle.process.JavaExecSpec.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EnvJsBrowserEvaluator.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
public void evaluate(String url, Writer writer) { RhinoWorkerHandle<String, EnvJsEvaluateSpec> handle = rhinoWorkerHandleFactory.create(rhinoClasspath, createWorkerSpec(), logLevel, new Action<JavaExecSpec>() { public void execute(JavaExecSpec javaExecSpec) { javaExecSpec.setWorkingDir(workingDir); } }); final String result = handle.process(new EnvJsEvaluateSpec(envJsFactory.create(), url)); try { IOUtils.copy(new StringReader(result), writer); } catch (IOException e) { throw new UncheckedIOException(e); } }
Example #2
Source File: JjtreeExecutorAction.java From javaccPlugin with MIT License | 5 votes |
@Override public void execute(JavaExecSpec executor) { executor.classpath(classpath); executor.setMain("org.javacc.jjtree.Main"); executor.args((Object[]) arguments.toArray()); executor.setIgnoreExitValue(true); }
Example #3
Source File: EnvJsBrowserEvaluator.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
public void evaluate(String url, Writer writer) { RhinoWorkerHandle<String, EnvJsEvaluateSpec> handle = rhinoWorkerHandleFactory.create(rhinoClasspath, createWorkerSpec(), logLevel, new Action<JavaExecSpec>() { public void execute(JavaExecSpec javaExecSpec) { javaExecSpec.setWorkingDir(workingDir); } }); final String result = handle.process(new EnvJsEvaluateSpec(envJsFactory.create(), url)); try { IOUtils.copy(new StringReader(result), writer); } catch (IOException e) { throw new UncheckedIOException(e); } }
Example #4
Source File: RhinoCoffeeScriptCompiler.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
public WorkResult compile(CoffeeScriptCompileSpec spec) { RhinoWorkerHandle<Boolean, SerializableCoffeeScriptCompileSpec> handle = rhinoWorkerHandleFactory.create(rhinoClasspath, createWorkerSpec(), logLevel, new Action<JavaExecSpec>() { public void execute(JavaExecSpec javaExecSpec) { javaExecSpec.setWorkingDir(workingDir); } }); final Boolean result = handle.process(new SerializableCoffeeScriptCompileSpec(spec)); return new WorkResult() { public boolean getDidWork() { return result; } }; }
Example #5
Source File: JjdocExecutorActionTest.java From javaccPlugin with MIT License | 5 votes |
@Before public void setUp() throws Exception { javaExecSpec = mock(JavaExecSpec.class); providedClasspath = mock(Configuration.class); providedArguments = new ProgramArguments(); action = new JjdocExecutorAction(providedClasspath, providedArguments); }
Example #6
Source File: ApplicationClassesInSystemClassLoaderWorkerFactory.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
public void prepareJavaCommand(JavaExecSpec execSpec) { execSpec.setMain("jarjar." + GradleWorkerMain.class.getName()); execSpec.classpath(classPathRegistry.getClassPath("WORKER_MAIN").getAsFiles()); Object requestedSecurityManager = execSpec.getSystemProperties().get("java.security.manager"); if (requestedSecurityManager != null) { execSpec.systemProperty("org.gradle.security.manager", requestedSecurityManager); } execSpec.systemProperty("java.security.manager", "jarjar." + BootstrapSecurityManager.class.getName()); try { ByteArrayOutputStream bytes = new ByteArrayOutputStream(); DataOutputStream outstr = new DataOutputStream(new EncodedStream.EncodedOutput(bytes)); LOGGER.debug("Writing an application classpath to child process' standard input."); outstr.writeInt(processBuilder.getApplicationClasspath().size()); for (File file : processBuilder.getApplicationClasspath()) { outstr.writeUTF(file.getAbsolutePath()); } outstr.close(); final InputStream originalStdin = execSpec.getStandardInput(); InputStream input = ByteStreams.join(ByteStreams.newInputStreamSupplier(bytes.toByteArray()), new InputSupplier<InputStream>() { public InputStream getInput() throws IOException { return originalStdin; } }).getInput(); execSpec.setStandardInput(input); } catch (IOException e) { throw new UncheckedIOException(e); } }
Example #7
Source File: JavaccExecutorActionTest.java From javaccPlugin with MIT License | 5 votes |
@Before public void setUp() throws Exception { javaExecSpec = mock(JavaExecSpec.class); providedClasspath = mock(Configuration.class); providedArguments = new ProgramArguments(); action = new JavaccExecutorAction(providedClasspath, providedArguments); }
Example #8
Source File: JjdocExecutorAction.java From javaccPlugin with MIT License | 5 votes |
@Override public void execute(JavaExecSpec executor) { executor.classpath(classpath); executor.setMain("org.javacc.jjdoc.JJDocMain"); executor.args((Object[]) arguments.toArray()); executor.setIgnoreExitValue(true); }
Example #9
Source File: JavaccExecutorAction.java From javaccPlugin with MIT License | 5 votes |
@Override public void execute(JavaExecSpec executor) { executor.classpath(classpath); executor.setMain("org.javacc.parser.Main"); executor.args((Object[]) arguments.toArray()); executor.setIgnoreExitValue(true); }
Example #10
Source File: JjtreeExecutorActionTest.java From javaccPlugin with MIT License | 5 votes |
@Before public void setUp() throws Exception { javaExecSpec = mock(JavaExecSpec.class); providedClasspath = mock(Configuration.class); providedArguments = new ProgramArguments(); action = new JjtreeExecutorAction(providedClasspath, providedArguments); }
Example #11
Source File: RhinoCoffeeScriptCompiler.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
public WorkResult compile(CoffeeScriptCompileSpec spec) { RhinoWorkerHandle<Boolean, SerializableCoffeeScriptCompileSpec> handle = rhinoWorkerHandleFactory.create(rhinoClasspath, createWorkerSpec(), logLevel, new Action<JavaExecSpec>() { public void execute(JavaExecSpec javaExecSpec) { javaExecSpec.setWorkingDir(workingDir); } }); final Boolean result = handle.process(new SerializableCoffeeScriptCompileSpec(spec)); return new WorkResult() { public boolean getDidWork() { return result; } }; }
Example #12
Source File: ApplicationClassesInSystemClassLoaderWorkerFactory.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
public void prepareJavaCommand(JavaExecSpec execSpec) { execSpec.setMain("jarjar." + GradleWorkerMain.class.getName()); execSpec.classpath(classPathRegistry.getClassPath("WORKER_MAIN").getAsFiles()); Object requestedSecurityManager = execSpec.getSystemProperties().get("java.security.manager"); if (requestedSecurityManager != null) { execSpec.systemProperty("org.gradle.security.manager", requestedSecurityManager); } execSpec.systemProperty("java.security.manager", "jarjar." + BootstrapSecurityManager.class.getName()); try { ByteArrayOutputStream bytes = new ByteArrayOutputStream(); DataOutputStream outstr = new DataOutputStream(new EncodedStream.EncodedOutput(bytes)); LOGGER.debug("Writing an application classpath to child process' standard input."); outstr.writeInt(processBuilder.getApplicationClasspath().size()); for (File file : processBuilder.getApplicationClasspath()) { outstr.writeUTF(file.getAbsolutePath()); } outstr.close(); final InputStream originalStdin = execSpec.getStandardInput(); InputStream input = ByteStreams.join(ByteStreams.newInputStreamSupplier(bytes.toByteArray()), new InputSupplier<InputStream>() { public InputStream getInput() throws IOException { return originalStdin; } }).getInput(); execSpec.setStandardInput(input); } catch (IOException e) { throw new UncheckedIOException(e); } }
Example #13
Source File: DefaultRhinoWorkerHandleFactory.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
public <R extends Serializable, P extends Serializable> RhinoWorkerHandle<R, P> create(Iterable<File> rhinoClasspath, RhinoWorkerSpec<R, P> workerSpec, LogLevel logLevel, Action<JavaExecSpec> javaExecSpecAction) { WorkerProcessBuilder builder = workerProcessBuilderFactory.create(); builder.setBaseName("Gradle Rhino Worker"); builder.setLogLevel(logLevel); builder.applicationClasspath(rhinoClasspath); builder.sharedPackages("org.mozilla.javascript"); JavaExecHandleBuilder javaCommand = builder.getJavaCommand(); if (javaExecSpecAction != null) { javaExecSpecAction.execute(javaCommand); } WorkerProcess workerProcess = builder.worker(new RhinoServer<R, P>(workerSpec)).build(); return new DefaultRhinoWorkerHandle<R, P>(workerSpec.getResultType(), workerProcess); }
Example #14
Source File: DefaultRhinoWorkerHandleFactory.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
public <R extends Serializable, P extends Serializable> RhinoWorkerHandle<R, P> create(Iterable<File> rhinoClasspath, RhinoWorkerSpec<R, P> workerSpec, LogLevel logLevel, Action<JavaExecSpec> javaExecSpecAction) { WorkerProcessBuilder builder = workerProcessBuilderFactory.create(); builder.setBaseName("Gradle Rhino Worker"); builder.setLogLevel(logLevel); builder.applicationClasspath(rhinoClasspath); builder.sharedPackages("org.mozilla.javascript"); JavaExecHandleBuilder javaCommand = builder.getJavaCommand(); if (javaExecSpecAction != null) { javaExecSpecAction.execute(javaCommand); } WorkerProcess workerProcess = builder.worker(new RhinoServer<R, P>(workerSpec)).build(); return new DefaultRhinoWorkerHandle<R, P>(workerSpec.getResultType(), workerProcess); }
Example #15
Source File: EnvJsBrowserEvaluator.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
public void evaluate(String url, Writer writer) { RhinoWorkerHandle<String, EnvJsEvaluateSpec> handle = rhinoWorkerHandleFactory.create(rhinoClasspath, createWorkerSpec(), logLevel, new Action<JavaExecSpec>() { public void execute(JavaExecSpec javaExecSpec) { javaExecSpec.setWorkingDir(workingDir); } }); final String result = handle.process(new EnvJsEvaluateSpec(envJsFactory.create(), url)); try { IOUtils.copy(new StringReader(result), writer); } catch (IOException e) { throw new UncheckedIOException(e); } }
Example #16
Source File: RhinoCoffeeScriptCompiler.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
public WorkResult compile(CoffeeScriptCompileSpec spec) { RhinoWorkerHandle<Boolean, SerializableCoffeeScriptCompileSpec> handle = rhinoWorkerHandleFactory.create(rhinoClasspath, createWorkerSpec(), logLevel, new Action<JavaExecSpec>() { public void execute(JavaExecSpec javaExecSpec) { javaExecSpec.setWorkingDir(workingDir); } }); final Boolean result = handle.process(new SerializableCoffeeScriptCompileSpec(spec)); return new WorkResult() { public boolean getDidWork() { return result; } }; }
Example #17
Source File: ApplicationClassesInSystemClassLoaderWorkerFactory.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
public void prepareJavaCommand(JavaExecSpec execSpec) { execSpec.setMain("jarjar." + GradleWorkerMain.class.getName()); execSpec.classpath(classPathRegistry.getClassPath("WORKER_MAIN").getAsFiles()); Object requestedSecurityManager = execSpec.getSystemProperties().get("java.security.manager"); if (requestedSecurityManager != null) { execSpec.systemProperty("org.gradle.security.manager", requestedSecurityManager); } execSpec.systemProperty("java.security.manager", "jarjar." + BootstrapSecurityManager.class.getName()); try { ByteArrayOutputStream bytes = new ByteArrayOutputStream(); DataOutputStream outstr = new DataOutputStream(new EncodedStream.EncodedOutput(bytes)); LOGGER.debug("Writing an application classpath to child process' standard input."); outstr.writeInt(processBuilder.getApplicationClasspath().size()); for (File file : processBuilder.getApplicationClasspath()) { outstr.writeUTF(file.getAbsolutePath()); } outstr.close(); final InputStream originalStdin = execSpec.getStandardInput(); InputStream input = ByteStreams.join(ByteStreams.newInputStreamSupplier(bytes.toByteArray()), new InputSupplier<InputStream>() { public InputStream getInput() throws IOException { return originalStdin; } }).getInput(); execSpec.setStandardInput(input); } catch (IOException e) { throw new UncheckedIOException(e); } }
Example #18
Source File: ApplicationClassesInSystemClassLoaderWorkerFactory.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
public void prepareJavaCommand(JavaExecSpec execSpec) { execSpec.setMain("jarjar." + GradleWorkerMain.class.getName()); execSpec.classpath(classPathRegistry.getClassPath("WORKER_MAIN").getAsFiles()); Object requestedSecurityManager = execSpec.getSystemProperties().get("java.security.manager"); if (requestedSecurityManager != null) { execSpec.systemProperty("org.gradle.security.manager", requestedSecurityManager); } execSpec.systemProperty("java.security.manager", "jarjar." + BootstrapSecurityManager.class.getName()); try { ByteArrayOutputStream bytes = new ByteArrayOutputStream(); DataOutputStream outstr = new DataOutputStream(new EncodedStream.EncodedOutput(bytes)); LOGGER.debug("Writing an application classpath to child process' standard input."); outstr.writeInt(processBuilder.getApplicationClasspath().size()); for (File file : processBuilder.getApplicationClasspath()) { outstr.writeUTF(file.getAbsolutePath()); } outstr.close(); final InputStream originalStdin = execSpec.getStandardInput(); InputStream input = ByteStreams.join(ByteStreams.newInputStreamSupplier(bytes.toByteArray()), new InputSupplier<InputStream>() { public InputStream getInput() throws IOException { return originalStdin; } }).getInput(); execSpec.setStandardInput(input); } catch (IOException e) { throw new UncheckedIOException(e); } }
Example #19
Source File: GradleJavaProcessExecutor.java From javaide with GNU General Public License v3.0 | 5 votes |
@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 want the caller to be able to do its own thing. javaExecSpec.setIgnoreExitValue(true); }
Example #20
Source File: DefaultRhinoWorkerHandleFactory.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
public <R extends Serializable, P extends Serializable> RhinoWorkerHandle<R, P> create(Iterable<File> rhinoClasspath, RhinoWorkerSpec<R, P> workerSpec, LogLevel logLevel, Action<JavaExecSpec> javaExecSpecAction) { WorkerProcessBuilder builder = workerProcessBuilderFactory.create(); builder.setBaseName("Gradle Rhino Worker"); builder.setLogLevel(logLevel); builder.applicationClasspath(rhinoClasspath); builder.sharedPackages("org.mozilla.javascript"); JavaExecHandleBuilder javaCommand = builder.getJavaCommand(); if (javaExecSpecAction != null) { javaExecSpecAction.execute(javaCommand); } WorkerProcess workerProcess = builder.worker(new RhinoServer<R, P>(workerSpec)).build(); return new DefaultRhinoWorkerHandle<R, P>(workerSpec.getResultType(), workerProcess); }
Example #21
Source File: DefaultRhinoWorkerHandleFactory.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
public <R extends Serializable, P extends Serializable> RhinoWorkerHandle<R, P> create(Iterable<File> rhinoClasspath, RhinoWorkerSpec<R, P> workerSpec, LogLevel logLevel, Action<JavaExecSpec> javaExecSpecAction) { WorkerProcessBuilder builder = workerProcessBuilderFactory.create(); builder.setBaseName("Gradle Rhino Worker"); builder.setLogLevel(logLevel); builder.applicationClasspath(rhinoClasspath); builder.sharedPackages("org.mozilla.javascript"); JavaExecHandleBuilder javaCommand = builder.getJavaCommand(); if (javaExecSpecAction != null) { javaExecSpecAction.execute(javaCommand); } WorkerProcess workerProcess = builder.worker(new RhinoServer<R, P>(workerSpec)).build(); return new DefaultRhinoWorkerHandle<R, P>(workerSpec.getResultType(), workerProcess); }
Example #22
Source File: EnvJsBrowserEvaluator.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
public void evaluate(String url, Writer writer) { RhinoWorkerHandle<String, EnvJsEvaluateSpec> handle = rhinoWorkerHandleFactory.create(rhinoClasspath, createWorkerSpec(), logLevel, new Action<JavaExecSpec>() { public void execute(JavaExecSpec javaExecSpec) { javaExecSpec.setWorkingDir(workingDir); } }); final String result = handle.process(new EnvJsEvaluateSpec(envJsFactory.create(), url)); try { IOUtils.copy(new StringReader(result), writer); } catch (IOException e) { throw new UncheckedIOException(e); } }
Example #23
Source File: RhinoCoffeeScriptCompiler.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
public WorkResult compile(CoffeeScriptCompileSpec spec) { RhinoWorkerHandle<Boolean, SerializableCoffeeScriptCompileSpec> handle = rhinoWorkerHandleFactory.create(rhinoClasspath, createWorkerSpec(), logLevel, new Action<JavaExecSpec>() { public void execute(JavaExecSpec javaExecSpec) { javaExecSpec.setWorkingDir(workingDir); } }); final Boolean result = handle.process(new SerializableCoffeeScriptCompileSpec(spec)); return new WorkResult() { public boolean getDidWork() { return result; } }; }
Example #24
Source File: ApplicationClassesInIsolatedClassLoaderWorkerFactory.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 4 votes |
public void prepareJavaCommand(JavaExecSpec execSpec) { execSpec.setMain(GradleWorkerMain.class.getName()); execSpec.classpath(classPathRegistry.getClassPath("WORKER_PROCESS").getAsFiles()); }
Example #25
Source File: JavaExecHandleBuilder.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 4 votes |
@Override public JavaExecSpec setIgnoreExitValue(boolean ignoreExitValue) { super.setIgnoreExitValue(ignoreExitValue); return this; }
Example #26
Source File: DefaultFileOperations.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 4 votes |
public ExecResult javaexec(Action<? super JavaExecSpec> action) { JavaExecAction javaExecAction = instantiator.newInstance(DefaultJavaExecAction.class, fileResolver); action.execute(javaExecAction); return javaExecAction.execute(); }
Example #27
Source File: AbstractProject.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 4 votes |
public ExecResult javaexec(Action<? super JavaExecSpec> action) { return getProcessOperations().javaexec(action); }
Example #28
Source File: JsHint.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 4 votes |
@TaskAction public void doJsHint() { RhinoWorkerHandleFactory handleFactory = new DefaultRhinoWorkerHandleFactory(getWorkerProcessBuilderFactory()); LogLevel logLevel = getProject().getGradle().getStartParameter().getLogLevel(); RhinoWorkerHandle<JsHintResult, JsHintSpec> rhinoHandle = handleFactory.create(getRhinoClasspath(), createWorkerSpec(), logLevel, new Action<JavaExecSpec>() { public void execute(JavaExecSpec javaExecSpec) { javaExecSpec.setWorkingDir(getProject().getProjectDir()); } }); JsHintSpec spec = new JsHintSpec(); spec.setSource(getSource().getFiles()); // flatten because we need to serialize spec.setEncoding(getEncoding()); spec.setJsHint(getJsHint().getSingleFile()); JsHintResult result = rhinoHandle.process(spec); setDidWork(true); // TODO - this is all terribly lame. We need some proper reporting here (which means implementing Reporting). Logger logger = getLogger(); boolean anyErrors = false; Map<String, Map<?, ?>> reportData = new LinkedHashMap<String, Map<?, ?>>(result.getResults().size()); for (Map.Entry<File, Map<String, Object>> fileEntry: result.getResults().entrySet()) { File file = fileEntry.getKey(); Map<String, Object> data = fileEntry.getValue(); reportData.put(file.getAbsolutePath(), data); if (data.containsKey("errors")) { anyErrors = true; URI projectDirUri = getProject().getProjectDir().toURI(); @SuppressWarnings("unchecked") Map<String, Object> errors = (Map<String, Object>) data.get("errors"); if (!errors.isEmpty()) { URI relativePath = projectDirUri.relativize(file.toURI()); logger.warn("JsHint errors for file: {}", relativePath.getPath()); for (Map.Entry<String, Object> errorEntry : errors.entrySet()) { @SuppressWarnings("unchecked") Map<String, Object> error = (Map<String, Object>) errorEntry.getValue(); int line = Float.valueOf(error.get("line").toString()).intValue(); int character = Float.valueOf(error.get("character").toString()).intValue(); String reason = error.get("reason").toString(); logger.warn(" {}:{} > {}", new Object[] {line, character, reason}); } } } } File jsonReportFile = getJsonReport(); if (jsonReportFile != null) { try { FileWriter reportWriter = new FileWriter(jsonReportFile); new GsonBuilder().setPrettyPrinting().create().toJson(reportData, reportWriter); reportWriter.close(); } catch (IOException e) { throw new UncheckedIOException(e); } } if (anyErrors) { throw new TaskExecutionException(this, new GradleException("JsHint detected errors")); } }
Example #29
Source File: JavaExec.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 4 votes |
/** * {@inheritDoc} */ public JavaExecSpec setIgnoreExitValue(boolean ignoreExitValue) { javaExecHandleBuilder.setIgnoreExitValue(ignoreExitValue); return this; }
Example #30
Source File: AbstractProject.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 4 votes |
public ExecResult javaexec(Closure closure) { return javaexec(new ClosureBackedAction<JavaExecSpec>(closure)); }