IllegalStateException: event sink is closed with build-scan 1.1

Gradle Version: 2.4.11
Operating System and JVM version:

Build #AI-145.3253452, built on September 7, 2016
JRE: 1.8.0_102-b14 x86_64
JVM: Java HotSpot(TM) 64-Bit Server VM by Oracle Corporation

It’s a regression, everything works fine in 1.0

Issue occurs only when syncing project in Android Studio, does not occur when running from commandline.

Build-scan settings:

	id 'com.gradle.build-scan' version '1.1'
}

buildScan {
	licenseAgreementUrl = 'https://gradle.com/terms-of-service'
	licenseAgree = 'yes'
}

Stacktrace from log:

Caused by: java.lang.IllegalStateException: event sink is closed
	at com.gradle.scan.plugin.internal.d.c.a(SourceFile:1159)
	at com.gradle.scan.plugin.internal.b.a.a.a(SourceFile:1062)
	at com.gradle.scan.plugin.internal.b.a.b.execute(SourceFile:1045)
	at org.gradle.listener.ActionBroadcast.execute(ActionBroadcast.java:39)
	at org.gradle.api.internal.DefaultDomainObjectCollection.doAdd(DefaultDomainObjectCollection.java:165)
	at org.gradle.api.internal.DefaultDomainObjectCollection.add(DefaultDomainObjectCollection.java:159)
	at org.gradle.api.internal.plugins.DefaultPluginManager.doApply(DefaultPluginManager.java:142)
	... 62 more
2016-09-19 14:57:34,411 [ 147875]   WARN - nal.AbstractExternalSystemTask - Cause: event sink is closed 
com.intellij.openapi.externalSystem.model.ExternalSystemException: Cause: event sink is closed
	at org.jetbrains.plugins.gradle.service.project.AbstractProjectImportErrorHandler.createUserFriendlyError(AbstractProjectImportErrorHandler.java:106)
	at org.jetbrains.plugins.gradle.service.project.BaseProjectImportErrorHandler.getUserFriendlyError(BaseProjectImportErrorHandler.java:158)
	at org.jetbrains.plugins.gradle.service.project.BaseGradleProjectResolverExtension.getUserFriendlyError(BaseGradleProjectResolverExtension.java:579)
	at org.jetbrains.plugins.gradle.service.project.AbstractProjectResolverExtension.getUserFriendlyError(AbstractProjectResolverExtension.java:158)
	at com.android.tools.idea.gradle.project.AndroidGradleProjectResolver.getUserFriendlyError(AndroidGradleProjectResolver.java:405)
	at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver$ProjectConnectionDataNodeFunction.fun(GradleProjectResolver.java:772)
	at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver$ProjectConnectionDataNodeFunction.fun(GradleProjectResolver.java:752)
	at org.jetbrains.plugins.gradle.service.execution.GradleExecutionHelper.execute(GradleExecutionHelper.java:238)
	at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver.resolveProjectInfo(GradleProjectResolver.java:112)
	at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver.resolveProjectInfo(GradleProjectResolver.java:73)
	at com.intellij.openapi.externalSystem.service.remote.RemoteExternalSystemProjectResolverImpl$1.produce(RemoteExternalSystemProjectResolverImpl.java:41)
	at com.intellij.openapi.externalSystem.service.remote.RemoteExternalSystemProjectResolverImpl$1.produce(RemoteExternalSystemProjectResolverImpl.java:37)
	at com.intellij.openapi.externalSystem.service.remote.AbstractRemoteExternalSystemService.execute(AbstractRemoteExternalSystemService.java:59)
	at com.intellij.openapi.externalSystem.service.remote.RemoteExternalSystemProjectResolverImpl.resolveProjectInfo(RemoteExternalSystemProjectResolverImpl.java:37)
	at com.intellij.openapi.externalSystem.service.remote.wrapper.ExternalSystemProjectResolverWrapper.resolveProjectInfo(ExternalSystemProjectResolverWrapper.java:49)
	at com.intellij.openapi.externalSystem.service.internal.ExternalSystemResolveProjectTask.doExecute(ExternalSystemResolveProjectTask.java:51)
	at com.intellij.openapi.externalSystem.service.internal.AbstractExternalSystemTask.execute(AbstractExternalSystemTask.java:138)
	at com.intellij.openapi.externalSystem.service.internal.AbstractExternalSystemTask.execute(AbstractExternalSystemTask.java:124)
	at com.intellij.openapi.externalSystem.util.ExternalSystemUtil$3.execute(ExternalSystemUtil.java:419)
	at com.intellij.openapi.externalSystem.util.ExternalSystemUtil$4$2.run(ExternalSystemUtil.java:500)
	at com.intellij.openapi.progress.impl.CoreProgressManager$TaskRunnable.run(CoreProgressManager.java:563)
	at com.intellij.openapi.progress.impl.CoreProgressManager$2.run(CoreProgressManager.java:142)
	at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:446)
	at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:392)
	at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:54)
	at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:127)
	at com.intellij.openapi.progress.impl.ProgressManagerImpl$1.run(ProgressManagerImpl.java:126)
	at com.intellij.openapi.application.impl.ApplicationImpl$8.run(ApplicationImpl.java:369)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:745)

