Sean
I'm not sure what you mean by 'function' but gradle scripts are Groovy code.
You can declare methods and execute them as many times and order as you
need.
task A() << {
doStuff()
doOtherStuff()
}
tack B() << {
doOtherStuff()
}
def doStuff() {
}
def doOtherStuff() {
}
I don't think using task.execute() is a good idea. As Gradle chaps are
saying, this internal API might go one day.
Aslo, Gradle is build on convention of declaring dependencies. I had hard
time to understand that when I switched from Ant. But it works rather well.
task A;
task B;
task C;
task D;
A.dependsOn = [D, B, C]
this will execute B > C > D > A
If you need D > B > C > A all you need to do is:
A.dependsOn = [D, B, C]
C.dependsOn B
B.dependsOn D
This is problematic however when you don't want to declare dependencies
between C and B and D.
Perhaps someone have a better idea? (Gradle not sorting tasks alphabetically
?)
Greg
On Fri, May 27, 2011 at 8:53 AM, Sean Van Buggenum <[email protected]> wrote:
> I came across that problem,
>
> but I think it is partly because I was migrating quite a large unwieldy
> build script from ant to gradle, and the correct use of gradle dependsOn
> just didn't fit what I needed.
> in the end, for some parts of my build script, I ended up in directly
> invoking the execution of the gradle task, so that events happened exactly
> in the order I needed.
>
> eg,
>
> getByName('aggregateModuleTests').execute()
>
> or simply
>
> aggregateModuleTests.execute()
>
> I'm not sure if there is any such thing as a simple 'function' allowed in a
> gradle script .. ?
> and as I didn't know, and didn't see any reference to such an entity, I was
> just directly executing tasks.
>
>
> On 27 May 2011 17:38, Greg Gigon <[email protected]> wrote:
>
>> Yes.
>>
>> I assume that the whole Idea of Gradle is to declare what tasks depend on
>> what and Gradle will execute them in the right order.
>> For example if A depends on C and C depends on B, if you execute task A,
>> the order will be B > C > A.
>>
>> With multiple dependency it's exactly the same deal. Assumption is that
>> Gradle will work it out. Therefore it checks each task dependency. If a task
>> have multiple dependencies then those are sorted.
>>
>> If you want some tasks in multiple dependencies to be executed in specific
>> order, add dependencies between them.
>> For example, if you are in the situation:
>>
>> task A;
>> A.dependsOn C
>> A.dependsOn B
>>
>> those will be executed B > C > A
>> if you are after order C > B > A you need to declare B.dependsOn C
>>
>> task A;
>> A.dependsOn C
>> A.dependsOn B
>> B.dependsOn C
>>
>> Cheers, Greg
>>
>> On Thu, May 26, 2011 at 11:53 PM, bart <[email protected]> wrote:
>>
>>> I'm running into this same issue. Does anyone have any advice?
>>>
>>> --
>>> View this message in context:
>>> http://gradle.1045684.n5.nabble.com/tasks-and-dependsOn-order-not-in-the-order-given-tp3339151p4430335.html
>>> Sent from the gradle-user mailing list archive at Nabble.com.
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe from this list, please visit:
>>>
>>> http://xircles.codehaus.org/manage_email
>>>
>>>
>>>
>>
>>
>> --
>> Greg Gigon
>> http://greggigon.com
>> http://www.linkedin.com/in/greggigon
>> Twitter: gregorygigon <http://twitter.com/gregorygigon>
>>
>> "You see, wire telegraph is a kind of a very, very long cat. You pull his
>> tail in New York and his head is meowing in Los Angeles. Do you understand
>> this? And radio operates exactly the same way: you send signals here, they
>> receive them there. The only difference is that there is no cat."
>> Albert Einstein, when asked to describe radio
>>
>>
>
--
Greg Gigon
http://greggigon.com
http://www.linkedin.com/in/greggigon
Twitter: gregorygigon <http://twitter.com/gregorygigon>
"You see, wire telegraph is a kind of a very, very long cat. You pull his
tail in New York and his head is meowing in Los Angeles. Do you understand
this? And radio operates exactly the same way: you send signals here, they
receive them there. The only difference is that there is no cat."
Albert Einstein, when asked to describe radio