[GRADLE-2515] Possible bug on plugin task override Created: 09/Oct/12  Updated: 04/Jan/13  Resolved: 19/Oct/12

Status: Resolved
Project: Gradle
Affects Version/s: 1.2
Fix Version/s: None

Type: Bug
Reporter: Alexander Jipa Assignee: Szczepan Faber
Resolution: Cannot Reproduce Votes: 0


 Description   

When I'm trying to override a task that is provided from plugin I got a "a task with that name already exists" exception.
I'm not sure if it's expected behavior and if not whose part this is (plugin vendor or gradle) but I think gradle could mediate this.

The behavior is rather strange since the overriden logic seems to work (println writes data to console).

I tried doing the following:

...
apply plugin: 'gradlefx'

task compile(overwrite: true)

{ println 'Overwritten' }

...

I'm not that into gradle internals but with little thinking I figured out that the problem may not be in my override but rather in plugin trying to inject it's own tasks with the same name.

The workaround that helped me is the following:

...
apply plugin: 'gradlefx'

afterEvaluate {
task compile(overwrite: true)

{ println 'Overwritten' }

}
...

Maybe all task overrides should happen after evaluation or I'm missing something?

P.S.
Javadoc for TaskContainer is rather confusing, since the description does mention override option, whereas overwrite is expected.



 Comments   
Comment by Szczepan Faber [ 12/Oct/12 ]

Thanks for reporting the javadoc issue (I've fixed it). Overwrite feature works according to my knowledge (we have integ tests for that). Perhaps the gradlefx also adds the compile task using 'afterEvaluate'?

Generated at Wed Jun 30 12:24:03 CDT 2021 using Jira 8.4.2#804003-sha1:d21414fc212e3af190e92c2d2ac41299b89402cf.