My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for
UseGuavaInYourBuild  
How to use Guava from different Build systems
maven, build, Phase-Deploy, repositories, gradle, ant, Featured
Updated Mar 20, 2012 by kevinb@google.com

Developers may use several different kinds of build system to compile/package their code. Guava can be used with any of them. For any code snippet below, please substitute the version given with the version of Guava you wish to use.

Maven

Apache Maven is a system for building projects and source code into deployment binaries, executing tests, and other software assembly lifecycle actions. It supports managed dependencies from central and private repositories. Guava is deployed to the common maven repositories, so to use it, you need only add the following snippet to the <dependencies /> section of the project's pom.xml file.

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

Gradle

Gradle is a build system that uses a domain specific language to construct instructions on how to build, test, assemble, deploy software from source. It supports managed dependencies and can make use of the maven repository for software artifacts. In order to use guava from Gradle, one must ensure the maven standard repositories are available like so:

repositories {
  mavenCentral()
}

Then one can add the guava dependency in the dependencies section like so:

dependencies {
 compile group: 'com.google.guava', name: 'guava', version: '10.0.1'
}

Ivy

Ivy is a dependency management system for builds. Ivy users should add the following line to the dependencies section of the ivy.xml file for any module that depends on Guava:

<dependency org="com.google.guava" name="guava" rev="10.0.1" />

and make sure that the "public" resolver is used.

Buildr

With Buildr, include this:

compile.with 'com.google.guava:guava:jar:10.0.1'

Manual Dependencies

You can also just manually download JARs for the classes, sources and javadocs. See the appropriate release page, e.g. Release10.

What about GWT?

In all the examples above, leave "com.google.guava" as it is but replace the other occurrence of "guava" with "guava-gwt".


Sign in to add a comment
Powered by Google Project Hosting