To override a property defined in the POM use the parâmetro -D
typical of any Java application when invoking mvn
For example to deploy assets shared by applications to a TEST directory:
mvn -P deployShared package -Dshared_dir=/usr/local/Cellar/tomcat/7.0.47/shared
In this example we are overwriting shared_dir during the package phase. This variable is used by the deployShared profile defined in the POM to copy the files to the Tomcat environment (version 7.0.47) used for Test .
The same POM can be used to deploy to the Homologation environment as follows:
mvn -P deployShared package -Dshared_dir=/usr/local/tomcat-7.0.47-homolog/shared
And so on.
The profile deployShared
uses maven-dependency-plugin
and looks like this:
<profile>
<id>deployShared</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.8</version>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<includeScope>runtime</includeScope>
<outputDirectory>${shared_dir}</outputDirectory>
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>false</overWriteSnapshots>
<overWriteIfNewer>true</overWriteIfNewer>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<outputDirectory>${shared_dir}</outputDirectory>
</configuration>
</plugin>
</plugins>
</build>
</profile>