Aliasing commonly repeated tasks combination

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Aliasing commonly repeated tasks combination

evgenyg
Hi,

What do you think of the following feature suggestion to Gradle: being able to easily alias commonly repeated commands combinations. For example, I run "gradle build deploy -PnoGroovy -x test -x about" very frequently (lightweight build & deploy) and "gradle clean build deploy" less frequently (full build & deploy).

If I could map, say, "lightweight" or "l" to "build deploy -PnoGroovy -x test -x about" and "full" or "f" to "clean build deploy" in "build.gradle", then I could simply run "gradle lightweight" or "gradle l" or "gradle f".

This is not a regular task dependency but merely a shortcut to command-line combinations typed, mapped as a String to some shorter command.


Best regards,
Evgeny
evgeny-goldin.com
Reply | Threaded
Open this post in threaded view
|

Re: Aliasing commonly repeated tasks combination

Philippe Lhoste
On 22/06/2011 14:49, evgenyg wrote:

> What do you think of the following feature suggestion to Gradle: being able
> to easily alias commonly repeated commands combinations. For example, I run
> *"gradle build deploy -PnoGroovy -x test -x about"* very frequently
> (lightweight build&  deploy) and *"gradle clean build deploy"* less
> frequently (full build&  deploy).
>
> If I could map, say, "lightweight" or "l" to *"build deploy -PnoGroovy -x
> test -x about"* and "full" or "f" to *"clean build deploy"* in
> "build.gradle", then I could simply run "gradle lightweight" or "gradle l"
> or "gradle f".
>
> This is not a regular task dependency but merely a shortcut to command-line
> combinations typed, mapped as a String to some shorter command.

Don't see this as a criticism of your suggestion, but as a possible workaround (before
seeing the suggestion implemented?).

Why don't you use the shell facilities of your system to do such aliases? Since these are
common tasks, it can be efficient to do it this way. Unix' shells certainly allows that,
even Windows allows this (with the not-so-known doskey's macrofile option).

Advantage of your proposal is that such a solution built in Gradle would work on all
systems (and comes with the build file).

--
Philippe Lhoste
--  (near) Paris -- France
--  http://Phi.Lho.free.fr
--  --  --  --  --  --  --  --  --  --  --  --  --  --


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

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Aliasing commonly repeated tasks combination

evgenyg
Yes, I have bunch of batch scripts already, optimizing most of commands launched daily, like "m" for "mvn -e clean install" and "gr" for "gradle -S --no-color".

But to keep adding those small scripts for each project ever developed with Gradle means polluting my command-line space and soon I start running out of comfortable and memorable ones :) If "build.gradle" keeps aliases then a) they're portable for any platform and b) they're specific for the given project only. So "gr f" in one project isn't the same as "gr f" in another one.

Honestly, I haven't thought of solution yet, but planned to look into feeding the String to GradleMain.

Best regards,
Evgeny
evgeny-goldin.com
Reply | Threaded
Open this post in threaded view
|

Re: Aliasing commonly repeated tasks combination

Luke Daley-2

On 24/06/2011, at 7:58 AM, evgenyg wrote:

> Yes, I have bunch of batch scripts already, optimizing most of commands
> launched daily, like "m" for "mvn -e clean install" and "gr" for "gradle -S
> --no-color".
>
> But to keep adding those small scripts for each project ever developed with
> Gradle means polluting my command-line space and soon I start running out of
> comfortable and memorable ones :) If "build.gradle" keeps aliases then a)
> they're portable for any platform and b) they're specific for the given
> project only. So "gr f" in one project isn't the same as "gr f" in another
> one.
>
> Honestly, I haven't thought of solution yet, but planned to look into
> feeding the String to GradleMain.


It's quite an interesting idea.

I'm thinking of it as a kind of execution layer on top of direct task executions. Something like…

targets {
        lightweight  {
                command "build deploy -PnoGroovy -x test -x about"
                description "Quick build and deploy"
        }
}

or…

targets {
        lightweight  "build deploy -PnoGroovy -x test -x about"
}

There are a bunch of questions about how these things compose though. What does the following do?

gradle lightweight test

It may be as simple as expanding each in turn, i.e.…

gradle build deploy -PnoGroovy -x test -x about test


At the very least it is worth opening a ticket for to discuss further.

--
Luke Daley
Principal Engineer, Gradleware
http://gradleware.com

Please vote Gradle for JAX Awards » http://vote.jax-awards.com




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

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Aliasing commonly repeated tasks combination

Adam Murdoch
In reply to this post by evgenyg

