blob: c063aec5f91e725d64f5da57889ec8ae14bcc8e0 [file] [log] [blame] [view]
cgdeckerf40d6872016-12-28 11:24:17 -08001# Guava: Google Core Libraries for Java
kevinb@google.com95e8bd22010-04-09 17:02:12 +00002
cgdeckerfffd6a32018-05-25 12:32:08 -07003[![Latest release](https://img.shields.io/github/release/google/guava.svg)](https://github.com/google/guava/releases/latest)
Jochen Schalanda124e5732014-11-05 12:32:03 -08004[![Build Status](https://travis-ci.org/google/guava.svg?branch=master)](https://travis-ci.org/google/guava)
5
kakd67899d2016-10-11 15:02:53 -07006Guava is a set of core libraries that includes new collection types (such as
7multimap and multiset), immutable collections, a graph library, functional
8types, an in-memory cache, and APIs/utilities for concurrency, I/O, hashing,
9primitives, reflection, string processing, and much more!
vijaykakadiya65c42d92015-01-21 11:51:28 -080010
dpb4d0e0af2017-05-23 08:14:38 -070011Guava comes in two flavors.
12
dpbfb763ee2017-10-02 12:51:35 -070013* The JRE flavor requires JDK 1.8 or higher.
dpb4d0e0af2017-05-23 08:14:38 -070014* If you need support for JDK 1.7 or Android, use the Android flavor. You can
15 find the Android Guava source in the [`android` directory].
16
17[`android` directory]: https://github.com/google/guava/tree/master/android
kevinb@google.com95e8bd22010-04-09 17:02:12 +000018
cgdeckerfffd6a32018-05-25 12:32:08 -070019## Adding Guava to your build
cgdeckera91e6f22015-07-15 11:43:30 -070020
cgdeckerfffd6a32018-05-25 12:32:08 -070021Guava's Maven group ID is `com.google.guava` and its artifact ID is `guava`.
22Guava provides two different "flavors": one for use on a (Java 8+) JRE and one
23for use on Android or Java 7 or by any library that wants to be compatible with
24either of those. These flavors are specified in the Maven version field as
cgdecker8e174e72019-03-07 11:48:23 -080025either `27.1-jre` or `27.1-android`. For more about depending on
cgdeckerfffd6a32018-05-25 12:32:08 -070026Guava, see [using Guava in your build].
cgdeckera91e6f22015-07-15 11:43:30 -070027
28To add a dependency on Guava using Maven, use the following:
29
30```xml
31<dependency>
32 <groupId>com.google.guava</groupId>
33 <artifactId>guava</artifactId>
cgdecker8e174e72019-03-07 11:48:23 -080034 <version>27.1-jre</version>
dpb4d0e0af2017-05-23 08:14:38 -070035 <!-- or, for Android: -->
cgdecker8e174e72019-03-07 11:48:23 -080036 <version>27.1-android</version>
cgdeckera91e6f22015-07-15 11:43:30 -070037</dependency>
38```
39
seabass54dc1b02015-09-21 10:09:38 -070040To add a dependency using Gradle:
41
Elias Ojala4675e302018-08-13 09:06:28 -070042```gradle
seabass54dc1b02015-09-21 10:09:38 -070043dependencies {
cgdecker8e174e72019-03-07 11:48:23 -080044 compile 'com.google.guava:guava:27.1-jre'
dpb4d0e0af2017-05-23 08:14:38 -070045 // or, for Android:
cgdecker8e174e72019-03-07 11:48:23 -080046 api 'com.google.guava:guava:27.1-android'
seabass54dc1b02015-09-21 10:09:38 -070047}
48```
dpb4d0e0af2017-05-23 08:14:38 -070049
cgdeckerf40d6872016-12-28 11:24:17 -080050## Snapshots
cgdeckera91e6f22015-07-15 11:43:30 -070051
52Snapshots of Guava built from the `master` branch are available through Maven
cgdecker11d36832017-10-03 14:26:37 -070053using version `HEAD-jre-SNAPSHOT`, or `HEAD-android-SNAPSHOT` for the Android
dpb4d0e0af2017-05-23 08:14:38 -070054flavor.
cgdeckera91e6f22015-07-15 11:43:30 -070055
cgdecker8fbb7ac2015-10-01 14:39:22 -070056- Snapshot API Docs: [guava][guava-snapshot-api-docs]
cpovirka3da7322017-08-11 11:17:48 -070057- Snapshot API Diffs: [guava][guava-snapshot-api-diffs]
cgdeckera91e6f22015-07-15 11:43:30 -070058
cgdeckerf40d6872016-12-28 11:24:17 -080059## Learn about Guava
vijaykakadiya65c42d92015-01-21 11:51:28 -080060
dpb153ca2f2017-10-26 14:20:40 -070061- Our users' guide, [Guava Explained]
cgdeckercc3b0f82015-06-08 10:56:45 -070062- [A nice collection](http://www.tfnico.com/presentations/google-guava) of other helpful links
vijaykakadiya65c42d92015-01-21 11:51:28 -080063
cgdeckerf40d6872016-12-28 11:24:17 -080064## Links
kevinb@google.com95e8bd22010-04-09 17:02:12 +000065
cgdeckerfa95e382014-10-31 12:30:47 -070066- [GitHub project](https://github.com/google/guava)
Stevef1a0a2e2016-03-22 08:04:17 -070067- [Issue tracker: Report a defect or feature request](https://github.com/google/guava/issues/new)
cgdeckerfa95e382014-10-31 12:30:47 -070068- [StackOverflow: Ask "how-to" and "why-didn't-it-work" questions](https://stackoverflow.com/questions/ask?tags=guava+java)
69- [guava-discuss: For open-ended questions and discussion](http://groups.google.com/group/guava-discuss)
kevinb@google.com95e8bd22010-04-09 17:02:12 +000070
cgdeckerf40d6872016-12-28 11:24:17 -080071## IMPORTANT WARNINGS
kevinb@google.com95e8bd22010-04-09 17:02:12 +000072
cgdeckerfa95e382014-10-31 12:30:47 -0700731. APIs marked with the `@Beta` annotation at the class or method level
guava.mirrorbot@gmail.com509fe0a2010-12-06 18:31:42 +000074are subject to change. They can be modified in any way, or even
75removed, at any time. If your code is a library itself (i.e. it is
76used on the CLASSPATH of users outside your own control), you should
cpovirk04df3ed2017-12-21 14:09:57 -080077not use beta APIs, unless you [repackage] them. **If your
cgdecker079db392017-12-21 10:29:46 -080078code is a library, we strongly recommend using the [Guava Beta Checker] to
79ensure that you do not use any `@Beta` APIs!**
kevinb@google.com95e8bd22010-04-09 17:02:12 +000080
cpovirk3a3e4952017-09-29 10:50:56 -0700812. APIs without `@Beta` will remain binary-compatible for the indefinite
82future. (Previously, we sometimes removed such APIs after a deprecation period.
83The last release to remove non-`@Beta` APIs was Guava 21.0.) Even `@Deprecated`
84APIs will remain (again, unless they are `@Beta`). We have no plans to start
85removing things again, but officially, we're leaving our options open in case
86of surprises (like, say, a serious security problem).
guava.mirrorbot@gmail.com509fe0a2010-12-06 18:31:42 +000087
cgdecker292118d2018-10-18 13:32:32 -0700883. Guava has one dependency that is needed at runtime:
89`com.google.guava:failureaccess:1.0`
90
914. Serialized forms of ALL objects are subject to change unless noted
Colin Decker5b8c0492014-07-07 16:37:27 -040092otherwise. Do not persist these and assume they can be read by a
93future version of the library.
kevinb@google.com95e8bd22010-04-09 17:02:12 +000094
cgdecker292118d2018-10-18 13:32:32 -0700955. Our classes are not designed to protect against a malicious caller.
fry@google.com3fbaf562011-01-27 19:37:40 +000096You should not use them for communication between trusted and
97untrusted code.
98
cgdecker292118d2018-10-18 13:32:32 -0700996. For the mainline flavor, we unit-test the libraries using only OpenJDK 1.8 on
cgdeckerfa95e382014-10-31 12:30:47 -0700100Linux. Some features, especially in `com.google.common.io`, may not work
cpovirk6fba8d12017-09-28 08:41:15 -0700101correctly in other environments. For the Android flavor, our unit tests run on
102API level 15 (Ice Cream Sandwich).
dpb4d0e0af2017-05-23 08:14:38 -0700103
ronshapiro3383db72018-04-20 13:28:45 -0700104[guava-snapshot-api-docs]: https://google.github.io/guava/releases/snapshot-jre/api/docs/
105[guava-snapshot-api-diffs]: https://google.github.io/guava/releases/snapshot-jre/api/diffs/
cgdeckera91e6f22015-07-15 11:43:30 -0700106[Guava Explained]: https://github.com/google/guava/wiki/Home
cgdecker079db392017-12-21 10:29:46 -0800107[Guava Beta Checker]: https://github.com/google/guava-beta-checker
cpovirk08983fb2017-12-08 08:16:19 -0800108
109<!-- References -->
110
cgdeckerfffd6a32018-05-25 12:32:08 -0700111[using Guava in your build]: https://github.com/google/guava/wiki/UseGuavaInYourBuild
cpovirkcabe9702017-12-21 14:44:51 -0800112[repackage]: https://github.com/google/guava/wiki/UseGuavaInYourBuild#what-if-i-want-to-use-beta-apis-from-a-library-that-people-use-as-a-dependency
cpovirk08983fb2017-12-08 08:16:19 -0800113