On Tue, May 4, 2010 at 02:17, Peter Ledbrook <[email protected]> wrote:

> Hi,
>
> My old Grails plugin for Gradle creates a default rule like so:
>
>  // Convert any task executed from the command line into the
>  // Grails equivalent command.
>  project.tasks.addRule("Grails command") { String name ->
>      // Gradle has a tendency to want to create 'args' and 'env'
>      // tasks, so block it from doing so.
>      if (name == "args" || name == "env") return
>
>      // Add a task for the given Grails command.
>      project.task(name) << {
>          runGrailsWithProps(GrailsNameUtils.getNameFromScript(name),
> project)
>      }
>  }
>
> The trouble is, if this plugin is applied to a build file and the user
> then adds a custom task, say "myTask", then when that custom task is
> called:
>
>  gradle myTask
>
> Gradle complains that the task already exists. Should I change the way
> that the plugin adds the rule?
>

You could project.tasks.replace(String) or replace(String, Class) if you
find that task is already defined.


> Thanks,
>
> Peter
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>    http://xircles.codehaus.org/manage_email
>
>
>


-- 
Jason Porter

Software Engineer
Open Source Advocate

PGP key id: 926CCFF5
PGP key available at: keyserver.net, pgp.mit.edu

Reply via email to