0

我无法在我的网络应用程序中使用 yui-compressor maven 插件。当我运行 maven 时,出现以下错误

[信息] 插件管理器执行目标 'net.sf.alchim:yuicompressor-maven-plugin:0.7.1:compress' 出现内部错误:无法加载 mojo 'net.sf.alchim:
yuicompressor-maven-plugin:0.7.1:compress'
在插件“net.sf.alchim:yuicompressor-maven-plugin”中。缺少必需的类:org.mozilla.javascript.ErrorReporter

后来发现rhino js插件中包含org.mozilla.javascript.ErrorReporter这个类。所以我在依赖标签中包含了这个插件,但我仍然得到同样的错误。

有没有人遇到过这样的错误。

--> 更新主要问题以添加 pom 插件详细信息

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

3 回答 3

0

你能试试最新版本(1.1)吗?

0.7.1 版本甚至似乎不在官方存储库中。也许是依赖解决问题?

于 2010-10-12T21:43:02.027 回答
0

请参阅 jboss 上的主题Yui 压缩器 StringIndexOutOfBoundsException

在 web 应用程序上使用 yuicompressor 的唯一方法是手动将其与 rhino 依赖项合并。否则,要运行的应用程序将需要在类加载器加载序列中指定所需的 jar 序列(youcompressor 必须在 rhino 之前运行)。

于 2012-01-13T15:19:51.890 回答
0

我也为 ErrorReporter 类丢失而苦苦挣扎。我通过构建一个 jar-with-dependencies 解决了这个问题,然后我转身在我的网络应用程序中使用它,

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

一旦我这样做了,一切都会奏效。在我的 jar 中,我可以看到 org.mozilla.javascript.ErrorReporter.class 在那里,然后 Maven 将为我编译。

于 2013-04-16T19:19:24.087 回答