gradle tasks throws ConcurrentModificationException


(Joachim Heldmann) #1

I use Gradle 1.0-milestone-6 and get the following error when I execute “gradle -d tasks”

11:34:19.367 [QUIET] [org.gradle.api.tasks.diagnostics.TaskReportTask_Decorated]
11:34:19.367 [QUIET] [org.gradle.api.tasks.diagnostics.TaskReportTask_Decorated] ------------------------------------------------------------
11:34:19.367 [QUIET] [org.gradle.api.tasks.diagnostics.TaskReportTask_Decorated] All tasks runnable from root project
11:34:19.367 [QUIET] [org.gradle.api.tasks.diagnostics.TaskReportTask_Decorated] ------------------------------------------------------------
11:34:19.367 [QUIET] [org.gradle.api.tasks.diagnostics.TaskReportTask_Decorated]
11:34:19.461 [DEBUG] [org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter] Finished executing task ':tasks'
11:34:19.461 [ERROR] [org.gradle.BuildExceptionReporter]
11:34:19.461 [ERROR] [org.gradle.BuildExceptionReporter] FAILURE: Build failed with an exception.
11:34:19.461 [ERROR] [org.gradle.BuildExceptionReporter]
11:34:19.461 [ERROR] [org.gradle.BuildExceptionReporter] * What went wrong:
11:34:19.461 [ERROR] [org.gradle.BuildExceptionReporter] Execution failed for task ':tasks'.
11:34:19.461 [ERROR] [org.gradle.BuildExceptionReporter] Cause: java.util.ConcurrentModificationException (no error message)
11:34:19.461 [ERROR] [org.gradle.BuildExceptionReporter]
11:34:19.461 [ERROR] [org.gradle.BuildExceptionReporter] * Exception is:
11:34:19.461 [ERROR] [org.gradle.BuildExceptionReporter] org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':tasks'.
11:34:19.461 [ERROR] [org.gradle.BuildExceptionReporter]
      at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:71)
11:34:19.461 [ERROR] [org.gradle.BuildExceptionReporter]
      at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:48)
11:34:19.461 [ERROR] [org.gradle.BuildExceptionReporter]
      at org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(PostExecutionAnalysisTaskExecuter.java:34)
11:34:19.461 [ERROR] [org.gradle.BuildExceptionReporter]
      at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:55)
11:34:19.461 [ERROR] [org.gradle.BuildExceptionReporter]
      at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:57)
11:34:19.461 [ERROR] [org.gradle.BuildExceptionReporter]
      at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:41)
11:34:19.461 [ERROR] [org.gradle.BuildExceptionReporter]
      at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:51)
11:34:19.461 [ERROR] [org.gradle.BuildExceptionReporter]
      at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:52)
11:34:19.461 [ERROR] [org.gradle.BuildExceptionReporter]
      at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:42)
11:34:19.461 [ERROR] [org.gradle.BuildExceptionReporter]
      at org.gradle.api.internal.AbstractTask.executeWithoutThrowingTaskFailure(AbstractTask.java:243)
11:34:19.461 [ERROR] [org.gradle.BuildExceptionReporter]
      at org.gradle.execution.DefaultTaskGraphExecuter.executeTask(DefaultTaskGraphExecuter.java:192)
11:34:19.461 [ERROR] [org.gradle.BuildExceptionReporter]
      at org.gradle.execution.DefaultTaskGraphExecuter.doExecute(DefaultTaskGraphExecuter.java:177)
11:34:19.461 [ERROR] [org.gradle.BuildExceptionReporter]
      at org.gradle.execution.DefaultTaskGraphExecuter.execute(DefaultTaskGraphExecuter.java:83)
11:34:19.461 [ERROR] [org.gradle.BuildExceptionReporter]
      at org.gradle.execution.SelectedTaskExecutionAction.execute(SelectedTaskExecutionAction.java:36)
11:34:19.461 [ERROR] [org.gradle.BuildExceptionReporter]
      at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:70)
11:34:19.461 [ERROR] [org.gradle.BuildExceptionReporter]
      at org.gradle.execution.DefaultBuildExecuter.access$300(DefaultBuildExecuter.java:23)
