Extension property from command line

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

Extension property from command line

Cédric Champeau
Hi,

I am writing a plugin for Gradle and I'd like to make sure that the user
may pass a property on command line instead of having to put it in
build.gradle (this is for "one shot" commands).

I have a plugin extension class, so my build.gradle file has a
configuration snippet like this:

cloudfoundryService {
     serviceName = 'foo'
     ...
}

It works fine this way, but what I'd like to do is to allow specifying
that "serviceName" from command-line:

./gradlew -PcloudfoundryService.serviceName='foo' my-task

But this doesn't seem to work. Is it supported or should I use a system
property instead ?

Thanks!

--
Cédric Champeau
SpringSource - A Division Of VMware
http://www.springsource.com/
http://twitter.com/CedricChampeau


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

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Extension property from command line

Peter Niederwieser
Setting an extension property from the command line is desirable but not something that's currently supported (it's not as easy as it sounds). For now, you'll have to use an extra system (-D) or project (-P) property. The extension property can then default to the former's value.

--
Peter Niederwieser
Principal Engineer, Gradleware
http://gradleware.com
Creator, Spock Framework
http://spockframework.org
Twitter: @pniederw
Reply | Threaded
Open this post in threaded view
|

Re: Extension property from command line

Cédric Champeau
Ok, thanks for the quick answer!

Le 08/03/2012 22:00, Peter Niederwieser a écrit :

> Setting an extension property from the command line is desirable but not
> something that's currently supported (it's not as easy as it sounds). For
> now, you'll have to use an extra system (-D) or project (-P) property. The
> extension property can then default to the former's value.
>
> --
> Peter Niederwieser
> Principal Engineer, Gradleware
> http://gradleware.com
> Creator, Spock Framework
> http://spockframework.org
> Twitter: @pniederw
>
> --
> View this message in context: http://gradle.1045684.n5.nabble.com/Extension-property-from-command-line-tp5548804p5548839.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
>
>
>


--
Cédric Champeau
SpringSource - A Division Of VMware
http://www.springsource.com/
http://twitter.com/CedricChampeau


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

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Extension property from command line

Andrew Oberstar
It's not pretty, but you can continue to use project (-P) properties with the same name as the extension property.  Something like this:

if (project.hasProperty('cloudFoundryService.serviceName')) {
  serviceName = project['cloudFoundryService.serviceName']
}

Andrew Oberstar


On Thu, Mar 8, 2012 at 3:09 PM, Cédric Champeau <[hidden email]> wrote:
Ok, thanks for the quick answer!

Le 08/03/2012 22:00, Peter Niederwieser a écrit :

Setting an extension property from the command line is desirable but not
something that's currently supported (it's not as easy as it sounds). For
now, you'll have to use an extra system (-D) or project (-P) property. The
extension property can then default to the former's value.

--
Peter Niederwieser
Principal Engineer, Gradleware
http://gradleware.com
Creator, Spock Framework
http://spockframework.org
Twitter: @pniederw

--
View this message in context: http://gradle.1045684.n5.nabble.com/Extension-property-from-command-line-tp5548804p5548839.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





--
Cédric Champeau
SpringSource - A Division Of VMware
http://www.springsource.com/
http://twitter.com/CedricChampeau


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

  http://xircles.codehaus.org/manage_email