由网友(番茄你个西红柿)分享简介:我是maven的新手,我想更改maven插件的执行顺序。在我的pom.xml中,我有maven-assembly-plugin和maven-ant-plugin。maven-assembly-plugin用于创建压缩文件。maven-ant-plugin用于将压缩文件从目标复制到其他目录。当我运行pom.xml时,...
我是maven的新手,我想更改maven插件的执行顺序。
在我的pom.xml中,我有maven-assembly-plugin
和maven-ant-plugin
。
maven-assembly-plugin
用于创建压缩文件。
maven-ant-plugin
用于将压缩文件从目标复制到其他目录。
当我运行pom.xml时,maven-ant-plugin
被触发,并查找压缩文件,最后我收到错误消息,指出未找到压缩文件。
请告诉我如何在maven-ant-plugin
之前先运行maven-assembly-plugin
,这样它会找到压缩文件并将其复制到相应的目录。
推荐答案
因为您说您对Maven非常陌生……Maven构建是一系列有序阶段的执行。这些阶段由适用于您的项目based on its packaging的lifecycle确定。
因此,您控制当插件的目标由binding it to a particular phase执行时。
希望这会有帮助。
编辑:此外,从Maven 3.0.3开始,对于绑定到同一阶段的两个插件,执行顺序与定义它们的顺序相同。例如:
<plugin>
<artifactId>maven-plugin-1</artifactId>
<version>1.0</version>
<executions>
<execution>
<phase>process-resources</phase>
...
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-plugin-2</artifactId>
<version>1.0</version>
<executions>
<execution>
<phase>process-resources</phase>
...
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-plugin-3</artifactId>
<version>1.0</version>
<executions>
<execution>
<phase>generate-resources</phase>
...
</execution>
</executions>
</plugin>
在上述实例中,执行顺序为:
maven-plugin-3(生成资源) maven-plugin-1(进程资源) maven-plugin-2(进程资源)相关推荐
最新文章