[GRADLE-2687] Tooling API: Allow to completely suppress stdout and stderr Created: 21/Feb/13  Updated: 08/Feb/17  Resolved: 08/Feb/17

Status: Resolved
Project: Gradle
Affects Version/s: 1.4
Fix Version/s: None

Type: Improvement
Reporter: Denis Zhdanov Assignee: Radim Kubacki
Resolution: Fixed Votes: 30


 Description   

The tooling api already provides ability to define custom stdout and stderr. However, it seems that that doesn't redirect all output to the provided streams. Consider the simple example below:

java client
package org;

import org.gradle.tooling.GradleConnector;
import org.gradle.tooling.ModelBuilder;
import org.gradle.tooling.ProjectConnection;
import org.gradle.tooling.model.idea.IdeaProject;

import java.io.File;
import java.io.IOException;
import java.io.OutputStream;

public class TestClient {

  private static final String PROJECT_PATH = "/home/denis/dev/gradle/gradle-1.4/samples/java/multiproject";

  public static void main(String[] args) throws InterruptedException {
    GradleConnector connector = GradleConnector.newConnector();
    connector.forProjectDirectory(new File(PROJECT_PATH));
    ProjectConnection connection = connector.connect();
    ModelBuilder<IdeaProject> modelBuilder = connection.model(IdeaProject.class);
    OutputStream dummy = new OutputStream() {
      @Override
      public void write(int b) throws IOException {
      }
    };
    modelBuilder.setStandardOutput(dummy);
    modelBuilder.setStandardError(dummy);
    modelBuilder.get();
    connection.close();
  }
}

It defines instructs the tooling api to use empty stdout and stderr but the application produces the following output:

21:55:13.285 [Connection worker] DEBUG o.g.t.i.provider.DefaultConnection - Provider implementation created.
21:55:13.346 [Connection worker] DEBUG o.g.t.i.provider.DefaultConnection - Embedded executer support created.
21:55:13.353 [Connection worker] DEBUG o.g.t.i.provider.DefaultConnection - Configuring logging to level: INFO
Tooling API uses target gradle version: 1.4.
Starting Gradle daemon
Starting daemon process: workingDir = /home/denis/.gradle/daemon/1.4, daemonArgs: [/home/denis/dev/jdk/jdk1.7.0_13/bin/java, -XX:MaxPermSize=256m, -XX:+HeapDumpOnOutOfMemoryError, -Xmx1024m, -Dfile.encoding=UTF-8, -cp, /home/denis/.gradle/wrapper/dists/gradle-1.4-bin/47n6g3pbi5plc7n8fn58nkinje/gradle-1.4/lib/gradle-launcher-1.4.jar, org.gradle.launcher.daemon.bootstrap.GradleDaemon, 1.4, /home/denis/.gradle/daemon, 10800000, d4655041-b24b-4c54-b994-e65c845cbf7a, -XX:MaxPermSize=256m, -XX:+HeapDumpOnOutOfMemoryError, -Xmx1024m, -Dfile.encoding=UTF-8]
Starting process 'Gradle build daemon'. Working directory: /home/denis/.gradle/daemon/1.4 Command: /home/denis/dev/jdk/jdk1.7.0_13/bin/java -XX:MaxPermSize=256m -XX:+HeapDumpOnOutOfMemoryError -Xmx1024m -Dfile.encoding=UTF-8 -cp /home/denis/.gradle/wrapper/dists/gradle-1.4-bin/47n6g3pbi5plc7n8fn58nkinje/gradle-1.4/lib/gradle-launcher-1.4.jar org.gradle.launcher.daemon.bootstrap.GradleDaemon 1.4 /home/denis/.gradle/daemon 10800000 d4655041-b24b-4c54-b994-e65c845cbf7a -XX:MaxPermSize=256m -XX:+HeapDumpOnOutOfMemoryError -Xmx1024m -Dfile.encoding=UTF-8
An attempt to initialize for well behaving parent process finished.
Successfully started process 'Gradle build daemon'
Process 'Gradle build daemon' finished with exit value 0 (state: DETACHED)
An attempt to start the daemon took 0.442 secs.
Connected to the daemon. Dispatching Build{id=f8947130-747d-46fa-adcf-850e8bd85dc6.1, currentDir=/home/denis/project/java/gradle-api-client} request.
:buildSrc:compileJava UP-TO-DATE
:buildSrc:compileGroovy UP-TO-DATE
:buildSrc:processResources UP-TO-DATE
:buildSrc:classes UP-TO-DATE
:buildSrc:jar UP-TO-DATE
:buildSrc:assemble UP-TO-DATE
:buildSrc:compileTestJava
:buildSrc:compileTestGroovy UP-TO-DATE
:buildSrc:processTestResources UP-TO-DATE
:buildSrc:testClasses
:buildSrc:test
:buildSrc:check
:buildSrc:build
Download http://repo1.maven.org/maven2/commons-io/commons-io/1.2/commons-io-1.2.pom
Download http://repo1.maven.org/maven2/commons-lang/commons-lang/2.4/commons-lang-2.4-sources.jar
Download http://repo1.maven.org/maven2/commons-io/commons-io/1.2/commons-io-1.2-sources.jar
Download http://repo1.maven.org/maven2/commons-io/commons-io/1.2/commons-io-1.2.jar

