[GRADLE-496] dependsOn behavior - Improvement for user's guide Created: 22/May/09  Updated: 04/Jan/13  Resolved: 28/May/09

Status: Resolved
Project: Gradle
Affects Version/s: 0.6
Fix Version/s: 0.6.1

Type: Improvement
Reporter: Tomek Kaczanowski Assignee: Hans Dockter
Resolution: Fixed Votes: 0

Attachments: File build.gradle     File build_updated.gradle     File dependency_on_non_defined_tasks.diff    

 Description   

Hi,

I have come across this bug when trying to reference many not-yet-defined tasks with square brackets syntax.

Looks like the behaviour of dependsOn with apostrophes and square brackets is inconsistent if depending on not yet defined tasks. In short, it works fine with '' but crashes with []

example build (see attachment)

// THIS WORKS FINE
task dependsOnApostrophe (dependsOn: 'taskA')

// THE LINE BELOW CRASHES THE BUILD
task dependsOnSquareBracket (dependsOn: [taskA])

task taskA {
println "task A"
}

tomek@tomek-desktop:~$ gradle -t

Build failed with an exception.
Run with -s or -d option to get more details. Run with -f option to get the full (very verbose) stacktrace.

Build file '/home/tomek/build.gradle' line: 5

A problem occurred evaluating root project 'tomek'.
Cause: Could not find property 'taskA' on root project 'tomek'.

BUILD FAILED

if line
task dependsOnSquareBracket (dependsOn: [taskA])
is commented than everything works fine.

If this line
task dependsOnSquareBracket (dependsOn: [taskA])
appears after taskA definition, than it also works.


best regards
Tomek Kaczanowski
http://kaczanowscy.pl/tomek



 Comments   
Comment by Tomek Kaczanowski [ 22/May/09 ]

the problem is there, but not exactly where I thought it is

it looks like this. If taskA is not yet defined, you can create tasks that depends on it using its name in apostrophes, like this

task depA (dependsOn: 'taskA')
task depB (dependsOn: ['taskA'])

but you cant refer to it without apostrophes
task depA (dependsOn: taskA)
task depB (dependsOn: [taskA])

I don't know if it's a bug or a feature but surely it is not explained in the user guide.


best regards
Tomek Kaczanowski

Comment by Tomek Kaczanowski [ 27/May/09 ]

Ok, so as I've found it in documentation - it is stated clearly (in some other place) that this is an expected behaviour.

I'd suggest to add one sentence to the section that shows how to add dependency to a task that is not yet defined to make things perfectly clear: "Please notice, that you can't use a shortcut notation (see Section 4.6, "Shortcut notations") when referring to task, which is not defined yet."

patch included

Comment by Tomek Kaczanowski [ 27/May/09 ]

documentation patch

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