0

I am not able to use yui-compressor maven plugin in my web app. When I run maven I get following error

[INFO] Internal error in the plugin manager executing goal 'net.sf.alchim:yuicompressor-maven-plugin:0.7.1:compress': Unable to load the mojo 'net.sf.alchim:
yuicompressor-maven-plugin:0.7.1:compress' 
in the plugin 'net.sf.alchim:yuicompressor-maven-plugin'. A required class is missing: org.mozilla.javascript.ErrorReporter

Later I found that rhino js plugin contains this class org.mozilla.javascript.ErrorReporter. So I included this plugin in dependency tag but still I am getting the same error.

Has anyone came across such error.

--> updating main question to add the pom plugin details

<plugin>
    <groupId>net.sf.alchim</groupId>
    <artifactId>yuicompressor-maven-plugin</artifactId>
    <version>0.7.1</version>  
    <executions>
      <execution>
     <phase>compile</phase>
        <goals>
         <goal>jslint</goal>
          <goal>compress</goal>
        </goals>
      </execution>
    </executions>        
    <configuration>
    <failOnWarning>true</failOnWarning>
      <nosuffix>true</nosuffix>
      <aggregations>
       <aggregation>
          <!-- remove files after aggregation (default: false) -->
          <removeIncluded>false</removeIncluded>
          <!-- insert new line after each concatenation (default: false) -->
          <insertNewLine>false</insertNewLine>
          <output>${project.basedir}/${webcontent.dir}/js/compressedAll.js</output>
          <!-- files to include, path relative to output's directory or absolute path-->
          <!--inputDir>base directory for non absolute includes, default to parent dir of output</inputDir-->
          <includes>                
            <include>**/autocomplete.js</include>
            <include>**/calendar.js</include>
            <include>**/dialogs.js</include>
            <include>**/download.js</include>
            <include>**/folding.js</include>
            <include>**/jquery-1.4.2.min.js</include>
            <include>**/jquery.bgiframe.min.js</include>
            <include>**/jquery.loadmask.js</include>
            <include>**/jquery.printelement-1.1.js</include>
            <include>**/jquery.tablesorter.mod.js</include>
            <include>**/jquery.tablesorter.pager.js</include>
            <include>**/jquery.validate.js</include>  
            <include>**/jquery-ui-1.8.custom.min.js</include>
            <include>**/languageDropdown.js</include>
            <include>**/messages.js</include>
            <include>**/print.js</include>
            <include>**/tables.js</include>
            <include>**/tabs.js</include>
            <include>**/uwTooltip.js</include>
          </includes>
          <!-- files to exclude, path relative to output's directory-->

        </aggregation>
      </aggregations>
    </configuration>
    <dependencies>
         <dependency> 
 <groupId>rhino</groupId>  
  <artifactId>js</artifactId>       
  <scope>compile</scope>  
  <version>1.6R5</version> 
</dependency>  
<dependency>
        <groupId>org.apache.maven</groupId>
        <artifactId>maven-plugin-api</artifactId>
        <version>2.0.7</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.apache.maven</groupId>
        <artifactId>maven-project</artifactId>
        <version>2.0.7</version>
        <scope>provided</scope>
    </dependency><dependency>
        <groupId>net.sf.retrotranslator</groupId>
        <artifactId>retrotranslator-runtime</artifactId>
        <version>1.2.9</version>
        <scope>runtime</scope>
    </dependency>

    </dependencies>
  </plugin>                                                 
hanumant
  • 1,091
  • 4
  • 15
  • 27
  • Showing a pom, the plugin configuration, something allowing to reproduce, etc could help. – Pascal Thivent Sep 29 '10 at 15:48
  • Thanks for the reply. I was able to remove this error after adding rhino js plugin dependency directly under yui compressor's dependency section. But now facing weird problem. The yui compressor's compress goal is aggregating the js files into one but not compressing actually. – hanumant Sep 30 '10 at 04:20

3 Answers3

0

I struggled with the ErrorReporter class missing too. I solved it by building a jar-with-dependencies which I then turned around to use in my web app,

<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
  <execution>
    <phase>package</phase>
    <goals>
      <goal>attached</goal>
    </goals>
  </execution>
</executions>
<configuration>
  <descriptorRefs>
    <descriptorRef>jar-with-dependencies</descriptorRef>
  </descriptorRefs>
</configuration>

Once I did that, everything worked. In my jar I could see that the org.mozilla.javascript.ErrorReporter.class was in there and Maven would then compile for me.

Anjisan
  • 1,789
  • 3
  • 15
  • 26
0

Could you try the latest version (1.1)?

The 0.7.1 version doesn't even seem to be on the official repository. Maybe a dependency resolution problem?

Brian Clozel
  • 56,583
  • 15
  • 167
  • 176
0

See the topic Yui compressor StringIndexOutOfBoundsException on jboss

The only way to use yuicompressor on web app is to manually merge it with rhino dependency. Otherwise, the app to run would require specifying required sequence of jars in classloader loading sequence (youcompressor must go before rhino).

Community
  • 1
  • 1
Danubian Sailor
  • 1
  • 38
  • 145
  • 223