BUILD SUCCESSFUL

Total time: 8.5 secs

When a build.gradle is invalid a huge error report is printed as well:

22:04:44.347 [Connection worker] DEBUG o.g.t.i.provider.DefaultConnection - Provider implementation created.
22:04:44.409 [Connection worker] DEBUG o.g.t.i.provider.DefaultConnection - Embedded executer support created.
22:04:44.416 [Connection worker] DEBUG o.g.t.i.provider.DefaultConnection - Configuring logging to level: INFO
Tooling API uses target gradle version: 1.4.
Connected to the daemon. Dispatching Build{id=ee4b62f3-c80e-4054-bddd-c2e93eba7907.1, currentDir=/home/denis/project/java/gradle-api-client} request.
:buildSrc:compileJava UP-TO-DATE
:buildSrc:compileGroovy UP-TO-DATE
:buildSrc:processResources UP-TO-DATE
:buildSrc:classes UP-TO-DATE
:buildSrc:jar UP-TO-DATE
:buildSrc:assemble UP-TO-DATE
:buildSrc:compileTestJava UP-TO-DATE
:buildSrc:compileTestGroovy UP-TO-DATE
:buildSrc:processTestResources UP-TO-DATE
:buildSrc:testClasses UP-TO-DATE
:buildSrc:test UP-TO-DATE
:buildSrc:check UP-TO-DATE
:buildSrc:build UP-TO-DATE

FAILURE: Build failed with an exception.

* Where:
Build file '/home/denis/dev/gradle/gradle-1.4/samples/java/multiproject/build.gradle' line: 23

* What went wrong:
A problem occurred evaluating root project 'multiproject'.
> Could not find property 'asfas' on root project 'multiproject'.

* Try:
Run with --info or --debug option to get more log output.

