Maven YUI压缩器插件导致进程资源阶段无法运行?

时间:2011-01-04 17:09:19

标签: maven yui-compressor

我有一个构建war文件的maven项目。

在我的maven构建文件中包含yui压缩器导致在src / main / resources /中找不到与任何js文件无关的文件,在process-resources期间处理的文件在复制到目标目录时为空。确实非常奇怪。一旦yuicompressor插件从循环中移除,其他资源就会被处理得很好。

任何人都见过(请说是的;-))?

这是我的配置:

YUI Compressor配置:

<plugin>
            <groupId>net.alchim31.maven</groupId>
            <artifactId>yuicompressor-maven-plugin</artifactId>
            <version>1.1</version>
            <executions>
                <execution>
                    <goals>
                        <goal>compress</goal>
                    </goals>
                    <phase>process-resources</phase>
                </execution>
            </executions>
            <configuration>
                <excludes>
                    <exclude>**/extjs*/**/*.js</exclude>
                    <exclude>**/extjs*/**/*.css</exclude>
                </excludes>
                <nosuffix>true</nosuffix>
            </configuration>
        </plugin>

和Resources配置,包含复制到目标目录时为空的文件:

<resources>
        <resource>
            <directory>src/main/resources</directory>
            <filtering>true</filtering>
            <includes>
              <include>**/*.properties</include>
              <include>**/*.xml</include>
            </includes>
        </resource>
    </resources>

重复:资源目录中的文件(log4j.xml等)正被复制到目标目录,但它们是空的。

感谢您的帮助!

1 个答案:

答案 0 :(得分:1)

正在发生的事情是YUI Compressor插件将resources目录作为隐式压缩包含的位置之一。它在资源插件执行后运行,用空文件覆盖资源目录中的xml和.properties文件(因为xml和.properties文件不包含javascript)。我的修复是在插件的配置中添加新的排除:

  <excludes>
                    <exclude>**/*.xml</exclude> <!-- <-- this one here -->
                    <exclude>**/*.properties</exclude> <!-- <-- and this one -->
                    <exclude>**/extjs*/**/*.js</exclude>
                    <exclude>**/extjs*/**/*.css</exclude>
                </excludes>

然而,这仍然不太理想,因为任何没有xml或.properties后缀的资源仍将由yui压缩器解析;我回到了最初的问题。

我尝试了这种排除,但它不起作用:

<exclude>**/resources/*.*</exclude>

有没有人知道为什么以上不起作用,或者知道如何告诉yui插件处理资源中的任何内容?

相关问题