org.gradle.process.internal.JavaExecHandleBuilder Java Examples
The following examples show how to use
org.gradle.process.internal.JavaExecHandleBuilder.
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: CompilerDaemonStarter.java From pushfish-android with BSD 2-Clause "Simplified" License | 6 votes |
public CompilerDaemonClient startDaemon(File workingDir, DaemonForkOptions forkOptions) { LOG.debug("Starting Gradle compiler daemon with fork options {}.", forkOptions); Clock clock = new Clock(); WorkerProcessBuilder builder = workerFactory.create(); builder.setLogLevel(startParameter.getLogLevel()); // NOTE: might make sense to respect per-compile-task log level builder.applicationClasspath(forkOptions.getClasspath()); builder.sharedPackages(forkOptions.getSharedPackages()); JavaExecHandleBuilder javaCommand = builder.getJavaCommand(); javaCommand.setMinHeapSize(forkOptions.getMinHeapSize()); javaCommand.setMaxHeapSize(forkOptions.getMaxHeapSize()); javaCommand.setJvmArgs(forkOptions.getJvmArgs()); javaCommand.setWorkingDir(workingDir); WorkerProcess process = builder.worker(new CompilerDaemonServer()).setBaseName("Gradle Compiler Daemon").build(); process.start(); CompilerDaemonServerProtocol server = process.getConnection().addOutgoing(CompilerDaemonServerProtocol.class); CompilerDaemonClient client = new CompilerDaemonClient(forkOptions, process, server); process.getConnection().addIncoming(CompilerDaemonClientProtocol.class, client); process.getConnection().connect(); LOG.info("Started Gradle compiler daemon ({}) with fork options {}.", clock.getTime(), forkOptions); return client; }
Example #2
Source File: CompilerDaemonStarter.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 6 votes |
public CompilerDaemonClient startDaemon(File workingDir, DaemonForkOptions forkOptions) { LOG.debug("Starting Gradle compiler daemon with fork options {}.", forkOptions); Clock clock = new Clock(); WorkerProcessBuilder builder = workerFactory.create(); builder.setLogLevel(startParameter.getLogLevel()); // NOTE: might make sense to respect per-compile-task log level builder.applicationClasspath(forkOptions.getClasspath()); builder.sharedPackages(forkOptions.getSharedPackages()); JavaExecHandleBuilder javaCommand = builder.getJavaCommand(); javaCommand.setMinHeapSize(forkOptions.getMinHeapSize()); javaCommand.setMaxHeapSize(forkOptions.getMaxHeapSize()); javaCommand.setJvmArgs(forkOptions.getJvmArgs()); javaCommand.setWorkingDir(workingDir); WorkerProcess process = builder.worker(new CompilerDaemonServer()).setBaseName("Gradle Compiler Daemon").build(); process.start(); CompilerDaemonServerProtocol server = process.getConnection().addOutgoing(CompilerDaemonServerProtocol.class); CompilerDaemonClient client = new CompilerDaemonClient(forkOptions, process, server); process.getConnection().addIncoming(CompilerDaemonClientProtocol.class, client); process.getConnection().connect(); LOG.info("Started Gradle compiler daemon ({}) with fork options {}.", clock.getTime(), forkOptions); return client; }
Example #3
Source File: SonarRunner.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
JavaExecHandleBuilder prepareExec() { Map<String, Object> properties = getSonarProperties(); if (LOGGER.isInfoEnabled()) { LOGGER.info("Executing Sonar Runner with properties:\n[{}]", Joiner.on(", ").withKeyValueSeparator(": ").join(properties)); } JavaExecHandleBuilder javaExec = new JavaExecHandleBuilder(getFileResolver()); getForkOptions().copyTo(javaExec); FileCollection sonarRunnerConfiguration = getProject().getConfigurations().getAt(SonarRunnerExtension.SONAR_RUNNER_CONFIGURATION_NAME); Properties propertiesObject = new Properties(); propertiesObject.putAll(properties); File propertyFile = new File(getTemporaryDir(), "sonar-project.properties"); GUtil.saveProperties(propertiesObject, propertyFile); return javaExec .systemProperty("project.settings", propertyFile.getAbsolutePath()) // This value is set in the properties file, but Sonar Runner 2.4 requires it on the command line as well // http://forums.gradle.org/gradle/topics/gradle-2-2-nightly-sonarrunner-task-fails-with-toolversion-2-4 .systemProperty("project.home", getProject().getProjectDir().getAbsolutePath()) .setClasspath(sonarRunnerConfiguration) .setMain(MAIN_CLASS_NAME); }
Example #4
Source File: InProcessGradleExecuter.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
@Override protected GradleHandle doStart() { return new ForkingGradleHandle(getResultAssertion(), getDefaultCharacterEncoding(), new Factory<JavaExecHandleBuilder>() { public JavaExecHandleBuilder create() { JavaExecHandleBuilder builder = new JavaExecHandleBuilder(TestFiles.resolver()); builder.workingDir(getWorkingDir()); Set<File> classpath = new DefaultModuleRegistry().getFullClasspath(); builder.classpath(classpath); builder.setMain(Main.class.getName()); builder.args(getAllArgs()); return builder; } }).start(); }
Example #5
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 #6
Source File: InProcessGradleExecuter.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
@Override protected GradleHandle doStart() { return new ForkingGradleHandle(getResultAssertion(), getDefaultCharacterEncoding(), new Factory<JavaExecHandleBuilder>() { public JavaExecHandleBuilder create() { JavaExecHandleBuilder builder = new JavaExecHandleBuilder(TestFiles.resolver()); builder.workingDir(getWorkingDir()); Set<File> classpath = new DefaultModuleRegistry().getFullClasspath(); builder.classpath(classpath); builder.setMain(Main.class.getName()); builder.args(getAllArgs()); return builder; } }).start(); }
Example #7
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 #8
Source File: CompilerDaemonStarter.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
public CompilerDaemonClient startDaemon(File workingDir, DaemonForkOptions forkOptions) { LOG.debug("Starting Gradle compiler daemon with fork options {}.", forkOptions); Clock clock = new Clock(); WorkerProcessBuilder builder = workerFactory.create(); builder.setLogLevel(startParameter.getLogLevel()); // NOTE: might make sense to respect per-compile-task log level builder.applicationClasspath(forkOptions.getClasspath()); builder.sharedPackages(forkOptions.getSharedPackages()); File toolsJar = Jvm.current().getToolsJar(); if (toolsJar != null) { builder.getApplicationClasspath().add(toolsJar); // for SunJavaCompiler } JavaExecHandleBuilder javaCommand = builder.getJavaCommand(); javaCommand.setMinHeapSize(forkOptions.getMinHeapSize()); javaCommand.setMaxHeapSize(forkOptions.getMaxHeapSize()); javaCommand.setJvmArgs(forkOptions.getJvmArgs()); javaCommand.setWorkingDir(workingDir); WorkerProcess process = builder.worker(new CompilerDaemonServer()).setBaseName("Gradle Compiler Daemon").build(); process.start(); CompilerDaemonServerProtocol server = process.getConnection().addOutgoing(CompilerDaemonServerProtocol.class); CompilerDaemonClient client = new CompilerDaemonClient(forkOptions, process, server); process.getConnection().addIncoming(CompilerDaemonClientProtocol.class, client); process.getConnection().connect(); LOG.info("Started Gradle compiler daemon ({}) with fork options {}.", clock.getTime(), forkOptions); return client; }
Example #9
Source File: PlayApplicationRunner.java From playframework with Apache License 2.0 | 5 votes |
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.playframework.tools.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(); }
Example #10
Source File: SonarRunner.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
JavaExecHandleBuilder prepareExec() { Map<String, Object> properties = getSonarProperties(); if (LOGGER.isInfoEnabled()) { LOGGER.info("Executing Sonar Runner with properties:\n[{}]", Joiner.on(", ").withKeyValueSeparator(": ").join(properties)); } JavaExecHandleBuilder javaExec = new JavaExecHandleBuilder(getFileResolver()); getForkOptions().copyTo(javaExec); FileCollection sonarRunnerConfiguration = getProject().getConfigurations().getAt(SonarRunnerExtension.SONAR_RUNNER_CONFIGURATION_NAME); Properties propertiesObject = new Properties(); propertiesObject.putAll(properties); File propertyFile = new File(getTemporaryDir(), "sonar-project.properties"); GUtil.saveProperties(propertiesObject, propertyFile); return javaExec .systemProperty("project.settings", propertyFile.getAbsolutePath()) // This value is set in the properties file, but Sonar Runner 2.4 requires it on the command line as well // http://forums.gradle.org/gradle/topics/gradle-2-2-nightly-sonarrunner-task-fails-with-toolversion-2-4 .systemProperty("project.home", getProject().getProjectDir().getAbsolutePath()) .setClasspath(sonarRunnerConfiguration) .setMain(MAIN_CLASS_NAME); }
Example #11
Source File: InProcessGradleExecuter.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
@Override protected GradleHandle doStart() { return new ForkingGradleHandle(getResultAssertion(), getDefaultCharacterEncoding(), new Factory<JavaExecHandleBuilder>() { public JavaExecHandleBuilder create() { JavaExecHandleBuilder builder = new JavaExecHandleBuilder(TestFiles.resolver()); builder.workingDir(getWorkingDir()); Set<File> classpath = new DefaultModuleRegistry().getFullClasspath(); builder.classpath(classpath); builder.setMain(Main.class.getName()); builder.args(getAllArgs()); return builder; } }).start(); }
Example #12
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 #13
Source File: InProcessGradleExecuter.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
@Override protected GradleHandle doStart() { return new ForkingGradleHandle(getResultAssertion(), getDefaultCharacterEncoding(), new Factory<JavaExecHandleBuilder>() { public JavaExecHandleBuilder create() { JavaExecHandleBuilder builder = new JavaExecHandleBuilder(TestFiles.resolver()); builder.workingDir(getWorkingDir()); Set<File> classpath = new DefaultModuleRegistry().getFullClasspath(); builder.classpath(classpath); builder.setMain(Main.class.getName()); builder.args(getAllArgs()); return builder; } }).start(); }
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: CompilerDaemonStarter.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
public CompilerDaemonClient startDaemon(File workingDir, DaemonForkOptions forkOptions) { LOG.debug("Starting Gradle compiler daemon with fork options {}.", forkOptions); Clock clock = new Clock(); WorkerProcessBuilder builder = workerFactory.create(); builder.setLogLevel(startParameter.getLogLevel()); // NOTE: might make sense to respect per-compile-task log level builder.applicationClasspath(forkOptions.getClasspath()); builder.sharedPackages(forkOptions.getSharedPackages()); File toolsJar = Jvm.current().getToolsJar(); if (toolsJar != null) { builder.getApplicationClasspath().add(toolsJar); // for SunJavaCompiler } JavaExecHandleBuilder javaCommand = builder.getJavaCommand(); javaCommand.setMinHeapSize(forkOptions.getMinHeapSize()); javaCommand.setMaxHeapSize(forkOptions.getMaxHeapSize()); javaCommand.setJvmArgs(forkOptions.getJvmArgs()); javaCommand.setWorkingDir(workingDir); WorkerProcess process = builder.worker(new CompilerDaemonServer()).setBaseName("Gradle Compiler Daemon").build(); process.start(); CompilerDaemonServerProtocol server = process.getConnection().addOutgoing(CompilerDaemonServerProtocol.class); CompilerDaemonClient client = new CompilerDaemonClient(forkOptions, process, server); process.getConnection().addIncoming(CompilerDaemonClientProtocol.class, client); process.getConnection().connect(); LOG.info("Started Gradle compiler daemon ({}) with fork options {}.", clock.getTime(), forkOptions); return client; }