* Exception is:
org.gradle.api.GradleScriptException: A problem occurred evaluating root project 'multiproject'.
	at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:54)
	at org.gradle.configuration.DefaultScriptPluginFactory$ScriptPluginImpl.apply(DefaultScriptPluginFactory.java:127)
	at org.gradle.configuration.BuildScriptProcessor.evaluate(BuildScriptProcessor.java:38)
	at org.gradle.configuration.LifecycleProjectEvaluator.evaluate(LifecycleProjectEvaluator.java:43)
	at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.java:466)
	at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.java:77)
	at org.gradle.configuration.ProjectEvaluationConfigurer.execute(ProjectEvaluationConfigurer.java:23)
	at org.gradle.configuration.ProjectEvaluationConfigurer.execute(ProjectEvaluationConfigurer.java:21)
	at org.gradle.api.internal.Actions$CompositeAction.execute(Actions.java:78)
	at org.gradle.api.internal.Actions$TransformingActionAdapter.execute(Actions.java:130)
	at org.gradle.api.internal.project.AbstractProject.configure(AbstractProject.java:442)
	at org.gradle.api.internal.project.AbstractProject.allprojects(AbstractProject.java:437)
	at org.gradle.configuration.DefaultBuildConfigurer.configure(DefaultBuildConfigurer.java:40)
	at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:142)
	at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:113)
	at org.gradle.initialization.DefaultGradleLauncher.getBuildAnalysis(DefaultGradleLauncher.java:92)
	at org.gradle.tooling.internal.provider.BuildModelAction.run(BuildModelAction.java:70)
	at org.gradle.tooling.internal.provider.DelegatingBuildModelAction.run(DelegatingBuildModelAction.java:44)
	at org.gradle.tooling.internal.provider.ConfiguringBuildAction.run(ConfiguringBuildAction.java:98)
	at org.gradle.launcher.exec.InProcessGradleLauncherActionExecuter.execute(InProcessGradleLauncherActionExecuter.java:39)
	at org.gradle.launcher.daemon.server.exec.ExecuteBuild.doBuild(ExecuteBuild.java:45)
	at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:34)
	at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:126)
	at org.gradle.launcher.daemon.server.exec.WatchForDisconnection.execute(WatchForDisconnection.java:42)
	at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:126)
	at org.gradle.launcher.daemon.server.exec.ResetDeprecationLogger.execute(ResetDeprecationLogger.java:24)
	at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:126)
	at org.gradle.launcher.daemon.server.exec.StartStopIfBuildAndStop.execute(StartStopIfBuildAndStop.java:33)
	at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:126)
	at org.gradle.launcher.daemon.server.exec.ReturnResult.execute(ReturnResult.java:34)
	at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:126)
	at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:70)
	at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:68)
	at org.gradle.util.Swapper.swap(Swapper.java:38)
	at org.gradle.launcher.daemon.server.exec.ForwardClientInput.execute(ForwardClientInput.java:68)
	at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:126)
	at org.gradle.launcher.daemon.server.exec.LogToClient.doBuild(LogToClient.java:60)
	at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:34)
	at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:126)
	at org.gradle.launcher.daemon.server.exec.EstablishBuildEnvironment.doBuild(EstablishBuildEnvironment.java:59)
	at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:34)
	at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:126)
	at org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy$1.run(StartBuildOrRespondWithBusy.java:45)
	at org.gradle.launcher.daemon.server.DaemonStateCoordinator.runCommand(DaemonStateCoordinator.java:186)
	at org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy.doBuild(StartBuildOrRespondWithBusy.java:49)
	at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:34)
	at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:126)
	at org.gradle.launcher.daemon.server.exec.HandleStop.execute(HandleStop.java:36)
	at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:126)
	at org.gradle.launcher.daemon.server.exec.CatchAndForwardDaemonFailure.execute(CatchAndForwardDaemonFailure.java:32)
	at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:126)
	at org.gradle.launcher.daemon.server.exec.DefaultDaemonCommandExecuter.executeCommand(DefaultDaemonCommandExecuter.java:48)
	at org.gradle.launcher.daemon.server.DefaultIncomingConnectionHandler$ConnectionWorker.handleCommand(DefaultIncomingConnectionHandler.java:155)
	at org.gradle.launcher.daemon.server.DefaultIncomingConnectionHandler$ConnectionWorker.receiveAndHandleCommand(DefaultIncomingConnectionHandler.java:128)
	at org.gradle.launcher.daemon.server.DefaultIncomingConnectionHandler$ConnectionWorker.run(DefaultIncomingConnectionHandler.java:116)
	at org.gradle.internal.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$1.run(DefaultExecutorFactory.java:66)
Caused by: groovy.lang.MissingPropertyException: Could not find property 'asfas' on root project 'multiproject'.
	at org.gradle.api.internal.AbstractDynamicObject.propertyMissingException(AbstractDynamicObject.java:43)
	at org.gradle.api.internal.AbstractDynamicObject.getProperty(AbstractDynamicObject.java:35)
	at org.gradle.api.internal.CompositeDynamicObject.getProperty(CompositeDynamicObject.java:94)
	at org.gradle.groovy.scripts.BasicScript.propertyMissing(BasicScript.java:70)
	at build_vtde6re3759go5hfcril41uks.run(/home/denis/dev/gradle/gradle-1.4/samples/java/multiproject/build.gradle:23)
	at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:52)
	... 55 more


BUILD FAILED

Total time: 1.572 secs
Exception in thread "main" org.gradle.tooling.BuildException: Could not fetch model of type 'IdeaProject' using Gradle distribution 'http://services.gradle.org/distributions/gradle-1.4-bin.zip'.
	at org.gradle.tooling.internal.consumer.ResultHandlerAdapter.onFailure(ResultHandlerAdapter.java:53)
	at org.gradle.tooling.internal.consumer.async.DefaultAsyncConnection$2.run(DefaultAsyncConnection.java:71)
	at org.gradle.internal.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$1.run(DefaultExecutorFactory.java:66)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
	at java.lang.Thread.run(Thread.java:722)
Caused by: org.gradle.api.internal.LocationAwareException: Build file '/home/denis/dev/gradle/gradle-1.4/samples/java/multiproject/build.gradle' line: 23
A problem occurred evaluating root project 'multiproject'.
	at org.gradle.initialization.DefaultExceptionAnalyser.transform(DefaultExceptionAnalyser.java:85)
	at org.gradle.initialization.MultipleBuildFailuresExceptionAnalyser.transform(MultipleBuildFailuresExceptionAnalyser.java:47)
	at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:115)
	at org.gradle.initialization.DefaultGradleLauncher.getBuildAnalysis(DefaultGradleLauncher.java:92)
	at org.gradle.tooling.internal.provider.BuildModelAction.run(BuildModelAction.java:70)
	at org.gradle.tooling.internal.provider.DelegatingBuildModelAction.run(DelegatingBuildModelAction.java:44)
	at org.gradle.tooling.internal.provider.ConfiguringBuildAction.run(ConfiguringBuildAction.java:98)
	at org.gradle.launcher.exec.InProcessGradleLauncherActionExecuter.execute(InProcessGradleLauncherActionExecuter.java:39)
	at org.gradle.launcher.daemon.server.exec.ExecuteBuild.doBuild(ExecuteBuild.java:45)
	at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:34)
	at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:126)
	at org.gradle.launcher.daemon.server.exec.WatchForDisconnection.execute(WatchForDisconnection.java:42)
	at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:126)
	at org.gradle.launcher.daemon.server.exec.ResetDeprecationLogger.execute(ResetDeprecationLogger.java:24)
	at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:126)
	at org.gradle.launcher.daemon.server.exec.StartStopIfBuildAndStop.execute(StartStopIfBuildAndStop.java:33)
	at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:126)
	at org.gradle.launcher.daemon.server.exec.ReturnResult.execute(ReturnResult.java:34)
	at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:126)
	at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:70)
	at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:68)
	at org.gradle.util.Swapper.swap(Swapper.java:38)
	at org.gradle.launcher.daemon.server.exec.ForwardClientInput.execute(ForwardClientInput.java:68)
	at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:126)
	at org.gradle.launcher.daemon.server.exec.LogToClient.doBuild(LogToClient.java:60)
	at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:34)
	at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:126)
	at org.gradle.launcher.daemon.server.exec.EstablishBuildEnvironment.doBuild(EstablishBuildEnvironment.java:59)
	at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:34)
	at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:126)
	at org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy$1.run(StartBuildOrRespondWithBusy.java:45)
	at org.gradle.launcher.daemon.server.DaemonStateCoordinator.runCommand(DaemonStateCoordinator.java:186)
	at org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy.doBuild(StartBuildOrRespondWithBusy.java:49)
	at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:34)
	at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:126)
	at org.gradle.launcher.daemon.server.exec.HandleStop.execute(HandleStop.java:36)
	at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:126)
	at org.gradle.launcher.daemon.server.exec.CatchAndForwardDaemonFailure.execute(CatchAndForwardDaemonFailure.java:32)
	at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:126)
	at org.gradle.launcher.daemon.server.exec.DefaultDaemonCommandExecuter.executeCommand(DefaultDaemonCommandExecuter.java:48)
	at org.gradle.launcher.daemon.server.DefaultIncomingConnectionHandler$ConnectionWorker.handleCommand(DefaultIncomingConnectionHandler.java:155)
	at org.gradle.launcher.daemon.server.DefaultIncomingConnectionHandler$ConnectionWorker.receiveAndHandleCommand(DefaultIncomingConnectionHandler.java:128)
	at org.gradle.launcher.daemon.server.DefaultIncomingConnectionHandler$ConnectionWorker.run(DefaultIncomingConnectionHandler.java:116)
	... 4 more