11:34:19.461 [ERROR] [org.gradle.BuildExceptionReporter]
      at org.gradle.execution.DefaultBuildExecuter$2.proceed(DefaultBuildExecuter.java:80)
11:34:19.477 [ERROR] [org.gradle.BuildExceptionReporter]
      at org.gradle.execution.DryRunBuildExecutionAction.execute(DryRunBuildExecutionAction.java:32)
11:34:19.477 [ERROR] [org.gradle.BuildExceptionReporter]
      at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:70)
11:34:19.477 [ERROR] [org.gradle.BuildExceptionReporter]
      at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:63)
11:34:19.477 [ERROR] [org.gradle.BuildExceptionReporter]
      at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:157)
11:34:19.477 [ERROR] [org.gradle.BuildExceptionReporter]
      at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:112)
11:34:19.477 [ERROR] [org.gradle.BuildExceptionReporter]
      at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:80)
11:34:19.477 [ERROR] [org.gradle.BuildExceptionReporter]
      at org.gradle.launcher.cli.RunBuildAction.execute(RunBuildAction.java:42)
11:34:19.477 [ERROR] [org.gradle.BuildExceptionReporter]
      at org.gradle.launcher.cli.RunBuildAction.execute(RunBuildAction.java:28)
11:34:19.477 [ERROR] [org.gradle.BuildExceptionReporter]
      at org.gradle.launcher.exec.ExceptionReportingAction.execute(ExceptionReportingAction.java:32)
11:34:19.477 [ERROR] [org.gradle.BuildExceptionReporter]
      at org.gradle.launcher.exec.ExceptionReportingAction.execute(ExceptionReportingAction.java:21)
11:34:19.477 [ERROR] [org.gradle.BuildExceptionReporter]
      at org.gradle.launcher.cli.CommandLineActionFactory$WithLoggingAction.execute(CommandLineActionFactory.java:233)
11:34:19.477 [ERROR] [org.gradle.BuildExceptionReporter]
      at org.gradle.launcher.cli.CommandLineActionFactory$WithLoggingAction.execute(CommandLineActionFactory.java:217)
11:34:19.477 [ERROR] [org.gradle.BuildExceptionReporter]
      at org.gradle.launcher.Main.doAction(Main.java:48)
11:34:19.477 [ERROR] [org.gradle.BuildExceptionReporter]
      at org.gradle.launcher.exec.EntryPoint$1.execute(EntryPoint.java:53)
11:34:19.477 [ERROR] [org.gradle.BuildExceptionReporter]
      at org.gradle.launcher.exec.EntryPoint$1.execute(EntryPoint.java:51)
11:34:19.477 [ERROR] [org.gradle.BuildExceptionReporter]
      at org.gradle.launcher.exec.Execution.execute(Execution.java:28)
11:34:19.477 [ERROR] [org.gradle.BuildExceptionReporter]
      at org.gradle.launcher.exec.EntryPoint.run(EntryPoint.java:39)
11:34:19.477 [ERROR] [org.gradle.BuildExceptionReporter]
      at org.gradle.launcher.Main.main(Main.java:39)
11:34:19.477 [ERROR] [org.gradle.BuildExceptionReporter]
      at org.gradle.launcher.ProcessBootstrap.runNoExit(ProcessBootstrap.java:51)
11:34:19.477 [ERROR] [org.gradle.BuildExceptionReporter]
      at org.gradle.launcher.ProcessBootstrap.run(ProcessBootstrap.java:33)
11:34:19.477 [ERROR] [org.gradle.BuildExceptionReporter]
      at org.gradle.launcher.GradleMain.main(GradleMain.java:24)
11:34:19.477 [ERROR] [org.gradle.BuildExceptionReporter] Caused by: java.util.ConcurrentModificationException
11:34:19.477 [ERROR] [org.gradle.BuildExceptionReporter]
      at org.gradle.api.internal.DefaultDomainObjectCollection$IteratorImpl.next(DefaultDomainObjectCollection.java:313)
11:34:19.477 [ERROR] [org.gradle.BuildExceptionReporter]
      at org.gradle.api.internal.GraphAggregator.group(GraphAggregator.java:33)