Hello Karol,

thanks for the report. We’re currently working on a fix for this. I’ll ping you once we have sorted this out.

cheers,
René

Hey Karol,
we’re trying hard to reproduce the issue we’re seeing. We think we found the issue but have a hard time to reproduce this. can you provide more details about your android build. (which android studio, which gradle android plugin?) Maybe you’re even able to provide a reproducable sample build that demos that issue?

cheers,
René

Android Studio 2.2 RC. Build #AI-145.3253452 from 1st post should imply that but maybe not obvious.
Project consist of 5 modules + buildSrc:

  • 1 with plugin ‘com.android.application’:
apply plugin: 'com.android.application'
apply plugin: 'me.tatarka.retrolambda'
apply plugin: 'io.fabric'
apply plugin: 'com.neenbedankt.android-apt'
apply plugin: '<stripped>' //id of plugin from buildSrc
  • 1 with plugin ‘com.android.library’
  • 3 with plugin ‘java’
  • buildSrc uses kotlin plugin via nebula.kotlin:
plugins {
	id "nebula.kotlin" version "1.0.3"
}
apply plugin: 'java-gradle-plugin'

Issue is always reproducible on that project.

Is it sufficient or do you still need a sample?

where is your build scan plugin applied here?

I had no luck yet recreating the issue. can you provide the detailed plugins you apply on your android app (including the buildscript block?

Build scan is applied in root project build.gradle its content is in the 1st post. So including root project there is one more module. Here it is again:

buildscript {
	repositories {
		jcenter()
	}
}
plugins {
	id 'com.gradle.build-scan' version '1.1'
}

buildScan {
	licenseAgreementUrl = 'https://gradle.com/terms-of-service'
	licenseAgree = 'yes'
}

allprojects {
	repositories {
		mavenCentral()
		jcenter()
	}
}

And buildscript+plugins of android app module. I’ve added one more plugin since writing 1st post:

buildscript {
	repositories {
		maven { url 'https://maven.fabric.io/public' }
		mavenCentral()
	}
	dependencies {
		classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
		classpath 'me.tatarka:gradle-retrolambda:3.3.0'
		classpath 'io.fabric.tools:gradle:1.21.7'
		classpath 'pl.droidsonroids.gradle:gradle-pitest-plugin:0.0.3'
	}
}

plugins {
	id "pl.droidsonroids.jenkins" version "1.0.19"
	id "net.ltgt.errorprone" version "0.0.8"
}

apply plugin: 'com.android.application'
apply plugin: 'me.tatarka.retrolambda'
apply plugin: 'io.fabric'
apply plugin: 'com.neenbedankt.android-apt'
apply plugin: 'pl.droidsonroids.pitest'
apply plugin: `<stripped>` //id from buildSrc

Android plugin is declared as buildSrc compile dependency: 'com.android.tools.build:gradle:2.1.3'

Does it make a difference if you use the latest Anndroid Studio, that was just released earlier today?

No it doesn’t.
I’ve just upgraded both Android Studio to 2.2, Android Gradle plugin to 2.2.0 and Gradle to 3.1 and there is no difference.

Hello Karol,

can you give version 1.1.1 of the build-scan plugin a try and provide feedback if that fixes your issue? see https://plugins.gradle.org/plugin/com.gradle.build-scan for details.

cheers and thanks again,

René

There is no exception on 1.1.1.
Thanks for the quick fix.

Thank you, Karol, for reporting this issue and providing more details about it. This helped us identify and fix the problem quickly.

Any feedback about Build Scans is always welcome!

Etienne