7

GWT 2.2 and later includes Guava. The package containing Guava is com.google.gwt.thirdparty.guava. However, there doesn't seem to be a module XML file that would allow this package to be used in client (translatable) code. Based on this observation, it would seem that this copy of Guava is intended for GWT-internal use only.

For GWT projects using Guava, is the suggested approach to download Guava separately? If not, what is the process for including com.google.gwt.thirdparty.guava in client code?

Wesley
  • 10,652
  • 4
  • 37
  • 52

2 Answers2

7

Yes, if you want to use Guava yourself, you'll need the guava and guava-gwt jars, and reference the modules you want in your gwt.xml file. In the past, you've also needed jsr305, although my understanding is that this was being fixed, so you may not need that in r09

Ray
  • 4,829
  • 4
  • 28
  • 55
  • worked for me. I added both files (Version 13) from here https://code.google.com/p/guava-libraries/ to my war/WEB-INF/lib and added guava-13.0.1.jar to my build path (right click & add to build path) – eddyparkinson Oct 29 '12 at 05:09
3

Your assumption is correct; it's for internal use only; download it separately. If using Maven, include the following in your pom.xml:

<dependency>
  <groupId>com.google.guava</groupId>
  <artifactId>guava</artifactId>
  <version>r07</version>
  <scope>compile</scope>
</dependency>
<dependency>
  <groupId>com.google.guava</groupId>
  <artifactId>guava</artifactId>
  <version>r07</version>
  <classifier>gwt</classifier>
  <scope>provided</scope>
</dependency>
<!--  for the source/classes for javax.annotation -->
<dependency>
  <groupId>com.google.code.findbugs</groupId>
  <artifactId>jsr305</artifactId>
  <version>1.3.9</version>
  <scope>provided</scope>
</dependency> 
Valdis R
  • 2,095
  • 1
  • 18
  • 36
  • There isn't any Guava GWT jar available in Maven currently. It's looking like there should be for the next release (r10) and it'll be a separate artifact called guava-gwt that depends on guava. You won't need to include the jsr305 jar as a dependency either. – ColinD Apr 21 '11 at 12:57
  • @ColinD Yeah, that's right. We ended up packaging it ourselves and hosting it on our internal Maven repository. – Valdis R Apr 21 '11 at 15:26