11:34:19.477 [ERROR] [org.gradle.BuildExceptionReporter]
      at org.gradle.api.tasks.diagnostics.internal.SingleProjectTaskReportModel.build(SingleProjectTaskReportModel.java:61)
11:34:19.477 [ERROR] [org.gradle.BuildExceptionReporter]
      at org.gradle.api.tasks.diagnostics.TaskReportTask.generate(TaskReportTask.java:67)
11:34:19.477 [ERROR] [org.gradle.BuildExceptionReporter]
      at org.gradle.api.tasks.diagnostics.AbstractReportTask.generate(AbstractReportTask.java:67)
11:34:19.477 [ERROR] [org.gradle.BuildExceptionReporter]
      at org.gradle.api.internal.BeanDynamicObject.invokeMethod(BeanDynamicObject.java:158)
11:34:19.477 [ERROR] [org.gradle.BuildExceptionReporter]
      at org.gradle.api.internal.CompositeDynamicObject.invokeMethod(CompositeDynamicObject.java:93)
11:34:19.477 [ERROR] [org.gradle.BuildExceptionReporter]
      at org.gradle.api.tasks.diagnostics.TaskReportTask_Decorated.invokeMethod(Unknown Source)
11:34:19.477 [ERROR] [org.gradle.BuildExceptionReporter]
      at org.gradle.util.ReflectionUtil.invoke(ReflectionUtil.groovy:23)
11:34:19.477 [ERROR] [org.gradle.BuildExceptionReporter]
      at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$2.execute(AnnotationProcessingTaskFactory.java:129)
11:34:19.477 [ERROR] [org.gradle.BuildExceptionReporter]
      at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$2.execute(AnnotationProcessingTaskFactory.java:127)
11:34:19.477 [ERROR] [org.gradle.BuildExceptionReporter]
      at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:63)
11:34:19.477 [ERROR] [org.gradle.BuildExceptionReporter]
      ... 37 more
11:34:19.477 [ERROR] [org.gradle.BuildExceptionReporter]
11:34:19.477 [LIFECYCLE] [org.gradle.BuildResultLogger]
11:34:19.477 [LIFECYCLE] [org.gradle.BuildResultLogger] BUILD FAILED
11:34:19.477 [LIFECYCLE] [org.gradle.BuildResultLogger]
11:34:19.477 [LIFECYCLE] [org.gradle.BuildResultLogger] Total time: 2.344 secs

I can reproduce the error in a multiproject build with an empty “sub”-directory and the following build and settings files:

build.gradle

subprojects {
      apply plugin: 'java'
      afterEvaluate { project ->
        task foo {
        }
        clean.dependsOn "cleanFoo"
    }
}

settings.gradle

include "sub"

(Martin Jöhren) #2

Where should the task ‘cleanFoo’ come from? Maybe you meant ‘foo’? When I change the line into

clean.dependsOn "foo"

everything works fine. Is it a typo?


(Joachim Heldmann) #3

No, it’s not a typo.

The task “cleanFoo” comes from the Java plugin. The Java plugin creates a clean"TaskName" Task which deletes the output files of the specified task (-> userguide).


(Martin Jöhren) #4

Ok, u r right, but after a bit of investigation it seems to me that a) the task cleanFoo is not added directly by the java plugin. Instead the basePlugin does that ‘magic’ b) it is not a task. It is a rule. You can look it up in file BasePlugin.groovy. For me that means that a dependsOn won’t work because it is not a real task.

I don’t know whether it should be in that way implemented that you can specify a dependency on a task rule. Maybe a core developer can acknowledge that.


(Merlyn Albery-Speyer) #5

I also get this stack trace. I have a rule defined and a task that depends on it. It works in m3.


(Merlyn Albery-Speyer) #6

This worked for me:

  1. move my dependsOn to after the rule is defined. 2. remove the quotes

Not great. But it works for the time being.


(Joachim Heldmann) #7

After changing one line from

clean.dependsOn "cleanFoo"

to

clean.dependsOn tasks["cleanFoo"]

it works for me.