Search in sources :

Example 1 with JavaExecHandleBuilder

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

the class DefaultWorkerProcessBuilder method build.

@Override
public WorkerProcess build() {
    final WorkerJvmMemoryStatus memoryStatus = shouldPublishJvmMemoryInfo ? new WorkerJvmMemoryStatus() : null;
    final DefaultWorkerProcess workerProcess = new DefaultWorkerProcess(connectTimeoutSeconds, TimeUnit.SECONDS, memoryStatus);
    ConnectionAcceptor acceptor = server.accept(new Action<ObjectConnection>() {

        public void execute(final ObjectConnection connection) {
            workerProcess.onConnect(connection, new Runnable() {

                @Override
                public void run() {
                    DefaultWorkerLoggingProtocol defaultWorkerLoggingProtocol = new DefaultWorkerLoggingProtocol(outputEventListener);
                    connection.useParameterSerializers(WorkerLoggingSerializer.create());
                    connection.addIncoming(WorkerLoggingProtocol.class, defaultWorkerLoggingProtocol);
                    if (shouldPublishJvmMemoryInfo) {
                        connection.useParameterSerializers(WorkerJvmMemoryInfoSerializer.create());
                        connection.addIncoming(WorkerJvmMemoryInfoProtocol.class, memoryStatus);
                    }
                }
            });
        }
    });
    workerProcess.startAccepting(acceptor);
    Address localAddress = acceptor.getAddress();
    // Build configuration for GradleWorkerMain
    Object id = idGenerator.generateId();
    String displayName = getBaseName() + " " + id;
    LOGGER.debug("Creating {}", displayName);
    LOGGER.debug("Using application classpath {}", applicationClasspath);
    LOGGER.debug("Using implementation classpath {}", implementationClassPath);
    JavaExecHandleBuilder javaCommand = getJavaCommand();
    javaCommand.setDisplayName(displayName);
    workerImplementationFactory.prepareJavaCommand(id, displayName, this, implementationClassPath, localAddress, javaCommand, shouldPublishJvmMemoryInfo);
    javaCommand.args("'" + displayName + "'");
    ExecHandle execHandle = javaCommand.build();
    workerProcess.setExecHandle(execHandle);
    return new MemoryRequestingWorkerProcess(workerProcess, memoryManager, MemoryAmount.parseNotation(javaCommand.getMinHeapSize()));
}
Also used : ConnectionAcceptor(org.gradle.internal.remote.ConnectionAcceptor) Address(org.gradle.internal.remote.Address) JavaExecHandleBuilder(org.gradle.process.internal.JavaExecHandleBuilder) ObjectConnection(org.gradle.internal.remote.ObjectConnection) ExecHandle(org.gradle.process.internal.ExecHandle)

Example 2 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 = new JavaExecHandleBuilder(TestFiles.resolver());
            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) Factory(org.gradle.internal.Factory) File(java.io.File) TestFile(org.gradle.test.fixtures.file.TestFile) Main(org.gradle.launcher.Main)

Example 3 with JavaExecHandleBuilder

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

the class FindBugsWorkerManager method createWorkerProcess.

private FindBugsWorker createWorkerProcess(File workingDir, WorkerProcessFactory workerFactory, FileCollection findBugsClasspath, FindBugsSpec spec) {
    SingleRequestWorkerProcessBuilder<FindBugsWorker> builder = workerFactory.singleRequestWorker(FindBugsWorker.class, FindBugsExecuter.class);
    builder.setBaseName("Gradle FindBugs Worker");
    builder.applicationClasspath(findBugsClasspath);
    builder.sharedPackages(Arrays.asList("edu.umd.cs.findbugs"));
    JavaExecHandleBuilder javaCommand = builder.getJavaCommand();
    javaCommand.setWorkingDir(workingDir);
    javaCommand.setMaxHeapSize(spec.getMaxHeapSize());
    return builder.build();
}
Also used : JavaExecHandleBuilder(org.gradle.process.internal.JavaExecHandleBuilder)

Example 4 with JavaExecHandleBuilder

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

the class DefaultRhinoWorkerHandleFactory method create.

@Override
public <T> T create(Iterable<File> rhinoClasspath, Class<T> protocolType, Class<? extends T> workerImplementationType, LogLevel logLevel, File workingDir) {
    SingleRequestWorkerProcessBuilder<T> builder = workerProcessBuilderFactory.singleRequestWorker(protocolType, workerImplementationType);
    builder.setBaseName("Gradle Rhino Worker");
    builder.setLogLevel(logLevel);
    builder.applicationClasspath(rhinoClasspath);
    builder.sharedPackages("org.mozilla.javascript");
    JavaExecHandleBuilder javaCommand = builder.getJavaCommand();
    javaCommand.setWorkingDir(workingDir);
    return builder.build();
}
Also used : JavaExecHandleBuilder(org.gradle.process.internal.JavaExecHandleBuilder)

Example 5 with JavaExecHandleBuilder

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

the class PlayApplicationRunner method createWorkerProcess.

private static WorkerProcess createWorkerProcess(File workingDir, WorkerProcessFactory workerFactory, PlayRunSpec spec, VersionedPlayRunAdapter adapter) {
    WorkerProcessBuilder builder = workerFactory.create(new PlayWorkerServer(spec, adapter));
    builder.setBaseName("Gradle Play Worker");
    builder.sharedPackages("org.gradle.play.internal.run");
    JavaExecHandleBuilder javaCommand = builder.getJavaCommand();
    javaCommand.setWorkingDir(workingDir);
    javaCommand.setMinHeapSize(spec.getForkOptions().getMemoryInitialSize());
    javaCommand.setMaxHeapSize(spec.getForkOptions().getMemoryMaximumSize());
    javaCommand.setJvmArgs(spec.getForkOptions().getJvmArgs());
    return builder.build();
}
Also used : JavaExecHandleBuilder(org.gradle.process.internal.JavaExecHandleBuilder) WorkerProcessBuilder(org.gradle.process.internal.worker.WorkerProcessBuilder)

Aggregations

JavaExecHandleBuilder (org.gradle.process.internal.JavaExecHandleBuilder)7 File (java.io.File)1 ModuleRegistry (org.gradle.api.internal.classpath.ModuleRegistry)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 Timer (org.gradle.internal.time.Timer)1 Main (org.gradle.launcher.Main)1 ExecHandle (org.gradle.process.internal.ExecHandle)1 WorkerProcess (org.gradle.process.internal.worker.WorkerProcess)1 WorkerProcessBuilder (org.gradle.process.internal.worker.WorkerProcessBuilder)1 TestFile (org.gradle.test.fixtures.file.TestFile)1