Maven Javascript Compressor

Amb*_*Gup 9 javascript maven-2 minify

我想知道如何使用maven压缩javascript文件.我已经访问了像 http://mojohaus.org/javascript-maven-tools/guide-webapp-development.html这样的网站, 但没有解释实施.

我想知道执行maven插件的依赖性.

Pas*_*ent 9

我建议使用YUI Compressor Maven Mojo及其yuicompressor:compress目标.它有很好的记录,它只是有效.

要使用它,请添加以下内容pluginRepository:

  <pluginRepositories>
    <pluginRepository>
      <name>oss.sonatype.org - github-releases</name>
      <id>oss.sonatype.org-github-releases</id>
      <url>http://oss.sonatype.org/content/repositories/github-releases</url>
    </pluginRepository>
  </pluginRepositories>
Run Code Online (Sandbox Code Playgroud)

并声明插件:

<project>
  ...
  <build>
    <!-- To define the plugin version in your parent POM -->
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>net.alchim31.maven</groupId>
          <artifactId>yuicompressor-maven-plugin</artifactId>
          <version>0.9</version>
        </plugin>
        ...
      </plugins>
    </pluginManagement>
    <!-- To use the plugin goals in your POM or parent POM -->
    <plugins>
      <plugin>
        <groupId>net.alchim31.maven</groupId>
        <artifactId>yuicompressor-maven-plugin</artifactId>
        <executions>
          <execution>
            <goals>
              <goal>compress</goal>
            </goals>
          </execution>
        </executions>   
      </plugin>
      ...
    </plugins>
  </build>
  ...
</project>
Run Code Online (Sandbox Code Playgroud)

有关精确配置,请参阅使用情况页面和yuicompressor:compress的参数.