Caused by: org.gradle.api.GradleScriptException: A problem occurred evaluating root project 'multiproject'.
	at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:54)
	at org.gradle.configuration.DefaultScriptPluginFactory$ScriptPluginImpl.apply(DefaultScriptPluginFactory.java:127)
	at org.gradle.configuration.BuildScriptProcessor.evaluate(BuildScriptProcessor.java:38)
	at org.gradle.configuration.LifecycleProjectEvaluator.evaluate(LifecycleProjectEvaluator.java:43)
	at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.java:466)
	at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.java:77)
	at org.gradle.configuration.ProjectEvaluationConfigurer.execute(ProjectEvaluationConfigurer.java:23)
	at org.gradle.configuration.ProjectEvaluationConfigurer.execute(ProjectEvaluationConfigurer.java:21)
	at org.gradle.api.internal.Actions$CompositeAction.execute(Actions.java:78)
	at org.gradle.api.internal.Actions$TransformingActionAdapter.execute(Actions.java:130)
	at org.gradle.api.internal.project.AbstractProject.configure(AbstractProject.java:442)
	at org.gradle.api.internal.project.AbstractProject.allprojects(AbstractProject.java:437)
	at org.gradle.configuration.DefaultBuildConfigurer.configure(DefaultBuildConfigurer.java:40)
	at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:142)
	at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:113)
	at org.gradle.initialization.DefaultGradleLauncher.getBuildAnalysis(DefaultGradleLauncher.java:92)
	at org.gradle.tooling.internal.provider.BuildModelAction.run(BuildModelAction.java:70)
	at org.gradle.tooling.internal.provider.DelegatingBuildModelAction.run(DelegatingBuildModelAction.java:44)
	at org.gradle.tooling.internal.provider.ConfiguringBuildAction.run(ConfiguringBuildAction.java:98)
	at org.gradle.launcher.exec.InProcessGradleLauncherActionExecuter.execute(InProcessGradleLauncherActionExecuter.java:39)
	at org.gradle.launcher.daemon.server.exec.ExecuteBuild.doBuild(ExecuteBuild.java:45)
	at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:34)
	at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:126)
	at org.gradle.launcher.daemon.server.exec.WatchForDisconnection.execute(WatchForDisconnection.java:42)
	at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:126)
	at org.gradle.launcher.daemon.server.exec.ResetDeprecationLogger.execute(ResetDeprecationLogger.java:24)
	at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:126)
	at org.gradle.launcher.daemon.server.exec.StartStopIfBuildAndStop.execute(StartStopIfBuildAndStop.java:33)
	at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:126)
	at org.gradle.launcher.daemon.server.exec.ReturnResult.execute(ReturnResult.java:34)
	at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:126)
	at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:70)
	at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:68)
	at org.gradle.util.Swapper.swap(Swapper.java:38)
	at org.gradle.launcher.daemon.server.exec.ForwardClientInput.execute(ForwardClientInput.java:68)
	at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:126)
	at org.gradle.launcher.daemon.server.exec.LogToClient.doBuild(LogToClient.java:60)
	at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:34)
	at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:126)
	at org.gradle.launcher.daemon.server.exec.EstablishBuildEnvironment.doBuild(EstablishBuildEnvironment.java:59)
	at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:34)
	at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:126)
	at org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy$1.run(StartBuildOrRespondWithBusy.java:45)
	at org.gradle.launcher.daemon.server.DaemonStateCoordinator.runCommand(DaemonStateCoordinator.java:186)
	at org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy.doBuild(StartBuildOrRespondWithBusy.java:49)
	at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:34)
	at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:126)
	at org.gradle.launcher.daemon.server.exec.HandleStop.execute(HandleStop.java:36)
	at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:126)
	at org.gradle.launcher.daemon.server.exec.CatchAndForwardDaemonFailure.execute(CatchAndForwardDaemonFailure.java:32)
	at org.gradle.launcher.daemon.server.exec.DaemonCommandExecution.proceed(DaemonCommandExecution.java:126)
	at org.gradle.launcher.daemon.server.exec.DefaultDaemonCommandExecuter.executeCommand(DefaultDaemonCommandExecuter.java:48)
	at org.gradle.launcher.daemon.server.DefaultIncomingConnectionHandler$ConnectionWorker.handleCommand(DefaultIncomingConnectionHandler.java:155)
	at org.gradle.launcher.daemon.server.DefaultIncomingConnectionHandler$ConnectionWorker.receiveAndHandleCommand(DefaultIncomingConnectionHandler.java:128)
	at org.gradle.launcher.daemon.server.DefaultIncomingConnectionHandler$ConnectionWorker.run(DefaultIncomingConnectionHandler.java:116)
	at org.gradle.internal.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$1.run(DefaultExecutorFactory.java:66)