On 22/06/2011, at 10:49 PM, evgenyg wrote:

Hi,

What do you think of the following feature suggestion to Gradle: being able
to easily alias commonly repeated commands combinations. For example, I run
*"gradle build deploy -PnoGroovy -x test -x about"* very frequently
(lightweight build & deploy) and *"gradle clean build deploy"* less
frequently (full build & deploy).

This looks like something you could code up in your build script as a lifecycle task:

task minimalDeploy {
    dependOn assemble, deploy
    gradle.taskGraph.whenReady { graph -> if ( graph.hasTask(it) ) { project.noGroovy = true } }
}

To me, there's no difference between a lifecycle task, which gives a human-friendly name to some workflow step, and an alias, which also gives a human-friendly name to some workflow step. Instead of adding support for aliases, I'd rather improve our support for defining tasks which do more than just dependOn other tasks.



If I could map, say, "lightweight" or "l" to *"build deploy -PnoGroovy -x
test -x about"* and "full" or "f" to *"clean build deploy"* in
"build.gradle", then I could simply run "gradle lightweight" or "gradle l"
or "gradle f".

This is not a regular task dependency but merely a shortcut to command-line
combinations typed, mapped as a String to some shorter command.




-----
Best regards,

Evgeny

evgeny-goldin.com

--
View this message in context: http://gradle.1045684.n5.nabble.com/Aliasing-commonly-repeated-tasks-combination-tp4513918p4513918.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




--
Adam Murdoch
Gradle Co-founder
http://www.gradle.org
VP of Engineering, Gradleware Inc. - Gradle Training, Support, Consulting
http://www.gradleware.com

Reply | Threaded
Open this post in threaded view
|

Re: Aliasing commonly repeated tasks combination

Eric Berry
It's far from perfect, but I created a small plugin to alias gradle commands.
https://launchpad.net/gradle-aliases

Once installed you can run 'gradle createAlias'. It'll prompt you for the alias name, and the commands (entered as you would on the command line). This creates a groovy file in the project .gradle directory 'aliases.groovy'.

The format of the file is really simple, and the file can manually be edited with the aliases showing up as tasks.

You should then see the aliases appear when 'gradle tasks' is run.

It's pretty stupid simple though, and doesn't work with other tasks that require user input.

Still, has been pretty useful to me. Hopefully it'll be useful for others. :)

Cheers,
Eric

On Thu, Jun 23, 2011 at 5:07 PM, Adam Murdoch <[hidden email]> wrote:

On 22/06/2011, at 10:49 PM, evgenyg wrote:

Hi,

What do you think of the following feature suggestion to Gradle: being able
to easily alias commonly repeated commands combinations. For example, I run
*"gradle build deploy -PnoGroovy -x test -x about"* very frequently
(lightweight build & deploy) and *"gradle clean build deploy"* less
frequently (full build & deploy).

This looks like something you could code up in your build script as a lifecycle task:

task minimalDeploy {
    dependOn assemble, deploy
    gradle.taskGraph.whenReady { graph -> if ( graph.hasTask(it) ) { project.noGroovy = true } }
}

To me, there's no difference between a lifecycle task, which gives a human-friendly name to some workflow step, and an alias, which also gives a human-friendly name to some workflow step. Instead of adding support for aliases, I'd rather improve our support for defining tasks which do more than just dependOn other tasks.



If I could map, say, "lightweight" or "l" to *"build deploy -PnoGroovy -x
test -x about"* and "full" or "f" to *"clean build deploy"* in
"build.gradle", then I could simply run "gradle lightweight" or "gradle l"
or "gradle f".

This is not a regular task dependency but merely a shortcut to command-line
combinations typed, mapped as a String to some shorter command.




-----
Best regards,

Evgeny

evgeny-goldin.com

--
View this message in context: http://gradle.1045684.n5.nabble.com/Aliasing-commonly-repeated-tasks-combination-tp4513918p4513918.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




--
Adam Murdoch
Gradle Co-founder
http://www.gradle.org
VP of Engineering, Gradleware Inc. - Gradle Training, Support, Consulting
http://www.gradleware.com




--
Learn from the past. Live in the present. Plan for the future.
Blog: http://eric-berry.blogspot.com
jEdit <http://www.jedit.org> - Programmer's Text Editor
Bazaar <http://bazaar.canonical.com> - Version Control for Humans
Reply | Threaded
Open this post in threaded view
|

Re: Aliasing commonly repeated tasks combination

evgenyg
Awesome, Eric, will try it right away. Thanks for making it and sharing it here!
Best regards,
Evgeny
evgeny-goldin.com