Maven Javascript压缩器 [英] Maven Javascript Compressor

查看:81
本文介绍了Maven Javascript压缩器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I want to know how one can compress javascriptfiles using maven. I have lready visited webistes like http://mojohaus.org/javascript-maven-tools/guide-webapp-development.html but there is no implementation explained.

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

I want to know the dependency for executing the maven plugin.

推荐答案

我建议使用 yuicompressor:compress 目标.有据可查,可以正常工作.

I suggest using the YUI Compressor Maven Mojo and its yuicompressor:compress goal instead. It is well documented, it just works.

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

To use it, add the following 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>

并声明插件:

<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>

请参阅用法页和 yuicompressor:compress 进行精确配置.

Refer to the Usage page and the parameters of yuicompressor:compress for precise configuration.

这篇关于Maven Javascript压缩器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