Steve Appling wrote:
<clip ...>
While I agree that they are confusingly similar, I'm not sure that the
.do is any more obvious than the trailing <<.
I'm not sure of a better solution here. I have noticed myself making
mistakes while converting our project over to use the new syntax.
Perhaps I'm just slow, but I have already mixed up task and
configuration closures a few times myself.
Previously if you had to do configuration on a newly created task you
had to call configure explicitly like:
createTask('myTask', type:Copy).configure { config here }
Existing tasks could be configured directly, however:
myTask { config here }
I don't think this was previously intended to be a feature, but it did
distinguish the use of the closure.
There is actually a problem with this that I had not noticed related to coding
conventions and curly brackets.
previously we used:
createTask('myCopy', type:Copy).configure
{
from file('mysrc')
into file('mydest')
}
but this won't work:
task myCopy(type:Copy)
{
from file('mysrc')
into file('mydest')
}
This fails with:
Could not compile build file 'C:\test\gradleconfig\build.gradle'.
Cause: startup failed, build_gradle: 8: Ambiguous expression could be a
parameterless closure expression, an isolated open code block, or it may
continue a previous statement;
I can only get the new task syntax for configuration to work if we put the curly
bracket on the same line as the task like:
task myCopy(type:Copy) {
from file('mysrc')
into file('mydest')
}
I understand that having the opening bracket on the same line is much more
standard practice now, but we have an 11 year old Java coding standard that
everyone is used to. I would hate to have our build tool be the only exception
to this.
--
Steve Appling
Automated Logic Research Team
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email