我有一个Spring framework
项目,其中包含以下三个文件src/main/webapp/WEB-INF
:
project.propterties
project-servlet.xml
project-security.xml
在构建的情况下,我正在尝试maven profiles
按如下方式“注入”上述文件:prod
<profile>
<id>prod-build</id>
<build>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<phase>prepare-package</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<delete
file="${project.build.directory}/${project.build.finalName}/WEB-INF/project.properties" />
<copy file="src/main/config/prod/project.properties"
tofile="${project.build.directory}/${project.build.finalName}/WEB-INF/project.properties" />
</target>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources/prod</directory>
</resource>
</resources>
</build>
</profile>
问题是maven-antrun-plugin
当有机会运行时,war
已经打包好了。蚂蚁<target>
确实运行并进行了适当的更改,但为时已晚。
命令行:
$ mvn -Pprod-build clean install
mvn 输出:
[INFO] --- maven-antrun-plugin:1.7:run (default) @ FocusMVN ---
[INFO] Executing tasks
main:
[copy] Copying 1 file to J:\work\workspace\FocusMVN\target\myproject\WEB-INF
[INFO] Executed tasks
[INFO]
[INFO] --- maven-war-plugin:2.3:war (default-war) @ FocusMVN ---
[INFO] Packaging webapp
[INFO] Assembling webapp [FocusMVN] in [J:\work\workspace\FocusMVN\target\myproject]
[INFO] Processing war project
[INFO] Copying webapp resources [J:\work\workspace\FocusMVN\src\main\webapp]
[INFO] Webapp assembled in [3198 msecs]
[INFO] Building war: J:\work\workspace\FocusMVN\target\myproject.war
[INFO]
[INFO] --- maven-install-plugin:2.3.1:install (default-install) @ FocusMVN ---
[INFO] Installing J:\work\workspace\FocusMVN\target\myproject.war to C:\Users\mansoork\.m2\repository\ca\utoronto\med\dc\FocusMVN\0.0.1-SNAPSHOT\FocusMVN-0.0.1-SNAPSHOT.war
[INFO] Installing J:\work\workspace\FocusMVN\pom.xml to C:\Users\mansoork\.m2\repository\ca\utoronto\med\dc\FocusMVN\0.0.1-SNAPSHOT\FocusMVN-0.0.1-SNAPSHOT.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
任何指针将不胜感激。