Maven插件执行顺序

时间:2014-07-07 12:25:16

标签: java eclipse maven

所以情况就是这样,我想在创建战争之前应用yuicompressor插件和替换器插件。所以我需要在复制到目标文件夹后对我的文件应用替换和压缩操作。问题是它(静态文件jsp / js或其他webapps')在生命周期之前没有被复制。
使用maven版本m2e 3.0.4,所以订单应该有效。

如何在默认战争之前手动复制webapp内容?如果我以某种方式复制它将默认 - 通过覆盖再次复制它吗?

我想要maven插件的顺序是什么:
1.yuicompressor
2.replacer
3.war

而pom的插件顺序为:

<plugin>
                <groupId>net.alchim31.maven</groupId>
                <artifactId>yuicompressor-maven-plugin</artifactId>
                <version>1.4.0</version>
                <executions>
                    <execution>
                        <id>compressor</id>
                        <phase>package</phase>
                        <goals>
                            <goal>compress</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <!-- compressing -->
                </configuration>
            </plugin>
            <!-- js/css replacer -->
            <plugin>
                <groupId>com.google.code.maven-replacer-plugin</groupId>
                <artifactId>replacer</artifactId>
                <version>1.5.3</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>replace</goal>
                        </goals>
                    </execution>
                </executions>

                <configuration>
                    <!-- replacing -->
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.1.1</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>war</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <webXml>src/main/webapp/WEB-INF/web.xml</webXml>
                </configuration>
            </plugin> 

但是我从包装阶段中得到了什么:

maven log:

[INFO] 
[INFO] --- maven-war-plugin:2.4:war (default-war) @ Scheduler ---
[INFO] Packaging webapp
[INFO] Assembling webapp [Scheduler] in [D:\Development\TFCore\target\Scheduler]
[INFO] Processing war project
[INFO] Copying webapp resources [D:\Development\TFCore\src\main\webapp]
[INFO] Webapp assembled in [24946 msecs]
[INFO] Building war: D:\Development\TFCore\target\Scheduler.war
[INFO] 
[INFO] --- yuicompressor-maven-plugin:1.4.0:compress (compressor) @ Scheduler ---
[INFO] generate aggregation : D:\Development\TFCore\target\Scheduler\scripts\base.js
[INFO] base.js (4368673b)
[INFO] generate aggregation : D:\Development\TFCore\target\Scheduler\styles\base.css
[INFO] base.css (732042b)
[INFO] nb warnings: 0, nb errors: 0
[INFO] 
[INFO] --- replacer:1.5.3:replace (default) @ Scheduler ---
[INFO] Replacement run on 302 files.
[INFO] 
[INFO] --- maven-war-plugin:2.4:war (default) @ Scheduler ---
[INFO] Packaging webapp
[INFO] Assembling webapp [Scheduler] in [D:\Development\TFCore\target\Scheduler]
[INFO] Processing war project
[INFO] Copying webapp resources [D:\Development\TFCore\src\main\webapp]
[INFO] Webapp assembled in [22159 msecs]
[INFO] Building war: D:\Development\TFCore\target\Scheduler.war

1 个答案:

答案 0 :(得分:2)

你已经在项目中第二次定义了maven-war-plugin,在执行中使用了不同的id(默认值),导致maven-war-plugin执行的重复。除此之外,您可以将yuicompressor绑定到prepare-package阶段以及replacer-plugin。 yuicompressor和replacer插件的执行顺序由pom.xml文件中的顺序给出。