在PlayN中,如何使用Google的Guava库编译我的项目的HTML版本?

时间:2012-04-03 05:45:43

标签: gwt guava playn

我可以通过简单地导入Guava库来运行我的项目的Java版本:

import com.google.gwt.thirdparty.guava.common.collect.ImmutableList;

根据建议here,我已将此行添加到html / pom.xml中:

<dependency>
  <groupId>com.google.guava</groupId>
  <artifactId>guava-gwt</artifactId>
  <version>10.0.1</version>
</dependency>

这行到html / project.gwt.xml文件:

<inherits name="com.google.common.collect.Collect"/>

但是当我在Eclipse中尝试GWT-Compile我的HTML版本时,我收到如下错误:

[ERROR] Line 61: No source code is available for type com.google.gwt.thirdparty.guava.common.collect.ImmutableList<E>; did you forget to inherit a required module?

2 个答案:

答案 0 :(得分:3)

我认为您可能导入错误的课程。尝试将com.google.gwt.thirdparty.guava.common.collect.ImmutableList导入替换为com.google.common.collect.ImmutableList

以下是关于Lists课程的类似问题:Trouble with GWT and Guava

答案 1 :(得分:2)

我选择@eneveu's answer,因为它让我朝着正确的方向前进。以下是在PlayN项目的HTML版本中启用Guava的更明确的说明。

<强> 1。添加依赖于YourGame-core / pom.xml

<dependency>
  <groupId>com.google.guava</groupId>
  <artifactId>guava-gwt</artifactId>
  <version>11.0.2</version>
</dependency>

<强> 2。在Package Explorer窗口中右键单击YourGame-core目录,然后:Maven&gt;更新依赖关系

第3。对于HTML5,将此行添加到YourGame-html / YourGame.gwt.xml:

 <inherits name="com.google.common.collect.Collect"/> 

<强> 4。导入时,请使用正确的库路径:

import com.google.common.collect.Foo;
/* NOT: import com.google.gwt.thirdparty.guava.common.collect.Foo; */

我在下面的链接中编译了代码并在Chrome中进行了测试,以验证Guava是否已成功导入: