I'd like to set a property if an environment variable is set. I googled a lot on it and all I found is something similar to the code below, but I keep getting the error:
[FATAL] Non-parseable POM Y:\Maven\parent-pom\pom.xml: TEXT must be immediately followed by END_TAG and not START_TAG (position: START_TAG s een ...roperties"\r\n
classpathref="maven.plugin.classpath" />... @29:55) @ line 29, column 55
That's the code I'm trying, its inside a pom.xml and I ran the command -
mvn --errors deploy
Of course, I'll be happy to get any other solution, if you have other suggestion on how to set a property in pom.xml depending on an environment variable content.
Thanks, Eli
<distributionManagement>
.....
</distributionManagement>
<properties>
<tasks>
<taskdef resource="net/sf/antcontrib/antcontrib.properties"
classpathref="maven.plugin.classpath" />
<if>
<condition>
<equals arg1="${env.WAS60_HOME}" arg2=""\>
</condition>
<then>
<was60.home>${env.WAS60_HOME}</was60.home>
<javac>${was60.home}/java/bin/javac</javac>
</then>
</if>
<if>
<condition>
<equals arg1="${env.WAS85_HOME}" arg2=""\>
</condition>
<then>
<was85.home>${env.WAS85_HOME}</was60.home>
<javac>${was85.home}/java/bin/javac</javac>
</then>
</if>
</tasks>
</properties>
<profiles>
<profile>
<id>was.base.v60</id>
<dependencies>
<dependency>
....
<systemPath>${was60.home}/java/jre/lib/xml.jar</systemPath>
</dependency>
.....
</dependencies>
</profile>
<profile>
<id>was.base.v85</id>
<dependencies>
<dependency>
....
<systemPath>${was85.home}/java/jre/lib/xml.jar</systemPath>
</dependency>
.....
</dependencies>
</profile>
</profiles>
Apparently there is no way to do a proper IF-THEN-ELSE sentence in Maven. At least none that I found.
The closest thing I found was using the "activation" tag. which will activate the profile if the condition in it is met.
There is some bug on multiple conditions in Maven 2.0.X, not sure what's the status of it now -
http://jira.codehaus.org/browse/MNG-4565
So, a code example is answered on the question here -
Maven 2: Run maven-replacer-plugin with conditional replacement value?
But if you want to do something like << IF ... Then ... Else >> You're going to hit you head on a wall doing it. There are other ways, of course and I assume it is done in purpose, so you'll have to follow Maven way.
Thanks to all that tried to help Elyahu