Caused by: groovy.lang.MissingPropertyException: Could not find property 'asfas' on root project 'multiproject'.
	at org.gradle.api.internal.AbstractDynamicObject.propertyMissingException(AbstractDynamicObject.java:43)
	at org.gradle.api.internal.AbstractDynamicObject.getProperty(AbstractDynamicObject.java:35)
	at org.gradle.api.internal.CompositeDynamicObject.getProperty(CompositeDynamicObject.java:94)
	at org.gradle.groovy.scripts.BasicScript.propertyMissing(BasicScript.java:70)
	at build_vtde6re3759go5hfcril41uks.run(/home/denis/dev/gradle/gradle-1.4/samples/java/multiproject/build.gradle:23)
	at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:52)
	... 55 more

That prevents us from providing 'full auto-import'. I.e. it would have been possible to monitor gradle scripts modification at tooling api client and refresh a project on such events (practically, not that simple but scheduling a refresh and executing it if no changes have been made particular amount of time). However, there is a possible case that particular gradle script is inconsistent at the moment of typing and then we have a huge logs pollution by error information generated by gradle.



 Comments   
Comment by Marco Behler [ 26/Apr/13 ]

Us IntelliJ users would LOVE to see this getting fixed

Comment by Andy Morris [ 07/Nov/13 ]

+1 for this to be fixed so auto-import can work.

Comment by Peter Tillemans [ 20/Nov/13 ]

+1 to get auto-import to actually work automatically.

Comment by Ryan Gardner [ 22/Apr/14 ]

Letting clients pass in a custom stdout and stderr and then not actually using the custom stdout or stderr for the output seems like a bug to me (why would you ever not want to use those custom output streams?)

This bug has been opened and blocking better integration with intellij (and other tools) for over a year. It doesn't sound like it's that hard of a thing to fix.

Is this something that the community could fix and then contribute as a patch?

Comment by Stuart Stevenson [ 16/Jun/14 ]

Anything that help improves Intellij integration gets a +1 from me. The current level of integration is hampering migration of our code base to Gradle.

Comment by David Moles [ 25/Jul/14 ]

See also this related issue: http://forums.gradle.org/gradle/topics/gradle_tooling_api_produces_copious_log_output_that_is_difficult_impossible_to_suppress

Comment by Matyas [ 30/Aug/14 ]

+1 Is there any progress on this issue? This blocks a full IDEA integration, see http://confluence.jetbrains.com/display/IDEADEV/Gradle+integration

Comment by Lari Hotari [ 09/Oct/14 ]

We would like to have this fixed for Grails 3 where we use Gradle extensively via the Tooling API.

I've been looking in to this issue and it seems that the problem is around these lines of code:
in org.gradle.tooling.internal.provider.ProviderConnection
and
in org.gradle.tooling.internal.provider.LoggingBridgingBuildActionExecuter

We'd also like to be able to do colored (ansi escaped) output in the tooling API so that the output is similar to the cli output. There has been a question about this on the gradle-dev mailing list.

The ansi output in tooling api isn't directly related to this issue, but I'll write some notes here since I didn't find a separate issue about the colored output with Tooling API.

