You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by David Williams <dn...@gmail.com> on 2007/07/30 19:03:52 UTC
Passing System Variables to Maven
Hi Everyone,
How do you pass system environment variables like system date or system time
to maven. I'm running maven on a windows machine.
Thanks,
David
Re: Passing System Variables to Maven
Posted by Steven Rowe <sa...@syr.edu>.
Hi David,
I have used an antrun plugin execution to generate a timestamp
properties file in the "initialize" phase, like this:
<properties>
...
<generated-resources-dir>
target/generated-resources
</generated-resources-dir>
...
</properties>
<build>
...
<plugins>
...
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>generate-timestamp-properties-file</id>
<phase>initialize</phase>
<goals><goal>run</goal></goals>
<configuration>
<tasks>
<mkdir dir="${generated-resources-dir}"/>
<tstamp>
<format property="timestamp"
pattern="MM/dd/yyyy HH:mm:ss"/>
</tstamp>
<delete
file="${generated-resources-dir}/timestamp.properties"
failonerror="false"/>
<echo message="timestamp=${timestamp}"
file="${generated-resources-dir}/timestamp.properties"/>
</tasks>
</configuration>
</execution>
...
</executions>
</plugin>
...
</plugins>
...
</build>
Hope it helps,
Steve
David Williams wrote:
> Guys,
>
> Thanks for your responses. What I really want to do is pass the current
> system date and or time to a properties file. I already know what I need to
> do to filter in maven but I'm trying to figure out the best way to get these
> variables in a build.properties file for example. I'm currently using Maven
> 2.0.6. Some projects are building with java 1.4 and some with java 1.5.
>
> Thanks again for your responses,
>
> David
>
> On 7/31/07, Eric Redmond <er...@gmail.com> wrote:
>> That's fine, then stick them in the settings.xml. But you missed my point:
>> "env" access via properties won't be around in the next version of Maven,
>> so
>> they aren't a good suggestion.
>>
>> Eric
>>
>> On 7/31/07, Graham Leggett <mi...@sharp.fm> wrote:
>>> Eric Redmond wrote:
>>>
>>>> I would stick to -D options. "env" variables are going away in Maven
>>> soon.
>>>
>>> -D options are simply command line options, they are not an environment.
>>>
>>> Trying to create a pretend environment using -D violates the principle
>>> of least astonishment in a big way, and is a major headache if you have
>>> system specific information that maven requires, such as the location of
>>> eclipse for the pde-maven-plugin.
>>>
>>> Regards,
>>> Graham
>>
>> --
>> Eric Redmond
>> http://blog.propellors.net
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: Passing System Variables to Maven
Posted by David Williams <dn...@gmail.com>.
Guys,
Thanks for your responses. What I really want to do is pass the current
system date and or time to a properties file. I already know what I need to
do to filter in maven but I'm trying to figure out the best way to get these
variables in a build.properties file for example. I'm currently using Maven
2.0.6. Some projects are building with java 1.4 and some with java 1.5.
Thanks again for your responses,
David
On 7/31/07, Eric Redmond <er...@gmail.com> wrote:
>
> That's fine, then stick them in the settings.xml. But you missed my point:
> "env" access via properties won't be around in the next version of Maven,
> so
> they aren't a good suggestion.
>
> Eric
>
> On 7/31/07, Graham Leggett <mi...@sharp.fm> wrote:
> >
> > Eric Redmond wrote:
> >
> > > I would stick to -D options. "env" variables are going away in Maven
> > soon.
> >
> > -D options are simply command line options, they are not an environment.
> >
> > Trying to create a pretend environment using -D violates the principle
> > of least astonishment in a big way, and is a major headache if you have
> > system specific information that maven requires, such as the location of
> > eclipse for the pde-maven-plugin.
> >
> > Regards,
> > Graham
> > --
> >
> >
>
>
> --
> Eric Redmond
> http://blog.propellors.net
>
Re: Passing System Variables to Maven
Posted by Eric Redmond <er...@gmail.com>.
That's fine, then stick them in the settings.xml. But you missed my point:
"env" access via properties won't be around in the next version of Maven, so
they aren't a good suggestion.
Eric
On 7/31/07, Graham Leggett <mi...@sharp.fm> wrote:
>
> Eric Redmond wrote:
>
> > I would stick to -D options. "env" variables are going away in Maven
> soon.
>
> -D options are simply command line options, they are not an environment.
>
> Trying to create a pretend environment using -D violates the principle
> of least astonishment in a big way, and is a major headache if you have
> system specific information that maven requires, such as the location of
> eclipse for the pde-maven-plugin.
>
> Regards,
> Graham
> --
>
>
--
Eric Redmond
http://blog.propellors.net
Re: Passing System Variables to Maven
Posted by Graham Leggett <mi...@sharp.fm>.
Eric Redmond wrote:
> I would stick to -D options. "env" variables are going away in Maven soon.
-D options are simply command line options, they are not an environment.
Trying to create a pretend environment using -D violates the principle
of least astonishment in a big way, and is a major headache if you have
system specific information that maven requires, such as the location of
eclipse for the pde-maven-plugin.
Regards,
Graham
--
Re: Passing System Variables to Maven
Posted by Eric Redmond <er...@gmail.com>.
I would stick to -D options. "env" variables are going away in Maven soon.
Eric
On 7/30/07, Graham Leggett <mi...@sharp.fm> wrote:
>
> David Williams wrote:
>
> > How do you pass system environment variables like system date or system
> time
> > to maven. I'm running maven on a windows machine.
>
> You can access environment variables by using maven variables of the
> form ${env.VARIABLE}.
>
> So ${env.PATH} would be your path, for example.
>
> As far as I am aware, will only work on JDK v1.5 and above, as it wasn't
> possible to read environment variables in Java before then.
>
> Regards,
> Graham
> --
>
>
--
Eric Redmond
http://blog.propellors.net
Re: Passing System Variables to Maven
Posted by Graham Leggett <mi...@sharp.fm>.
David Williams wrote:
> How do you pass system environment variables like system date or system time
> to maven. I'm running maven on a windows machine.
You can access environment variables by using maven variables of the
form ${env.VARIABLE}.
So ${env.PATH} would be your path, for example.
As far as I am aware, will only work on JDK v1.5 and above, as it wasn't
possible to read environment variables in Java before then.
Regards,
Graham
--
Re : Passing System Variables to Maven
Posted by er...@videotron.ca.
Hi DavidThose are all already available in the Java environment running Maven. If the property your are looking for is not in the system default, you pass them in the command line using the -D option.Hope it helps.Eric.----- Message d'origine -----De: David Williams <dn...@gmail.com>Date: Lundi, Juillet 30, 2007 1:04 pmObjet: Passing System Variables to MavenÀ: Maven Users List <us...@maven.apache.org>> Hi Everyone,> > How do you pass system environment variables like system date or > system time> to maven. I'm running maven on a windows machine.> > Thanks,> > David>