Java Code Examples for org.gradle.process.JavaExecSpec#setMain()

The following examples show how to use org.gradle.process.JavaExecSpec#setMain() . 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: ApplicationClassesInSystemClassLoaderWorkerFactory.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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 2
Source File: ApplicationClassesInSystemClassLoaderWorkerFactory.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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 3
Source File: GradleJavaProcessExecutor.java    From javaide with GNU General Public License v3.0 5 votes vote down vote up
@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 4
Source File: ApplicationClassesInSystemClassLoaderWorkerFactory.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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 5
Source File: ApplicationClassesInSystemClassLoaderWorkerFactory.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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 6
Source File: JjtreeExecutorAction.java    From javaccPlugin with MIT License 5 votes vote down vote up
@Override
public void execute(JavaExecSpec executor) {
    executor.classpath(classpath);
    executor.setMain("org.javacc.jjtree.Main");
    executor.args((Object[]) arguments.toArray());
    executor.setIgnoreExitValue(true);
}
 
Example 7
Source File: JjdocExecutorAction.java    From javaccPlugin with MIT License 5 votes vote down vote up
@Override
public void execute(JavaExecSpec executor) {
    executor.classpath(classpath);
    executor.setMain("org.javacc.jjdoc.JJDocMain");
    executor.args((Object[]) arguments.toArray());
    executor.setIgnoreExitValue(true);
}
 
Example 8
Source File: JavaccExecutorAction.java    From javaccPlugin with MIT License 5 votes vote down vote up
@Override
public void execute(JavaExecSpec executor) {
    executor.classpath(classpath);
    executor.setMain("org.javacc.parser.Main");
    executor.args((Object[]) arguments.toArray());
    executor.setIgnoreExitValue(true);
}
 
Example 9
Source File: RhinoExtension.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void configureJavaExec(JavaExecSpec spec) {
    spec.setMain(RHINO_SHELL_MAIN);
    spec.setClasspath(getClasspath());
}
 
Example 10
Source File: ApplicationClassesInIsolatedClassLoaderWorkerFactory.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void prepareJavaCommand(JavaExecSpec execSpec) {
    execSpec.setMain(GradleWorkerMain.class.getName());
    execSpec.classpath(classPathRegistry.getClassPath("WORKER_PROCESS").getAsFiles());
}
 
Example 11
Source File: RhinoExtension.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void configureJavaExec(JavaExecSpec spec) {
    spec.setMain(RHINO_SHELL_MAIN);
    spec.setClasspath(getClasspath());
}
 
Example 12
Source File: ApplicationClassesInIsolatedClassLoaderWorkerFactory.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void prepareJavaCommand(JavaExecSpec execSpec) {
    execSpec.setMain(GradleWorkerMain.class.getName());
    execSpec.classpath(classPathRegistry.getClassPath("WORKER_PROCESS").getAsFiles());
}
 
Example 13
Source File: RhinoExtension.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void configureJavaExec(JavaExecSpec spec) {
    spec.setMain(RHINO_SHELL_MAIN);
    spec.setClasspath(getClasspath());
}
 
Example 14
Source File: ApplicationClassesInIsolatedClassLoaderWorkerFactory.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void prepareJavaCommand(JavaExecSpec execSpec) {
    execSpec.setMain(GradleWorkerMain.class.getName());
    execSpec.classpath(classPathRegistry.getClassPath("WORKER_PROCESS").getAsFiles());
}
 
Example 15
Source File: RhinoExtension.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void configureJavaExec(JavaExecSpec spec) {
    spec.setMain(RHINO_SHELL_MAIN);
    spec.setClasspath(getClasspath());
}
 
Example 16
Source File: ApplicationClassesInIsolatedClassLoaderWorkerFactory.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void prepareJavaCommand(JavaExecSpec execSpec) {
    execSpec.setMain(GradleWorkerMain.class.getName());
    execSpec.classpath(classPathRegistry.getClassPath("WORKER_PROCESS").getAsFiles());
}