Is it possible to set a default property in maven3. I can fetch the CATALINA_HOME from bash by following
<properties>
<cargo.tomcat.home>${env.CATALINA_HOME}</cargo.tomcat.home>
</properties>
But if the variable is not set and I run the evaluate expression command I get null object
! mvn org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=cargo.tomcat.home
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Webapp 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-help-plugin:2.1.1:evaluate (default-cli) @ cargo-selenium-springmvc-webapp ---
[INFO] No artifact parameter specified, using 'com.keybroker.spike:cargo-selenium-springmvc-webapp:war:1.0-SNAPSHOT' as project.
[INFO]
null object or invalid expression
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.721s
[INFO] Finished at: Tue Jul 17 16:51:48 CEST 2012
[INFO] Final Memory: 5M/81M
[INFO] ------------------------------------------------------------------------
I would be interested in setting a default $CATALINA_HOME. I don’t mind using another plugin but vanilla maven3 would be best. So what i am looking for
if $CATALINA_HOME is set by bash then use it
otherwise if the is a -DcatalinaHome argument passed to maven, then use that
if all else fails, default to XYZ path for $CATALINA_HOME
Yes, this is possible. I have tested this on Windows 7 and Maven 3.0.4.
FOOis my example environment variable.First, add the following profile to the POM
As you already know, the placeholder
${env.FOO}is used elsewhere in the POM which will be replaced with a real value. The three ways to supply a value are:1) By setting an environment variable
2) Supplying a command line parameter (this will override the environment variable)
which will override the environment value.
3) Not setting
FOOby any of the previous methods, the value in the POM will be activated clause, by the!env.FOOand be set todefault_FOO