使用Maven中的yui压缩器压缩选定的js文件夹

时间:2015-01-07 13:05:42

标签: maven plugins yui-compressor

我正在尝试使用以下代码压缩我的webapp(impl / amss9 / widgets)目录中所选文件夹中的js

        <plugin>
            <groupId>net.alchim31.maven</groupId>
            <artifactId>yuicompressor-maven-plugin</artifactId>
            <executions>
                <execution>
                    <phase>prepare-package</phase>
                    <configuration>
                         <includes>
                            <include>${amss.webapp.dir}/impl/amss9/widgets/**/*.js</include>
                        </includes>
                    </configuration>
                    <goals>
                        <goal>compress</goal>
                    </goals>

                </execution>
            </executions>   
        </plugin>

上面的代码没有压缩任何东西。 如果我删除包含标记,那么它正在压缩我的webapp目录的所有js。 我不明白出了什么问题。

1 个答案:

答案 0 :(得分:1)

这一部分:

<includes>
     <include>${amss.webapp.dir}/impl/amss9/widgets/**/*.js</include>
</includes>

不会帮助你。相反,你必须使用这样的东西:

<plugin>
  <groupId>net.alchim31.maven</groupId>
  <artifactId>yuicompressor-maven-plugin</artifactId>
  <version>1.3.0</version>
  <executions>
    <execution>
      <goals>
        <goal>compress</goal>
      </goals>
    </execution>
  </executions>        
  <configuration>
    <gzip>true</gzip>
    <nosuffix>true</nosuffix>
    <sourceDirectory>app/assets/javascripts</sourceDirectory>
    <outputDirectory>${basedir}/public/javascripts</outputDirectory>
    <aggregations>
      <aggregation>
        <removeIncluded>true</removeIncluded>
        <insertNewLine>false</insertNewLine>
        <output>${basedir}/public/javascripts/application.js</output>
        <inputDir>${basedir}/public/javascripts/</inputDir>
        <includes>
          <include>jquery-1.7.1.min.js</include>
          <include>arborjs/arbor.js</include>
          <include>arborjs/arbor-graphics.js</include>
          <include>bootstrap.min.js</include>
          <include>application.js</include>
        </includes>
      </aggregation>
    </aggregations>
   </configuration>
</plugin>