how do I exclude files for jshint using maven?

766 views
Skip to first unread message

Johan Vandeplas

unread,
Nov 30, 2011, 9:34:11 AM11/30/11
to wro4j
To continue the question posted on stackoverflow:

http://stackoverflow.com/questions/8312969/wro4j-maven-plugin-how-do-i-exclude-files-for-jshint

I'm tried using 2 wro files

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

wro.xml:

<groups xmlns="http://www.isdc.ro/wro">
<group name="utils">
<js>/javascript/utils/*.js</js>
</group>
<group name="libraries">
<js>/javascript/libs/jquery/*.js</js>
<js>/javascript/libs/jquery-tmpl/*.js</js>
<js>/javascript/libs/jquery-blockUI/*.js</js>
<js>/javascript/libs/knockout/*.js</js>
</group>
<group name="app">
<js>/javascript/configuration/Config.js</js>
<js>/javascript/app.js</js>
<css>/css/*.css</css>
<js>/javascript/services/EventService.js</js>
<js>/javascript/services/impl/*.js</js>
<js>/javascript/configuration/*.js</js>
<js>/javascript/models/*.js</js>
<js>/javascript/viewmodels/*.js</js>
</group>
<group name="jQueryMobile">
<js>/javascript/libs/jquery-mobile/*.js</js>
<css>/css/jquery-mobile/*.css</css>
</group>
</groups>

wro2.xml:

<groups xmlns="http://www.isdc.ro/wro">
<group name="utils">
<js>/javascript/utils/*.js</js>
</group>
<group name="app">
<js>/javascript/configuration/Config.js</js>
<js>/javascript/app.js</js>
<css>/css/*.css</css>
<js>/javascript/services/EventService.js</js>
<js>/javascript/services/impl/*.js</js>
<js>/javascript/configuration/*.js</js>
<js>/javascript/models/*.js</js>
<js>/javascript/viewmodels/*.js</js>
</group>
</groups>

plungins in the pom.xml:

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

Problem is jsHint still takes "utils,libraries,app,jQueryMobile".
(libraries contains jquery and knockout. They both generate a lot of
'errors', I don't need to check those files I expect them to be ok.)

Alex Objelean

unread,
Nov 30, 2011, 10:19:23 AM11/30/11
to wr...@googlegroups.com
I think I've found the solution. It is related to maven execution configuration rather than to wro4j-maven-plugin. 

So, instead of declaring the same plugin twice with different configurations, you declare it once with two executions and each execution has its own configuration. Example:

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


Let me know if it works for you.

PS: I'll post the answer on stack overflow also (for higher visibility))

Cheers, 
Alex

espina...@gmail.com

unread,
Nov 30, 2011, 6:33:00 PM11/30/11
to wr...@googlegroups.com
Hi Alex,

 I'm trying to the same and your solution works perfectly. At the same time I'm wondering why do need two different wro.xml files? For example, given something like this:
 
  wro.xml
  <group name="app">
    <group-ref>base</group-ref>
    <group-ref>utils</group-ref>
    <js>home.js</js>
  </group>

  <group name="utils">
    <js>utils.js</js>
  </group>

  <group name="base">
    <js>libs/jquery-1.7.1.js</js>
    <js>libs/underscore.js</js>
    <js>libs/backbone.js</js>
  </group>

 pom.xml
 ...

 <configuration>
   <options>jquery,devel,evil,noarg,eqnull</options>
   <failNever>false</failNever>
   <targetGroups>utils,app</targetGroups>
   <includeReferences>false</includeReferences>
 </configuration>

 Basically, I want to process utils & app groups and ignore any group-ref these groups might have. In this way we don't need a new wro just for jshint.

 Thanks for these great tool.

Alex Objelean

unread,
Dec 1, 2011, 2:57:44 AM12/1/11
to wr...@googlegroups.com
Using a different model file (wro.xml) is not the only solution. Alternatively, you can specify for jshint goal only the groups containing resources you need to be jshinted. All you have to do is to split yor resources in smaller groups to control their granularity. The group ref cannot be used right now, because it doesn't have any special meaning in model context, it is used just for resource reusability.

Cheers,
Alex

Edgar Espina

unread,
Dec 1, 2011, 7:37:02 AM12/1/11
to wr...@googlegroups.com
Hi Alex,

 In my example I've smaller groups: app & utlis but JShint start checking jquery-1.7.1.js bc the group-ref to base group. Am I missing something?

 Thanks for your help.

Alex Objelean

unread,
Dec 1, 2011, 8:38:30 AM12/1/11
to wr...@googlegroups.com
Hi Edgar,

when using the group called app (from example you've provided), all resources defined in that particular group will be processed, included those included by group-ref. 

In order to process only resources you are interested in, you have to create a separate group (let's call it home), the result would look like this:

  <group name="app">
    <group-ref>base</group-ref>
    <group-ref>utils</group-ref>
    <group-ref>home</group-ref>
  </group> 

  <group name="home">
    <js>home.js</js>
  </group> 

Now, if you want only home.js to be processed, add the home group to targetGroups element.

There is no such thing as includeReferences. When processing, each groupRef is expanded with associated groups, so it cannot be handled the way you described it.

Let me know if you have any other questions.

Cheers,
Alex


--
You received this message because you are subscribed to the Google Groups "wro4j" group.
To view this discussion on the web visit https://groups.google.com/d/msg/wro4j/-/jCqgvvM3CYIJ.
To post to this group, send email to wr...@googlegroups.com.
To unsubscribe from this group, send email to wro4j+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/wro4j?hl=en.

Reply all
Reply to author
Forward
0 new messages