Calling task from another task

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Calling task from another task

Paweł Krupiński
I've been looking for it in the user guide and API, but haven't found it:
Is there a way to execute a gradle task from another gradle task (but
not through dependency), like antcall?

        Paweł
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Calling task from another task

Szczepan Faber
I don't know if there is an antcall equivalent in gradle. Obviously
what you could do is extract a method and call this method from both
tasks - but you probably know this already :)

Cheers,
Szczepan Faber

On Tue, Dec 16, 2008 at 6:04 PM, Paweł Krupiński
<[hidden email]> wrote:
> I've been looking for it in the user guide and API, but haven't found it:
> Is there a way to execute a gradle task from another gradle task (but
> not through dependency), like antcall?
>
>        Paweł
>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Calling task from another task

Szczepan Faber
In reply to this post by Paweł Krupiński
Actually, I've been browsing gradle source code and I found a way to do it:

your_task.execute()

Szczepan

On Tue, Dec 16, 2008 at 6:04 PM, Paweł Krupiński
<[hidden email]> wrote:
> I've been looking for it in the user guide and API, but haven't found it:
> Is there a way to execute a gradle task from another gradle task (but
> not through dependency), like antcall?
>
>        Paweł
>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Calling task from another task

hans_d
Administrator
In reply to this post by Paweł Krupiński

On Dec 16, 2008, at 6:04 PM, Paweł Krupiński wrote:

> I've been looking for it in the user guide and API, but haven't  
> found it:
> Is there a way to execute a gradle task from another gradle task (but
> not through dependency), like antcall?

What is your use case? Why does dependsOn does not work for you?

Szczepan has pointed out that you can use the execute method. It is  
not part of the public API yet, but we might have to change this.

- Hans

--
Hans Dockter
Gradle Project lead
http://www.gradle.org





---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Calling task from another task

Paweł Krupiński
>> I've been looking for it in the user guide and API, but haven't found it:
>> Is there a way to execute a gradle task from another gradle task (but
>> not through dependency), like antcall?
>
> What is your use case? Why does dependsOn does not work for you?
>
> Szczepan has pointed out that you can use the execute method. It is not part
> of the public API yet, but we might have to change this.

He was right - extracting the code to a method is the way to go. I was
just in an ant-y state of mind. :)

            Paweł
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Calling task from another task

Liping Huang
This post has NOT been accepted by the mailing list yet.
In reply to this post by Szczepan Faber
yes, this is very convenient way to call another task from gradle task, so is it possible to pass the parameters via this approach?
Loading...