【发布时间】:2012-09-26 21:14:59
【问题描述】:
我的 webapp 中有两个 servlet 配置文件,一个用于我们的正常环境 (Heroku),另一个用于 WebLogic。我有一个用于我们的 WebLogic 构建的 Maven 配置文件,它应该将“servlet-context.xml.weblogic”复制到“servlet-context.xml”。一切似乎都在工作,除了在构建 war 文件之后进行复制,因此正确的 servlet 上下文不会包含在包中。在 maven-antrun-plugin 中使用正确的构建阶段以正确完成复制?
这是我的 POM.xml 文件的相关部分:
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<phase>test</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<move
file="${project.build.directory}/${project.build.finalName}/WEB-INF/spring/appServlet/radio-context.xml.weblogic"
tofile="${project.build.directory}/${project.build.finalName}/WEB-INF/spring/appServlet/radio-context.xml"/>
</tasks>
</configuration>
</execution>
</executions>
</plugin>
这会失败并出现以下错误:
Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin:1.3:run (default) on project radio: An Ant BuildException has occured: Warning: Could not find file C:\workspace\radio\target\radio-1.0.0-BUILD-SNAPSHOT\WEB-INF\spring\appServlet\radio-context.xml.weblogic to copy. -> [Help 1]
但是,如果我将 <phase> 更改为 package,则副本可以工作,但在构建战争之后。
任何帮助将不胜感激。
【问题讨论】:
-
你尝试
process-resources阶段了吗? -
是的。请参阅下面的 cmets。
process-resources发生在文件复制到目标目录之前。
标签: maven weblogic war maven-antrun-plugin