Build that works with Gradle 2.2.1 fails with Gradle 2.3-20150115093000+0000

I have a complex multi-project build that works fine with Gradle 2.2.1 but I get an error with Gradle 2.3-20150115093000+0000

  • Where: Build file ‘C:\dev\MyRootProject\MySubProject\build.gradle’ line: 41

  • What went wrong: A problem occurred evaluating project ‘:MySubProject’. > Cannot add task ‘:MySubProject:build’ as a task with that name already exists.

… Caused by: org.gradle.api.InvalidUserDataException: Cannot add task ‘:MySubProject:build’ as a task with that name already exists.

at org.gradle.api.internal.tasks.DefaultTaskContainer.create(

at org.gradle.api.internal.project.AbstractProject.task(

at org.gradle.api.internal.BeanDynamicObject$MetaClassAdapter.invokeMethod(

at org.gradle.api.internal.BeanDynamicObject.invokeMethod(

at org.gradle.api.internal.CompositeDynamicObject.invokeMethod(

at org.gradle.groovy.scripts.BasicScript.methodMissing(


at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$

… 32 more

The build script for the sub project starts like this:

buildscript { // this is to get the code for the 'release' plugin
 project.ext.repoURL = "http://${repoHost}/repo"
 repositories { maven { url repoURL } }
 dependencies { classpath 'com.github.townsfolk:gradle-release:1.2' }
  apply plugin: 'maven'
apply from: '../versions.gradle'
 // this just defines some properties
  group = 'com.mydomain.myproject'
  defaultTasks 'allRelease'
  repositories {
 maven { url repoURL }
  // in here I just define a bunch of properties with project.ext.blah = 'blah'
// check a couple environment variables etc.
  task build(dependsOn: 'allRelease')
// line 41 where it claims 'build' already exists

Does the ‘maven’ plugin now create a ‘build’ task?

I had a look at the plugin hierarchy. The Maven plugin internally applies the ‘BasePlugin’. The ‘BasePlugin’ in turn applies the ‘LifecycleBasePlugin’. ‘LifecycleBasePlugin’ does create a task named ‘build’.

Then this is something that has changed since Gradle 2.2.1.

I believe the ‘maven’ plugin did things conditionally based on if the ‘java’ plugin was applied or not. Has that changed?

In any case, something has caused a regression. The question is will it be addressed in the Gradle code, or is it something I will need to adjust for if I move to 2.3?

We fixed this regression for Gradle-2.3-rc-1. If you can try it out and confirm it works for you, that would be great.

The bulid works with 2.3-rc-1

I now get the message: Defining custom æbuildÆ task is deprecated when using standard lifecycle plugin has been deprecated and is scheduled to be removed in Gradle 3.0

(Note the characters that appear to be intended as quotes around “build”)

Does this now mean that it will be not possible for my build script to work with without modifications when running with both Gradle 2.2.1 and Gradle 3.0? (Since with 2.2.1 the “build” task was not present, I had to create it.)

You can do this…

configure(tasks.maybeCreate(“build”)) {

That will work with all versions.