I’m using Maven 3.0.3. I want to run a task to copy environment specific properties before I package my WAR file. Below is my task.
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<phase>prepare-package</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<delete file="${project.build.outputDirectory}/environment.properties"/>
<copy file="src/main/resources/${env}_environment.properties"
tofile="${project.build.outputDirectory}/environment.properties" />
<delete file="${project.build.outputDirectory}/${env}_hibernate.cfg.xml"/>
<copy file="src/main/resources/${env}_hibernate.cfg.xml"
tofile="${project.build.outputDirectory}/hibernate.cfg.xml" />
<echo message="Copied ${env}_hibernate.cfg.xml properties. " />
</tasks>
</configuration>
</execution>
</executions>
</plugin>
However, when start up my app, invoking a goal from my Tomcat profile, by running “mvn -P tomcat tomcat:run”, the above task doesn’t get run. Any ideas how I can correct this? The Tomcat profile I include is below. – Dave
<profile>
<id>tomcat</id>
<activation>
<property>
<name>env</name>
<value>dev</value>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>tomcat-maven-plugin</artifactId>
<version>1.1</version>
<configuration>
<charset>UTF-8</charset>
<path>/leadsmonitor</path>
<server>nnadbmon-tomcat</server>
<update>true</update>
<url>http://nnadbmon.mydomain.com:8080/manager</url>
<warFile>target/leadsmonitor.war</warFile>
<systemProperties>
<JAVA_OPTS>-Xms256m -Xmx512m -XX:MaxPermSize=256m -XX:NewRatio=6 -XX:+CMSClassUnloadingEnabled -XX:+CMSPermGenSweepingEnabled -verbose:gc"</JAVA_OPTS>
</systemProperties>
</configuration>
</plugin>
</plugins>
</build>
</profile>
You should attach it to the
compilephase. This will actually get executed after the compilation has finished.