You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@bigtop.apache.org by Roman Shaposhnik <ro...@shaposhnik.org> on 2015/01/04 05:49:44 UTC

Gradle as the engine for frequent task automation

Hi!

there was a thread recently that suggested Graddle
as a great place for all the snippets of code we need
for the common tasks around Bigtop (test execution,
puppet, etc.). I've started to play with the idea for
my build stuff and ran into a slight issue.

I can't quite figure out what's the best way to pass
arguments to the scripts that I'm now turning into
gradle tasks.

I guess I can do this:
   $ gradle puppet-deploy -Dfoo=bar ...
but it feels awkward (most because there's
not even a chance for any kind of help being
printed out on task usage).

Thoughts?

Thanks,
Roman.

Re: Gradle as the engine for frequent task automation

Posted by Konstantin Boudnik <co...@apache.org>.
On Sun, Jan 04, 2015 at 07:28PM, Roman Shaposhnik wrote:
> On Sun, Jan 4, 2015 at 7:21 PM, Konstantin Boudnik <co...@apache.org> wrote:
> > Following your example you should be able to do something like
> >
> >     GreetingTask {
> >       greeting = System.properties['GreetingTask.greeting'] ?: 'roman'
> >     }
> >
> > which will produce the desired result, no?
> 
> Totally! I was just hoping for a little bit of magic setters. But may be
> being explicit is actually a good thing.

Yeah, I hear you. I've tried to play with a couple of different things, but
couldn't find a good way to auto-magically influence a class' member via a
sysprop.

Cos

Re: Gradle as the engine for frequent task automation

Posted by Roman Shaposhnik <ro...@shaposhnik.org>.
On Sun, Jan 4, 2015 at 7:21 PM, Konstantin Boudnik <co...@apache.org> wrote:
> Following your example you should be able to do something like
>
>     GreetingTask {
>       greeting = System.properties['GreetingTask.greeting'] ?: 'roman'
>     }
>
> which will produce the desired result, no?

Totally! I was just hoping for a little bit of magic setters. But may be
being explicit is actually a good thing.

Thanks,
Roman.

Re: Gradle as the engine for frequent task automation

Posted by Konstantin Boudnik <co...@apache.org>.
Following your example you should be able to do something like

    GreetingTask {
      greeting = System.properties['GreetingTask.greeting'] ?: 'roman' 
    }

which will produce the desired result, no?
  Cos

On Sun, Jan 04, 2015 at 05:57PM, Roman Shaposhnik wrote:
> On Sun, Jan 4, 2015 at 7:46 AM, jay vyas <ja...@gmail.com> wrote:
> > possibly a similar issue which I dealt with: I just added argument and user
> > guidance stuff  into settings.gradle,
> > https://github.com/apache/bigtop/blob/master/bigtop-tests/smoke-tests/settings.gradle
> 
> I think this is a fine approach, but I was looking for something more
> generic. Consider
> this: if I defined a custom task along the following lines:
> 
> class GreetingTask extends DefaultTask {
>     String greeting = 'hello from GreetingTask'
> 
>     @TaskAction
>     def greet() {
>         println greeting
>     }
> }
> 
> I can then utilize it in my build.gradle as follows:
> 
>    GreetingTask {
>         greeting = 'roman'
>     }
> 
> I wish there was a generic way of doing and equivalent
> from the command line a'la:
> 
> $ gradle GreetingTask -DGreetingTask.greeting=roman
> 
> 
> Thanks,
> Roman.

Re: Gradle as the engine for frequent task automation

Posted by Roman Shaposhnik <ro...@shaposhnik.org>.
On Sun, Jan 4, 2015 at 7:46 AM, jay vyas <ja...@gmail.com> wrote:
> possibly a similar issue which I dealt with: I just added argument and user
> guidance stuff  into settings.gradle,
> https://github.com/apache/bigtop/blob/master/bigtop-tests/smoke-tests/settings.gradle

I think this is a fine approach, but I was looking for something more
generic. Consider
this: if I defined a custom task along the following lines:

class GreetingTask extends DefaultTask {
    String greeting = 'hello from GreetingTask'

    @TaskAction
    def greet() {
        println greeting
    }
}

I can then utilize it in my build.gradle as follows:

   GreetingTask {
        greeting = 'roman'
    }

I wish there was a generic way of doing and equivalent
from the command line a'la:

$ gradle GreetingTask -DGreetingTask.greeting=roman


Thanks,
Roman.

Re: Gradle as the engine for frequent task automation

Posted by jay vyas <ja...@gmail.com>.
possibly a similar issue which I dealt with: I just added argument and user
guidance stuff  into settings.gradle,
https://github.com/apache/bigtop/blob/master/bigtop-tests/smoke-tests/settings.gradle
?


On Sun, Jan 4, 2015 at 2:24 AM, Konstantin Boudnik <co...@apache.org> wrote:

> On Sat, Jan 03, 2015 at 08:49PM, Roman Shaposhnik wrote:
> > Hi!
> >
> > there was a thread recently that suggested Graddle
> > as a great place for all the snippets of code we need
> > for the common tasks around Bigtop (test execution,
> > puppet, etc.). I've started to play with the idea for
> > my build stuff and ran into a slight issue.
> >
> > I can't quite figure out what's the best way to pass
> > arguments to the scripts that I'm now turning into
> > gradle tasks.
> >
> > I guess I can do this:
> >    $ gradle puppet-deploy -Dfoo=bar ...
> > but it feels awkward (most because there's
> > not even a chance for any kind of help being
> > printed out on task usage).
>
> Are you referring to a task usage info? Do you think adding some info into
> a
> task description will be sufficient? If not, I'd consider adding a new task
> that will be printing out tasks usage? The usage info could be stored in a
> separate file perhaps?
>
> Or am I barking on a wrong tree?
>   Cos
>
>


-- 
jay vyas

Re: Gradle as the engine for frequent task automation

Posted by Konstantin Boudnik <co...@apache.org>.
On Sat, Jan 03, 2015 at 08:49PM, Roman Shaposhnik wrote:
> Hi!
> 
> there was a thread recently that suggested Graddle
> as a great place for all the snippets of code we need
> for the common tasks around Bigtop (test execution,
> puppet, etc.). I've started to play with the idea for
> my build stuff and ran into a slight issue.
> 
> I can't quite figure out what's the best way to pass
> arguments to the scripts that I'm now turning into
> gradle tasks.
> 
> I guess I can do this:
>    $ gradle puppet-deploy -Dfoo=bar ...
> but it feels awkward (most because there's
> not even a chance for any kind of help being
> printed out on task usage).

Are you referring to a task usage info? Do you think adding some info into a
task description will be sufficient? If not, I'd consider adding a new task
that will be printing out tasks usage? The usage info could be stored in a
separate file perhaps?

Or am I barking on a wrong tree?
  Cos