title: Grails gradle "a task with that name already exists"
body: <p>I'm trying to create a test task rule using the example provided <a href="http://grails.github.io/grails-gradle-plugin/docs/manual/guide/usage.html#test">in the grails gradle doc</a> but I keep getting "a task with that name already exists" error.</p>
  
  <p>My build script is as follows:</p>
  
  <pre><code>import org.grails.gradle.plugin.tasks.* //Added import here else fails with "Could not find property GrailsTestTask"
  
  buildscript {
    repositories {
      jcenter()
    }
    dependencies {
      classpath "org.grails:grails-gradle-plugin:2.0.0"
    }
  }
  
  version "0.1"
  group "example"
  
  apply plugin: "grails"
  
  repositories {
    grails.central() //creates a maven repo for the Grails Central repository (Core libraries and plugins)
  }
  
  grails {
    grailsVersion = '2.3.5'
    groovyVersion = '2.1.9'
    springLoadedVersion '1.1.3'
  }
  
  dependencies {
    bootstrap "org.grails.plugins:tomcat:7.0.50" // No container is deployed by default, so add this
    compile 'org.grails.plugins:resources:1.2' // Just an example of adding a Grails plugin
  }
  
  project.tasks.addRule('Pattern: grails-test-app-&lt;phase&gt;') { String taskName -&gt;
      println tasks //shows grails-test-app-xxxxx task. Why?
      //if (taskName.startsWith('grails-test-app') &amp;&amp; taskName != 'grails-test-app') {
      //    task(taskName, type: GrailsTestTask) {
      //        String testPhase = (taskName - 'grails-test-app').toLowerCase()
      //        phases = [testPhase]
      //    }
      //}
  }
  </code></pre>
  
  <p>Running <code>$gradle grails-test-integration</code> 
  or in fact anything of the form  <code>$gradle grails-test-app-xxxxxxxx</code> yields the error "Cannot add task 'gradle grails-test-app-xxxxxxxx as a task with that name already exists".</p>
  
  <p>Can someone please advise how I can resolve this error? Thanks.</p>