代码之家  ›  专栏  ›  技术社区  ›  dfa

马文·尤伊:战争

  •  5
  • dfa  · 技术社区  · 17 年前

    我正在尝试使用maven和JS自动压缩CSS和JS this plugin

    <build>
      <finalName>${artifactId}-${version}-production</finalName>
      <plugins>
        <plugin>
          <groupId>net.sf.alchim</groupId>
          <artifactId>yuicompressor-maven-plugin</artifactId>
          <executions>
            <execution>
              <configuration>
                <gzip>true</gzip>
                <nosuffix>true</nosuffix>
              </configuration>
              <goals>
                <goal>compress</goal>
              </goals>
            </execution>
          </executions>
        </plugin>
      </plugins>
    </build>
    
    2 回复  |  直到 17 年前
        1
  •  8
  •   Rich Seller    17 年前

    您需要将执行绑定到一个阶段,以便在运行war打包时执行它。这些是 available phases 您可以绑定到用于战争包装的。

    <plugin>
      <groupId>net.sf.alchim</groupId>
      <artifactId>yuicompressor-maven-plugin</artifactId>
      <executions>
        <execution>
          <id>compress</id>
          <phase>process-resources</phase>
          ...<!--rest of config is fine-->
    

    更新:js.gz文件是否没有生成,或者只是没有包含在war中?

    如果你在战争中仍然看不到内容,还有一件事需要检查,那就是资源应该在 src/main/resources 不 src/main/webapp . yuicompressor插件将在中处理js文件 ,但他们不会参加最后的战争。

    更新2:在看到你的答案后重新阅读你的问题,我误解了你的目标。要避免实现两个目标,您可以执行以下操作之一:

    1. 试着跑,而不是跑战争目标 安装 或 包裹
    2. 或者,将上面示例中yuicompressor目标绑定到的阶段更改为 包裹
        2
  •  3
  •   dfa    17 年前

    出于某种奇怪的原因 war:war 在阶段中不调用插件 process-resources :我刚刚在nb 6.7上添加了一个自定义菜单,该菜单首先调用 compile 然后 战争:战争

    推荐文章