【问题标题】:Maven YUI Compressor Plugin Causing process-resources phase to not run?Maven YUI Compressor Plugin导致进程资源阶段不运行?
【发布时间】:2011-01-04 17:09:18
【问题描述】:

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

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

有人见过(请说是的;-))?

这是我的配置:

YUI 压缩器配置:

<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>
        <resource>
            <directory>src/main/resources</directory>
            <filtering>true</filtering>
            <includes>
              <include>**/*.properties</include>
              <include>**/*.xml</include>
            </includes>
        </resource>
    </resources>

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

感谢您的帮助!

【问题讨论】:

    标签: maven yui-compressor


    【解决方案1】:

    YUI Compressor 插件将资源目录作为隐式压缩的位置之一。它在资源插件执行后运行,用空文件覆盖资源目录中的 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 插件处理资源中的任何内容?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-03-03
      • 1970-01-01
      • 1970-01-01
      • 2023-01-24
      • 2015-11-20
      相关资源
      最近更新 更多