gwt-maven-plugin javascript编译错误
我们正在将构建系统转移到使用 Maven。我们的项目之一使用gwt(版本2.2.0)。它在 Eclipse 上编译为 javascript 没有任何错误,但我们在 Maven 中遇到了一些问题。
以下是运行“mvn clean package”时的错误消息
[INFO]
[INFO] --- gwt-maven-plugin:2.2.0:compile (default) @ Analytics ---
[INFO] auto discovered modules [com.ivstel.af.AF]
[INFO] Compiling module com.ivstel.af.AF
[INFO] Validating newly compiled units
[INFO] [ERROR] Errors in 'jar:file:/C:/Users/Croydon.IVSTEL1/.m2/repository/com/google/gwt/google-apis/gwt-visualization/1.1.1/gwt-visualization-1.1.1.jar
!/com/google/gwt/visualization/client/CommonOptions.java'
[INFO] [ERROR] Line 61: The method toJsArrayString(String[]) is undefined for the type ArrayHelper
[INFO] [ERROR] Errors in 'jar:file:/C:/Users/Croydon.IVSTEL1/.m2/repository/com/google/gwt/google-apis/gwt-visualization/1.1.1/gwt-visualization-1.1.1.jar
!/com/google/gwt/visualization/client/DataTable.java'
[INFO] [ERROR] Line 140: The method toJsArrayInteger(int[]) is undefined for the type ArrayHelper
[INFO] [ERROR] Errors in 'jar:file:/C:/Users/Croydon.IVSTEL1/.m2/repository/com/google/gwt/google-apis/gwt-visualization/1.1.1/gwt-visualization-1.1.1.jar
!/com/google/gwt/visualization/client/DataView.java'
[INFO] [ERROR] Line 62: The method toJsArrayInteger(int[]) is undefined for the type ArrayHelper
[INFO] [ERROR] Line 74: The method toJsArrayInteger(int[]) is undefined for the type ArrayHelper
[INFO] [ERROR] Line 82: The method toJsArrayInteger(int[]) is undefined for the type ArrayHelper
[INFO] [ERROR] Line 94: The method toJsArrayInteger(int[]) is undefined for the type ArrayHelper
[INFO] [ERROR] Errors in 'jar:file:/C:/Users/Croydon.IVSTEL1/.m2/repository/com/google/gwt/google-apis/gwt-visualization/1.1.1/gwt-visualization-1.1.1.jar
!/com/google/gwt/visualization/client/VisualizationUtils.java'
[INFO] [ERROR] Line 30: The method toJsArrayString(String[]) is undefined for the type ArrayHelper
[INFO] [ERROR] Line 44: The method toJsArrayString(String[]) is undefined for the type ArrayHelper
但是,有问题的 jar 确实包含函数 toJsArrayInteger gwt-visualization-1.1.1.jar\com\google\gwt\ajaxloader\client\ArrayHelper.java
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<!-- POM file generated with GWT webAppCreator -->
<modelVersion>4.0.0</modelVersion>
<groupId>com.ivstel.analytics</groupId>
<artifactId>Analytics</artifactId>
<packaging>war</packaging>
<version>1</version>
<name>Analytics</name>
<properties>
<!-- Convenience property to set the GWT version -->
<gwtVersion>2.2.0</gwtVersion>
<!-- GWT needs at least java 1.5 -->
<maven.compiler.source>1.5</maven.compiler.source>
<maven.compiler.target>1.5</maven.compiler.target>
<webappDirectory>${project.build.directory}/${project.build.finalName}</webappDirectory>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<!-- Shared version number properties -->
<com.google.gwt.version>${gwtVersion}</com.google.gwt.version>
</properties>
<dependencies>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-servlet</artifactId>
<version>${com.google.gwt.version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-user</artifactId>
<version>${com.google.gwt.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.gwt.google-apis</groupId>
<artifactId>gwt-maps</artifactId>
<version>1.0.4</version>
</dependency>
<dependency>
<groupId>com.google.gwt.google-apis</groupId>
<artifactId>gwt-visualization</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>org.gwtmultipage</groupId>
<artifactId>gwtmultipage-core</artifactId>
<version>1.0.0.Beta5</version>
</dependency>
<!-- Other dependencies ....... -->
</dependencies>
<build>
<!-- Generate compiled stuff in the folder used for developing mode -->
<outputDirectory>${webappDirectory}/WEB-INF/classes</outputDirectory>
<plugins>
<!-- GWT Maven Plugin -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<version>2.2.0</version>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>test</goal>
<goal>i18n</goal>
<!-- http://stackoverflow.com/questions/3611775/gwt-maven-eclipse-plugin-compilation-fails-due-to-duplicate-class -->
<!-- <goal>generateAsync</goal> -->
</goals>
</execution>
</executions>
<!-- Plugin configuration. There are many available options, see gwt-maven-plugin
documentation at codehaus.org -->
<configuration>
<runTarget>AF.html</runTarget>
<hostedWebapp>${webappDirectory}</hostedWebapp>
<i18nMessagesBundle>com.ivstel.af.client.Messages</i18nMessagesBundle>
</configuration>
<dependencies>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-servlet</artifactId>
<version>${com.google.gwt.version}</version>
</dependency>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-user</artifactId>
<version>${com.google.gwt.version}</version>
</dependency>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-dev</artifactId>
<version>${com.google.gwt.version}</version>
</dependency>
</dependencies>
</plugin>
<!-- Copy static web files before executing gwt:run -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>exploded</goal>
</goals>
</execution>
</executions>
<configuration>
<webappDirectory>${webappDirectory}</webappDirectory>
</configuration>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>noTest</id>
<properties>
<maven.test.skip>true</maven.test.skip>
</properties>
</profile>
</profiles>
</project>
We are moving our build system to use maven. One of our project's uses gwt (version 2.2.0). It compiles to javascript without any errors on Eclipse, but we are having some problems in maven.
Following is the error message when running "mvn clean package"
[INFO]
[INFO] --- gwt-maven-plugin:2.2.0:compile (default) @ Analytics ---
[INFO] auto discovered modules [com.ivstel.af.AF]
[INFO] Compiling module com.ivstel.af.AF
[INFO] Validating newly compiled units
[INFO] [ERROR] Errors in 'jar:file:/C:/Users/Croydon.IVSTEL1/.m2/repository/com/google/gwt/google-apis/gwt-visualization/1.1.1/gwt-visualization-1.1.1.jar
!/com/google/gwt/visualization/client/CommonOptions.java'
[INFO] [ERROR] Line 61: The method toJsArrayString(String[]) is undefined for the type ArrayHelper
[INFO] [ERROR] Errors in 'jar:file:/C:/Users/Croydon.IVSTEL1/.m2/repository/com/google/gwt/google-apis/gwt-visualization/1.1.1/gwt-visualization-1.1.1.jar
!/com/google/gwt/visualization/client/DataTable.java'
[INFO] [ERROR] Line 140: The method toJsArrayInteger(int[]) is undefined for the type ArrayHelper
[INFO] [ERROR] Errors in 'jar:file:/C:/Users/Croydon.IVSTEL1/.m2/repository/com/google/gwt/google-apis/gwt-visualization/1.1.1/gwt-visualization-1.1.1.jar
!/com/google/gwt/visualization/client/DataView.java'
[INFO] [ERROR] Line 62: The method toJsArrayInteger(int[]) is undefined for the type ArrayHelper
[INFO] [ERROR] Line 74: The method toJsArrayInteger(int[]) is undefined for the type ArrayHelper
[INFO] [ERROR] Line 82: The method toJsArrayInteger(int[]) is undefined for the type ArrayHelper
[INFO] [ERROR] Line 94: The method toJsArrayInteger(int[]) is undefined for the type ArrayHelper
[INFO] [ERROR] Errors in 'jar:file:/C:/Users/Croydon.IVSTEL1/.m2/repository/com/google/gwt/google-apis/gwt-visualization/1.1.1/gwt-visualization-1.1.1.jar
!/com/google/gwt/visualization/client/VisualizationUtils.java'
[INFO] [ERROR] Line 30: The method toJsArrayString(String[]) is undefined for the type ArrayHelper
[INFO] [ERROR] Line 44: The method toJsArrayString(String[]) is undefined for the type ArrayHelper
However, the jar in question does contain the function toJsArrayInteger in gwt-visualization-1.1.1.jar\com\google\gwt\ajaxloader\client\ArrayHelper.java
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<!-- POM file generated with GWT webAppCreator -->
<modelVersion>4.0.0</modelVersion>
<groupId>com.ivstel.analytics</groupId>
<artifactId>Analytics</artifactId>
<packaging>war</packaging>
<version>1</version>
<name>Analytics</name>
<properties>
<!-- Convenience property to set the GWT version -->
<gwtVersion>2.2.0</gwtVersion>
<!-- GWT needs at least java 1.5 -->
<maven.compiler.source>1.5</maven.compiler.source>
<maven.compiler.target>1.5</maven.compiler.target>
<webappDirectory>${project.build.directory}/${project.build.finalName}</webappDirectory>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<!-- Shared version number properties -->
<com.google.gwt.version>${gwtVersion}</com.google.gwt.version>
</properties>
<dependencies>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-servlet</artifactId>
<version>${com.google.gwt.version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-user</artifactId>
<version>${com.google.gwt.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.gwt.google-apis</groupId>
<artifactId>gwt-maps</artifactId>
<version>1.0.4</version>
</dependency>
<dependency>
<groupId>com.google.gwt.google-apis</groupId>
<artifactId>gwt-visualization</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>org.gwtmultipage</groupId>
<artifactId>gwtmultipage-core</artifactId>
<version>1.0.0.Beta5</version>
</dependency>
<!-- Other dependencies ....... -->
</dependencies>
<build>
<!-- Generate compiled stuff in the folder used for developing mode -->
<outputDirectory>${webappDirectory}/WEB-INF/classes</outputDirectory>
<plugins>
<!-- GWT Maven Plugin -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<version>2.2.0</version>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>test</goal>
<goal>i18n</goal>
<!-- http://stackoverflow.com/questions/3611775/gwt-maven-eclipse-plugin-compilation-fails-due-to-duplicate-class -->
<!-- <goal>generateAsync</goal> -->
</goals>
</execution>
</executions>
<!-- Plugin configuration. There are many available options, see gwt-maven-plugin
documentation at codehaus.org -->
<configuration>
<runTarget>AF.html</runTarget>
<hostedWebapp>${webappDirectory}</hostedWebapp>
<i18nMessagesBundle>com.ivstel.af.client.Messages</i18nMessagesBundle>
</configuration>
<dependencies>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-servlet</artifactId>
<version>${com.google.gwt.version}</version>
</dependency>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-user</artifactId>
<version>${com.google.gwt.version}</version>
</dependency>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-dev</artifactId>
<version>${com.google.gwt.version}</version>
</dependency>
</dependencies>
</plugin>
<!-- Copy static web files before executing gwt:run -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>exploded</goal>
</goals>
</execution>
</executions>
<configuration>
<webappDirectory>${webappDirectory}</webappDirectory>
</configuration>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>noTest</id>
<properties>
<maven.test.skip>true</maven.test.skip>
</properties>
</profile>
</profiles>
</project>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题是我使用的是旧版本的 gwt-maps,它使用的是旧版本的 ajaxloader。由于 gwt-maps 依赖项位于 gwt-visualizations 之前,因此编译器忽略了 gwt-visualizations 中的 ajaxloader 类。
似乎解决此情况的理想方法是使用noredist 工件,然后显式包含 gwt-ajaxloader 依赖项。我们还必须从 ajaxloader 中排除 gwt-dev 依赖项(gwt-maven-plugin 要求)。
The problem was that I was using an older version of gwt-maps, which used an older version of ajaxloader. Since the gwt-maps dependency was before gwt-visualizations, the compiler ignored the ajaxloader classes in gwt-visualizations.
Seems that the ideal way to do solve this situtaions is to use the noredist artifacts and then include the gwt-ajaxloader dependency explicitly. We also have to exclude the gwt-dev dependency from ajaxloader (gwt-maven-plugin requirement).