Search in sources :

Example 6 with JavaExecHandleBuilder

use of org.gradle.process.internal.JavaExecHandleBuilder in project gradle by gradle.

the class InProcessGradleExecuter method getJavaExecBuilder.

private Factory<JavaExecHandleBuilder> getJavaExecBuilder() {
    return new Factory<JavaExecHandleBuilder>() {

        public JavaExecHandleBuilder create() {
            GradleInvocation invocation = buildInvocation();
            JavaExecHandleBuilder builder = TestFiles.execFactory().newJavaExec();
            builder.workingDir(getWorkingDir());
            builder.setExecutable(new File(getJavaHome(), "bin/java"));
            Collection<File> classpath = cleanup(GLOBAL_SERVICES.get(ModuleRegistry.class).getAdditionalClassPath().getAsFiles());
            builder.classpath(classpath);
            builder.jvmArgs(invocation.launcherJvmArgs);
            builder.setMain(Main.class.getName());
            builder.args(invocation.args);
            builder.setStandardInput(connectStdIn());
            return builder;
        }
    };
}
Also used : JavaExecHandleBuilder(org.gradle.process.internal.JavaExecHandleBuilder) ModuleRegistry(org.gradle.api.internal.classpath.ModuleRegistry) BuildLayoutFactory(org.gradle.initialization.layout.BuildLayoutFactory) Factory(org.gradle.internal.Factory) File(java.io.File) TestFile(org.gradle.test.fixtures.file.TestFile) Main(org.gradle.launcher.Main)

Example 7 with JavaExecHandleBuilder

use of org.gradle.process.internal.JavaExecHandleBuilder in project gradle by gradle.

the class RunApplication method startApplication.

@TaskAction
public void startApplication() {
    DeploymentRegistry registry = getDeploymentRegistry();
    JavaApplicationHandle handle = registry.get(getPath(), JavaApplicationHandle.class);
    if (handle == null) {
        JavaExecHandleBuilder builder = getExecActionFactory().newJavaExec();
        builder.setClasspath(classpath);
        builder.setMain(mainClassName);
        builder.setArgs(arguments);
        registry.start(getPath(), changeBehavior, JavaApplicationHandle.class, builder);
    }
}
Also used : DeploymentRegistry(org.gradle.deployment.internal.DeploymentRegistry) JavaExecHandleBuilder(org.gradle.process.internal.JavaExecHandleBuilder) TaskAction(org.gradle.api.tasks.TaskAction)

Example 8 with JavaExecHandleBuilder

use of org.gradle.process.internal.JavaExecHandleBuilder in project gradle by gradle.

the class AntlrWorkerManager method createWorkerProcess.

private AntlrWorker createWorkerProcess(File workingDir, WorkerProcessFactory workerFactory, FileCollection antlrClasspath, AntlrSpec spec) {
    SingleRequestWorkerProcessBuilder<AntlrWorker> builder = workerFactory.singleRequestWorker(AntlrWorker.class, AntlrExecuter.class);
    builder.setBaseName("Gradle ANTLR Worker");
    if (antlrClasspath != null) {
        builder.applicationClasspath(antlrClasspath);
    }
    builder.sharedPackages(new String[] { "antlr", "org.antlr" });
    JavaExecHandleBuilder javaCommand = builder.getJavaCommand();
    javaCommand.setWorkingDir(workingDir);
    javaCommand.setMaxHeapSize(spec.getMaxHeapSize());
    javaCommand.systemProperty("ANTLR_DO_NOT_EXIT", "true");
    javaCommand.redirectErrorStream();
    return builder.build();
}
Also used : JavaExecHandleBuilder(org.gradle.process.internal.JavaExecHandleBuilder)

Example 9 with JavaExecHandleBuilder

use of org.gradle.process.internal.JavaExecHandleBuilder in project gradle by gradle.

the class WorkerDaemonStarter method startDaemon.

public <T extends WorkSpec> WorkerDaemonClient startDaemon(Class<? extends WorkerProtocol<ActionExecutionSpec>> workerProtocolImplementationClass, DaemonForkOptions forkOptions) {
    LOG.debug("Starting Gradle worker daemon with fork options {}.", forkOptions);
    Timer clock = Time.startTimer();
    MultiRequestWorkerProcessBuilder<WorkerDaemonProcess> builder = workerDaemonProcessFactory.multiRequestWorker(WorkerDaemonProcess.class, WorkerProtocol.class, workerProtocolImplementationClass);
    builder.setBaseName("Gradle Worker Daemon");
    // NOTE: might make sense to respect per-compile-task log level
    builder.setLogLevel(loggingManager.getLevel());
    builder.applicationClasspath(forkOptions.getClasspath());
    builder.sharedPackages(forkOptions.getSharedPackages());
    JavaExecHandleBuilder javaCommand = builder.getJavaCommand();
    forkOptions.getJavaForkOptions().copyTo(javaCommand);
    WorkerDaemonProcess workerDaemonProcess = builder.build();
    WorkerProcess workerProcess = workerDaemonProcess.start();
    WorkerDaemonClient client = new WorkerDaemonClient(forkOptions, workerDaemonProcess, workerProcess, loggingManager.getLevel());
    LOG.info("Started Gradle worker daemon ({}) with fork options {}.", clock.getElapsed(), forkOptions);
    return client;
}
Also used : WorkerProcess(org.gradle.process.internal.worker.WorkerProcess) Timer(org.gradle.internal.time.Timer) JavaExecHandleBuilder(org.gradle.process.internal.JavaExecHandleBuilder)

Aggregations

JavaExecHandleBuilder (org.gradle.process.internal.JavaExecHandleBuilder)9 Timer (org.gradle.internal.time.Timer)2 WorkerProcess (org.gradle.process.internal.worker.WorkerProcess)2 File (java.io.File)1 ModuleRegistry (org.gradle.api.internal.classpath.ModuleRegistry)1 TaskAction (org.gradle.api.tasks.TaskAction)1 DeploymentRegistry (org.gradle.deployment.internal.DeploymentRegistry)1 BuildLayoutFactory (org.gradle.initialization.layout.BuildLayoutFactory)1 Factory (org.gradle.internal.Factory)1 Address (org.gradle.internal.remote.Address)1 ConnectionAcceptor (org.gradle.internal.remote.ConnectionAcceptor)1 ObjectConnection (org.gradle.internal.remote.ObjectConnection)1 Main (org.gradle.launcher.Main)1 ExecHandle (org.gradle.process.internal.ExecHandle)1 WorkerProcessBuilder (org.gradle.process.internal.worker.WorkerProcessBuilder)1 TestFile (org.gradle.test.fixtures.file.TestFile)1