[GRADLE-1610] no exception when task with the same name is added Created: 14/Jun/11  Updated: 04/Jan/13  Resolved: 22/Jun/11

Status: Resolved
Project: Gradle
Affects Version/s: 1.0-milestone-3
Fix Version/s: None

Type: Bug
Reporter: Szczepan Faber Assignee: Unassigned
Resolution: Not A Bug Votes: 0


Issue leads to very confusing behavior, see ticket: GRADLE-1605

Comment by Szczepan Faber [ 14/Jun/11 ]

Consider the example:

project(':api') {
  task foo << { println 'yo!' }

task main
main.dependsOn task(':api:foo')

When running the 'main' task no exception is thrown even though we're adding the task that already exists.

Build should fail as ':api:foo' is added twice. This way the user know that he misconfigured the dependsOn clause and can fix it by doing:

main.dependsOn ':api:foo'
Comment by Adam Murdoch [ 21/Jun/11 ]

You're not adding the same task twice. The parameter to task() is interpreted as a task name, not a task path. So the call to task(':api:foo') in the root project adds a task with name ':api:foo' to the root project, ie it's adding task '::api:foo', not ':api:foo'.

Instead, task() should either fail when a path is passed to it, or should treat its parameter as a path and add the task to the appropriate project. Either way, then you'd get an exception in the above case.

Comment by Szczepan Faber [ 22/Jun/11 ]

We should fix GRADLE-1631

Generated at Wed Jun 30 11:59:56 CDT 2021 using Jira 8.4.2#804003-sha1:d21414fc212e3af190e92c2d2ac41299b89402cf.