我的目标是仅压缩某些目录中的某些javascript文件,但插件仍在遍历我的整个目录结构,试图压缩所有javascript文件。这就是我的pom的样子:
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>yuicompressor-maven-plugin</artifactId>
<version>1.3.0</version>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>compress</goal>
</goals>
</execution>
</executions>
<configuration>
<nosuffix>true</nosuffix>
<aggregations>
<aggregation>
<insertNewLine>true</insertNewLine>
<output>${project.build.directory}/${project.build.finalName}/js/analytics/all.js</output>
<inputDir>${basedir}/src/main/webapp/js/analytics/app</inputDir>
<includes>
<include>${basedir}/src/main/webapp/js/analytics/app/application.js</include>
</includes>
<excludes>
<exclude>all-js-min.js</exclude>
</excludes>
</aggregation>
</aggregations>
</configuration>
</plugin>
我希望它只会查找位于$ {basedir} / src / main / webapp / js / analytics / app中的js文件,并且只压缩application.js,因为这是我特定的唯一文件包括在内。它还试图压缩all-js-min.js 似乎忽略了include / exclude选项。什么想法可能会出错?
答案 0 :(得分:3)
顶级配置级别有“排除”选项。试试这个:
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>yuicompressor-maven-plugin</artifactId>
<version>1.3.0</version>
<executions>
<execution>
<goals>
<goal>compress</goal>
</goals>
<phase>process-sources</phase>
</execution>
</executions>
<configuration>
<excludes>
<exclude>[what you want to exclude]</exclude>
</excludes>
<aggregations>
<aggregation>
<removeIncluded>false</removeIncluded>
<includes>
<include>**/[js file name to include 1]</include>
<include>**/[js file name to include 2]</include>
</includes>
<output>[js file minified]</output>
</aggregation>
</aggregations>
</configuration>
</plugin>