-
Notifications
You must be signed in to change notification settings - Fork 10.9k
UseGuavaInYourBuild
For any code snippet below, please substitute the version given with the version of Guava you wish to use.
Add the following snippet to the <dependencies />
section:
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>23.5-jre</version> <!-- or 23.5-android for the Android flavor -->
</dependency>
Ensure the maven standard repositories are available like so:
repositories {
mavenCentral()
}
Then add the Guava dependency in the dependencies section like so:
dependencies {
compile group: 'com.google.guava', name: 'guava', version: '23.5-jre' # or 23.5-android for the Android flavor
}
Add the following line to the dependencies section:
<dependency org="com.google.guava" name="guava" rev="23.5-jre" /> <!-- or rev="23.5-android" for the Android flavor -->
and make sure that the "public" resolver is used.
Include this:
compile.with 'com.google.guava:guava:jar:23.5-jre' # or '...:23.5-android' for the Android flavor
You can also just manually download JARs for the classes, sources and javadocs. See the appropriate release.
In all the examples above, leave "com.google.guava" as it is but replace the other occurrence of "guava" with "guava-gwt". (There is no GWT artifact for the Android flavor.)
Guava depends on some artifacts that contain annotations. This is primarily for
use by static analysis tools and certain compilers, so these annotations need
not be present in your runtime classpath unless you want your app to recognize
those annotations. In many cases, they need not be present even in your
compile-time classpath. Yet we make them available in your compile-time
classpath by default to avoid errors in unusual cases. (For examples, see
#2652 /
#2837 (annotation processors),
#2721 /
#2824 (-Xlint:all -Werror
), and
#1095 /
#1127 (Scala).) If you wish to
avoid the dependencies, you can usually safely exclude them.
(Ideally, we would make the annotations available at compile-time but not runtime. However, this is not currently possible in Maven's model.)
- Introduction
- Basic Utilities
- Collections
- Graphs
- Caches
- Functional Idioms
- Concurrency
- Strings
- Networking
- Primitives
- Ranges
- I/O
- Hashing
- EventBus
- Math
- Reflection
- Releases
- Tips
- Glossary
- Mailing List
- Stack Overflow
- Android Overview
- Footprint of JDK/Guava data structures