1

我需要为 jsHint 排除库(如 jquery、knockoutjs、jqueryMobile 和一些扩展......)。

但对于其他目标,我需要它们。

编辑:

我已经创建了 2 个 wro 文件,但它仍然需要所有 targetGroups。

wro2.xml with utils,app wro.xml with utils,libraries,app,jQueryMobile

<plugins>
        <plugin>
            <groupId>ro.isdc.wro4j</groupId>
            <artifactId>wro4j-maven-plugin</artifactId>
            <version>1.4.1</version>
            <executions>
                <execution>
                    <id>ex1</id>
                    <goals>
                        <goal>jshint</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <!--jshint options-->
                <options>jquery,devel,evil,noarg,eqnull</options>
                <failNever>false</failNever>
                <targetGroups>utils,app</targetGroups>
                <wroFile>${basedir}/src/main/webapp/WEB-INF/wro2.xml</wroFile>
            </configuration>
        </plugin>
        <plugin>
            <groupId>ro.isdc.wro4j</groupId>
            <artifactId>wro4j-maven-plugin</artifactId>
            <version>1.4.1</version>
            <executions>
                <execution>
                    <id>ex2</id>
                    <phase>compile</phase>
                    <goals>
                        <goal>run</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <!--compile options-->
                <targetGroups>utils,libraries,app,jQueryMobile</targetGroups>
                <minimize>true</minimize>
                <destinationFolder>${basedir}/src/main/webapp/wro/</destinationFolder>
                <cssDestinationFolder>${basedir}/target/webapp/css/</cssDestinationFolder>
                <jsDestinationFolder>${basedir}/target/webapp/js/</jsDestinationFolder>
                <contextFolder>${basedir}/src/main/webapp/</contextFolder>
                <ignoreMissingResources>false</ignoreMissingResources>
                <wroFile>${basedir}/src/main/webapp/WEB-INF/wro.xml</wroFile>
                <wroManagerFactory>ro.isdc.wro.extensions.manager.standalone.GoogleStandaloneManagerFactory</wroManagerFactory>
            </configuration>
        </plugin>
    </plugins>
4

1 回答 1

2

您有以下选择:

  1. 仅对 jshint 处理使用单独的组
  2. 通过提供仅用于 jshint 目标的 wroFile 来创建不同的模型
  3. 创建 wroManagerFactory 的自定义实现并以编程方式排除您不想处理的文件。

无论哪种情况,您都必须在 pom.xml 中声明两次插件,因为配置选项会有所不同。

编辑:

该解决方案与 maven 执行配置有关,而不是与 wro4j-maven-plugin 有关。

因此,不是用不同的配置两次声明同一个插件,而是用两次执行声明一次,每次执行都有自己的配置。例子:

<plugin>
    <groupId>ro.isdc.wro4j</groupId>
    <artifactId>wro4j-maven-plugin</artifactId>
    <version>1.4.1</version>
    <executions>
      <execution>
        <id>ex1</id>
        <goals>
          <goal>run</goal>
        </goals>
        <configuration>
            <targetGroups>utils,libraries,app,jQueryMobile</targetGroups>
        </configuration>
      </execution>  
      <execution>
        <id>ex2</id>
        <goals>
          <goal>jshint</goal>
        </goals>
        <configuration>
          <options>jquery,devel,evil,noarg,eqnull</options>
          <failNever>false</failNever>
          <targetGroups>utils,app</targetGroups>
          <wroFile>${basedir}/src/main/webapp/WEB-INF/wro2.xml</wroFile>
    </configuration>            
      </execution>
    </executions>
  </plugin>
于 2011-11-29T15:33:01.507 回答