Pat*_*cey 9 pom.xml maven maven-war-plugin maven-antrun-plugin
在部署webapp时,我需要更新UI资源中的一些变量,解压缩一些资产并连接一些文件,目前这是通过ant任务实现的.我正在尝试使用类似的东西在maven构建过程中运行此任务...
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<id>deploy-ui</id>
<phase>prepare-package</phase>
<inherited>false</inherited>
<configuration>
<target>
<property name="buildDir" value="${project.build.directory}/${project.build.finalName}" />
<ant antfile="build.xml" target="static-assets" />
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
上述操作失败,因为文件尚未复制到目标目录中.如果我将阶段设置为"package",则ant任务运行正常并且所有文件都被创建/修改,但是因为在运行ant目标之前已经构建了.war,所以没有任何帮助.
基本上,我需要在准备包阶段结束时运行我的蚂蚁目标.
看过生命周期参考我无法研究如何将更细粒度的目标暴露给antrun插件.
有任何想法吗?
mab*_*aba 17
由于我的评论没有得到任何答案,我想你想继续使用maven-antrun-plugin.
根据我所学到的经验,如果要在同一个阶段执行两个插件,那么它们将按照声明的顺序执行pom.xml.
为此,您必须maven-war-plugin在<plugins/>后面的列表中添加maven-antrun-plugin.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<id>deploy-ui</id>
<phase>package</phase>
<inherited>false</inherited>
<configuration>
<target>
<property name="buildDir" value="${project.build.directory}/${project.build.finalName}" />
<ant antfile="build.xml" target="static-assets" />
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
<executions>
<execution>
<!-- First step is to disable the default-war build step. -->
<id>default-war</id>
<phase>none</phase>
</execution>
<execution>
<!-- Second step is to create an exploded war. Done in prepare-package -->
<id>war-exploded</id>
<phase>prepare-package</phase>
<goals>
<goal>exploded</goal>
</goals>
</execution>
<execution>
<!-- Last step is to make sure that the war is built in the package phase -->
<id>custom-war</id>
<phase>package</phase>
<goals>
<goal>war</goal>
</goals>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
添加了一些更多的执行,以便default-war首先禁用,然后战争爆炸,最后战争打包.
| 归档时间: |
|
| 查看次数: |
17911 次 |
| 最近记录: |