I am trying to create a test task rule using the example in grails gradle doc , but I keep getting "a task with the same name already exists".
My build script looks like this:
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-<phase>') { String taskName -> println tasks //shows grails-test-app-xxxxx task. Why? //if (taskName.startsWith('grails-test-app') && taskName != 'grails-test-app') { // task(taskName, type: GrailsTestTask) { // String testPhase = (taskName - 'grails-test-app').toLowerCase() // phases = [testPhase] // } //} }
Running $gradle grails-test-integration or actually nothing from the form $gradle grails-test-app-xxxxxxxx gives the error "Unable to add task" gradle grails-test-app-xxxxxxxx as a task with the same name already exists. "
Can someone please tell me how I can resolve this error? Thanks.
build.gradle gradle grails-plugin
user3240644
source share