I agree - its no more effort hat someone would have to do in an ant build file:
<property environment="env"/> less effort even ;) On Mon, Dec 29, 2008 at 4:16 PM, Adam Murdoch <[email protected]> wrote: > > > Les Hazlewood wrote: > > Obviously, one can put this at the top of their .gradle script and get what > I wanted: > > env = System.getenv() > > I'm not sure if that should be 'built in' as a convenience or not. What do > you think? Should every user be expected to define that line if they want > access to env vars? > > > Adding it to the Gradle API doesn't really seem worth the cost to me. > > > On Mon, Dec 29, 2008 at 1:11 PM, Les Hazlewood < > [email protected]> wrote: > >> Beautiful, thanks :) I just didn't know if there was an alias for >> System.getenv() already built in to Gradle. This would be kinda nice to do >> out of the box: >> >> env['JAVA_HOME'] >> >> Do you think this is a good idea? Should I open a Jira issue for an >> improvement if so? >> >> On Mon, Dec 29, 2008 at 1:07 PM, D'Arcy, Hamlet B < >> [email protected]> wrote: >> >>> I think you'd use the standard Groovy way, right? >>> >>> println System.getenv()['JAVA_HOME'] >>> >>> Should work within the script. It works in mine. >>> >>> -- >>> Hamlet D'Arcy >>> [email protected] >>> >>> > -----Original Message----- >>> > From: Les Hazlewood [mailto:[email protected]] >>> > Sent: Monday, December 29, 2008 11:58 AM >>> > To: [email protected] >>> > Subject: [gradle-user] Gradle easy access to environment variables >>> > >>> > It is not readily apparent to me in the User Guide (Section >>> > 4.3) how to quickly reference environment variables in Gradle scripts. >>> > >>> > I do not want to create environment variables >>> > ORG_GRADLE_PROJECT_propName since I'm trying to support an >>> > existing build where environment variables are already set on >>> > many machines. >>> > >>> > So far, I found I can do the following: >>> > >>> > createTask("init", overwrite: true) { task -> >>> > ant.property(environment: "env"); >>> > println ant.antProject.properties["env.MY_ENV_VAR"] >>> > } >>> > >>> > However, that seems a little hacky. I was assuming that >>> > there was a nicer way to do this in Gradle automatically, for >>> > example, envProps.MY_ENV_VAR. >>> > >>> > Can someone please clarify? >>> > >>> > Thanks, >>> > >>> > Les >>> > >>> > >>> >>> --------------------------------------------------------------------- >>> To unsubscribe from this list, please visit: >>> >>> http://xircles.codehaus.org/manage_email >>> >>> >>> >> > --------------------------------------------------------------------- To > unsubscribe from this list, please visit: > http://xircles.codehaus.org/manage_email