I did a local spike and I was able to get "forced" colored output (ansi escaped) for the cli by changing the code around these lines of code:
ConsoleConfigureAction

  protected ConsoleDetector createConsoleDetector(OperatingSystem operatingSystem) {
        if (useAnsiOutput) {
            return new ConsoleDetector() {
                public ConsoleMetaData getConsole() {
                    return new FallbackConsoleMetaData();
                }
            };
        }

NativeServices

public void execute(OutputEventRenderer renderer) {
        ConsoleDetector consoleDetector = NativeServices.getInstance().get(ConsoleDetector.class);
        ConsoleMetaData consoleMetaData = consoleDetector.getConsole();
        if (consoleMetaData == null) {
            return;
        }
        boolean stdOutIsTerminal = consoleMetaData.isStdOut();
        boolean stdErrIsTerminal = consoleMetaData.isStdErr();
        if (stdOutIsTerminal) {
            OutputStream originalStdOut = renderer.getOriginalStdOut();
            PrintStream outStr = new PrintStream(useAnsiOutput ? originalStdOut : org.fusesource.jansi.AnsiConsole.wrapOutputStream(originalStdOut));
            Console console = new AnsiConsole(outStr, outStr, renderer.getColourMap());
            renderer.addConsole(console, true, stdErrIsTerminal, consoleMetaData);
        } else if (stdErrIsTerminal) {
            // Only stderr is connected to a terminal
            OutputStream originalStdErr = renderer.getOriginalStdErr();
            PrintStream errStr = new PrintStream(useAnsiOutput ? originalStdErr : org.fusesource.jansi.AnsiConsole.wrapOutputStream(originalStdErr));
            Console console = new AnsiConsole(errStr, errStr, renderer.getColourMap());
            renderer.addConsole(console, false, true, consoleMetaData);
        }
    }

I'll try to find out if I can get the tooling API output to use "forced" colored output by using a similar config in LoggingBridgingBuildActionExecuter/ProviderConnection. I'm new to gradle source code so I'm just hacking around to see if something works. I hope that helps us all to get this issue solved faster. As I mentioned, we'd like to get the "forced" ansi colored output too for the tooling API output, not just a solution for redirecting stdout and stderr.

The "forced" ansi colored output requires skipping detection whether a real terminal is connected to stdout or not (both Gradle and Jansi do this). The windows OS detection should be skipped too (in Jansi), if we say we want ansi output, there shouldn't be any extra terminal or os detection magic. That's what I did with my small changes to get forced ansi escaped output in the cli. Something similar is required for the tooling api output if we want to get ansi escaped output there too.

Comment by Lóránt Pintér [ 09/Oct/14 ]

Lari, this would be great. The single most important bug holding us back from building more tools on top of Gradle is this one. If you could fix the colors as well, that'd be even better.

Comment by Lari Hotari [ 09/Oct/14 ]

I'm trying to understand the current solution and I'm writing some memos here about my investigation:

The reason why output of System.out/System.err isn't captured is because this row adds default output to System.out/System.err:
https://github.com/gradle/gradle/blob/b1e1d48866cb73b0a621142ca7444c8b22f9383a/subprojects/core/src/main/groovy/org/gradle/logging/LoggingServiceRegistry.java#L129

It would overriding the createOutputEventRenderer() method like LoggingServiceRegistry.CommandLineLogging class does to be able to control logging. Should probably implement "Action<? super OutputEventRenderer> consoleConfigureAction" like ConsoleConfigureAction that CommandLineLogging does.

Comment by Lari Hotari [ 09/Oct/14 ]

I started hacking on some stuff https://github.com/lhotari/gradle/commits/ansi_support

Comment by Lari Hotari [ 09/Oct/14 ]

I got the colored output working and I believe it also fixes this issue GRADLE-2687. I made a PR: https://github.com/gradle/gradle/pull/340

Comment by Radim Kubacki [ 13/Oct/14 ]

First changeset from that patch is integrated now. I' going to take a look at the next part to redirect the log messages too before the operation is started.

Comment by Graeme Rocher [ 20/Nov/14 ]

Any progress on this issue? It is impacting the development of Grails 3.0

Comment by Marcin Zajaczkowski [ 27/Dec/14 ]

Probably a reason mentioned by Lari also causes that messages printed directly on stdout/stderr cannot be tested/asserted with nebula-test (what was possible with Gradle 1.x).

Comment by Benjamin Muschko [ 15/Nov/16 ]

As announced on the Gradle blog we are planning to completely migrate issues from JIRA to GitHub.

We intend to prioritize issues that are actionable and impactful while working more closely with the community. Many of our JIRA issues are inactionable or irrelevant. We would like to request your help to ensure we can appropriately prioritize JIRA issues you’ve contributed to.

Please confirm that you still advocate for your JIRA issue before December 10th, 2016 by:

  • Checking that your issues contain requisite context, impact, behaviors, and examples as described in our published guidelines.
  • Leave a comment on the JIRA issue or open a new GitHub issue confirming that the above is complete.

We look forward to collaborating with you more closely on GitHub. Thank you for your contribution to Gradle!

Comment by Benjamin Muschko [ 08/Feb/17 ]

I believe this issue has been fixed with a Gradle 2.x release. I cannot reproduce the issue anymore with Gradle 3.3. Please open an issue on GitHub in case you are still running into issues.

Generated at Wed Jun 30 12:28:45 CDT 2021 using Jira 8.4.2#804003-sha1:d21414fc212e3af190e92c2d2ac41299b89402cf.