davidB / yuicompressor-maven-plugin

maven's plugin to compress (Minify / Ofuscate / Aggregate) Javascript files and CSS files using YUI Compressor
http://davidb.github.io/yuicompressor-maven-plugin/
GNU Lesser General Public License v2.1
122 stars 48 forks source link

compress goal incorrectly processes include resources #19

Closed patrickcrocker closed 13 years ago

patrickcrocker commented 13 years ago

Given the following pom.xml:

<project>
    ...
    <build>
        <filters>
            <filter>src/main/filters/dev.properties</filter>
        </filters>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
                <includes>
                    <include>webapp.properties</include>
                </includes>
            </resource>
        </resources>
        <plugins>
            <plugin>
                <groupId>net.alchim31.maven</groupId>
                <artifactId>yuicompressor-maven-plugin</artifactId>
                <version>1.1</version>
                <configuration>
                    <nosuffix>true</nosuffix>
                    <jswarn>false</jswarn>
                </configuration>
                <executions>
                    <execution>
                        <id>compress-js-css</id>
                        <phase>process-resources</phase>
                        <goals>
                            <goal>compress</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
    ...
</project>

The yuicompressor-maven-plugin will incorrectly process the webapp.properties file, resulting in an empty file (0 byte length):

$ mvn process-resources
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building yuicompressor-test-webapp 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.4.1:clean (default-clean) @ yuicompressor-test-webapp ---
[INFO] Deleting C:\Users\Patrick\Workspaces\Helios\yuicompressor-test-webapp\target
[INFO]
[INFO] --- maven-resources-plugin:2.4.3:resources (default-resources) @ yuicompressor-test-webapp ---
[INFO] Copying 1 resource
[INFO]
[INFO] --- yuicompressor-maven-plugin:1.1:compress (compress-js-css) @ yuicompressor-test-webapp ---
[INFO] webapp.properties (0b) -> webapp.properties (0b)[100%]
[INFO] prototype.js (163312b) -> prototype.js (94441b)[57%]
[INFO] test.css (1291b) -> test.css (1057b)[81%]
[INFO] total input (164603b) -> output (95498b)[58%]
[INFO] nb warnings: 0, nb errors: 0
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.578s
[INFO] Finished at: Fri Jan 14 15:56:39 CST 2011
[INFO] Final Memory: 15M/254M
[INFO] ------------------------------------------------------------------------

The only workaround is to explicitly exclude *.properties files in the yuicompressor-maven-plugin configuration:

<plugin>
    <groupId>net.alchim31.maven</groupId>
    <artifactId>yuicompressor-maven-plugin</artifactId>
    <version>1.1</version>
    <configuration>
        <nosuffix>true</nosuffix>
        <jswarn>false</jswarn>
        <excludes>
            <exlude>**/*.properties</exlude>
        </excludes>
    </configuration>
    <executions>
        <execution>
            <id>compress-js-css</id>
            <phase>process-resources</phase>
            <goals>
                <goal>compress</goal>
            </goals>
        </execution>
    </executions>
</plugin>
davidB commented 13 years ago

Right Because in 1.1, explicit includes under resources, override the default one (/.js, /.css). In 1.2 includes from resources will be ignored