cgdecker | f40d687 | 2016-12-28 11:24:17 -0800 | [diff] [blame] | 1 | # Guava: Google Core Libraries for Java |
kevinb@google.com | 95e8bd2 | 2010-04-09 17:02:12 +0000 | [diff] [blame] | 2 | |
cgdecker | fffd6a3 | 2018-05-25 12:32:08 -0700 | [diff] [blame] | 3 | [](https://github.com/google/guava/releases/latest) |
Jochen Schalanda | 124e573 | 2014-11-05 12:32:03 -0800 | [diff] [blame] | 4 | [](https://travis-ci.org/google/guava) |
| 5 | |
kak | d67899d | 2016-10-11 15:02:53 -0700 | [diff] [blame] | 6 | Guava is a set of core libraries that includes new collection types (such as |
| 7 | multimap and multiset), immutable collections, a graph library, functional |
| 8 | types, an in-memory cache, and APIs/utilities for concurrency, I/O, hashing, |
| 9 | primitives, reflection, string processing, and much more! |
vijaykakadiya | 65c42d9 | 2015-01-21 11:51:28 -0800 | [diff] [blame] | 10 | |
dpb | 4d0e0af | 2017-05-23 08:14:38 -0700 | [diff] [blame] | 11 | Guava comes in two flavors. |
| 12 | |
dpb | fb763ee | 2017-10-02 12:51:35 -0700 | [diff] [blame] | 13 | * The JRE flavor requires JDK 1.8 or higher. |
dpb | 4d0e0af | 2017-05-23 08:14:38 -0700 | [diff] [blame] | 14 | * 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.com | 95e8bd2 | 2010-04-09 17:02:12 +0000 | [diff] [blame] | 18 | |
cgdecker | fffd6a3 | 2018-05-25 12:32:08 -0700 | [diff] [blame] | 19 | ## Adding Guava to your build |
cgdecker | a91e6f2 | 2015-07-15 11:43:30 -0700 | [diff] [blame] | 20 | |
cgdecker | fffd6a3 | 2018-05-25 12:32:08 -0700 | [diff] [blame] | 21 | Guava's Maven group ID is `com.google.guava` and its artifact ID is `guava`. |
| 22 | Guava provides two different "flavors": one for use on a (Java 8+) JRE and one |
| 23 | for use on Android or Java 7 or by any library that wants to be compatible with |
| 24 | either of those. These flavors are specified in the Maven version field as |
cgdecker | 8e174e7 | 2019-03-07 11:48:23 -0800 | [diff] [blame] | 25 | either `27.1-jre` or `27.1-android`. For more about depending on |
cgdecker | fffd6a3 | 2018-05-25 12:32:08 -0700 | [diff] [blame] | 26 | Guava, see [using Guava in your build]. |
cgdecker | a91e6f2 | 2015-07-15 11:43:30 -0700 | [diff] [blame] | 27 | |
| 28 | To 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> |
cgdecker | 8e174e7 | 2019-03-07 11:48:23 -0800 | [diff] [blame] | 34 | <version>27.1-jre</version> |
dpb | 4d0e0af | 2017-05-23 08:14:38 -0700 | [diff] [blame] | 35 | <!-- or, for Android: --> |
cgdecker | 8e174e7 | 2019-03-07 11:48:23 -0800 | [diff] [blame] | 36 | <version>27.1-android</version> |
cgdecker | a91e6f2 | 2015-07-15 11:43:30 -0700 | [diff] [blame] | 37 | </dependency> |
| 38 | ``` |
| 39 | |
seabass | 54dc1b0 | 2015-09-21 10:09:38 -0700 | [diff] [blame] | 40 | To add a dependency using Gradle: |
| 41 | |
Elias Ojala | 4675e30 | 2018-08-13 09:06:28 -0700 | [diff] [blame] | 42 | ```gradle |
seabass | 54dc1b0 | 2015-09-21 10:09:38 -0700 | [diff] [blame] | 43 | dependencies { |
cgdecker | 8e174e7 | 2019-03-07 11:48:23 -0800 | [diff] [blame] | 44 | compile 'com.google.guava:guava:27.1-jre' |
dpb | 4d0e0af | 2017-05-23 08:14:38 -0700 | [diff] [blame] | 45 | // or, for Android: |
cgdecker | 8e174e7 | 2019-03-07 11:48:23 -0800 | [diff] [blame] | 46 | api 'com.google.guava:guava:27.1-android' |
seabass | 54dc1b0 | 2015-09-21 10:09:38 -0700 | [diff] [blame] | 47 | } |
| 48 | ``` |
dpb | 4d0e0af | 2017-05-23 08:14:38 -0700 | [diff] [blame] | 49 | |
cgdecker | f40d687 | 2016-12-28 11:24:17 -0800 | [diff] [blame] | 50 | ## Snapshots |
cgdecker | a91e6f2 | 2015-07-15 11:43:30 -0700 | [diff] [blame] | 51 | |
| 52 | Snapshots of Guava built from the `master` branch are available through Maven |
cgdecker | 11d3683 | 2017-10-03 14:26:37 -0700 | [diff] [blame] | 53 | using version `HEAD-jre-SNAPSHOT`, or `HEAD-android-SNAPSHOT` for the Android |
dpb | 4d0e0af | 2017-05-23 08:14:38 -0700 | [diff] [blame] | 54 | flavor. |
cgdecker | a91e6f2 | 2015-07-15 11:43:30 -0700 | [diff] [blame] | 55 | |
cgdecker | 8fbb7ac | 2015-10-01 14:39:22 -0700 | [diff] [blame] | 56 | - Snapshot API Docs: [guava][guava-snapshot-api-docs] |
cpovirk | a3da732 | 2017-08-11 11:17:48 -0700 | [diff] [blame] | 57 | - Snapshot API Diffs: [guava][guava-snapshot-api-diffs] |
cgdecker | a91e6f2 | 2015-07-15 11:43:30 -0700 | [diff] [blame] | 58 | |
cgdecker | f40d687 | 2016-12-28 11:24:17 -0800 | [diff] [blame] | 59 | ## Learn about Guava |
vijaykakadiya | 65c42d9 | 2015-01-21 11:51:28 -0800 | [diff] [blame] | 60 | |
dpb | 153ca2f | 2017-10-26 14:20:40 -0700 | [diff] [blame] | 61 | - Our users' guide, [Guava Explained] |
cgdecker | cc3b0f8 | 2015-06-08 10:56:45 -0700 | [diff] [blame] | 62 | - [A nice collection](http://www.tfnico.com/presentations/google-guava) of other helpful links |
vijaykakadiya | 65c42d9 | 2015-01-21 11:51:28 -0800 | [diff] [blame] | 63 | |
cgdecker | f40d687 | 2016-12-28 11:24:17 -0800 | [diff] [blame] | 64 | ## Links |
kevinb@google.com | 95e8bd2 | 2010-04-09 17:02:12 +0000 | [diff] [blame] | 65 | |
cgdecker | fa95e38 | 2014-10-31 12:30:47 -0700 | [diff] [blame] | 66 | - [GitHub project](https://github.com/google/guava) |
Steve | f1a0a2e | 2016-03-22 08:04:17 -0700 | [diff] [blame] | 67 | - [Issue tracker: Report a defect or feature request](https://github.com/google/guava/issues/new) |
cgdecker | fa95e38 | 2014-10-31 12:30:47 -0700 | [diff] [blame] | 68 | - [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.com | 95e8bd2 | 2010-04-09 17:02:12 +0000 | [diff] [blame] | 70 | |
cgdecker | f40d687 | 2016-12-28 11:24:17 -0800 | [diff] [blame] | 71 | ## IMPORTANT WARNINGS |
kevinb@google.com | 95e8bd2 | 2010-04-09 17:02:12 +0000 | [diff] [blame] | 72 | |
cgdecker | fa95e38 | 2014-10-31 12:30:47 -0700 | [diff] [blame] | 73 | 1. APIs marked with the `@Beta` annotation at the class or method level |
guava.mirrorbot@gmail.com | 509fe0a | 2010-12-06 18:31:42 +0000 | [diff] [blame] | 74 | are subject to change. They can be modified in any way, or even |
| 75 | removed, at any time. If your code is a library itself (i.e. it is |
| 76 | used on the CLASSPATH of users outside your own control), you should |
cpovirk | 04df3ed | 2017-12-21 14:09:57 -0800 | [diff] [blame] | 77 | not use beta APIs, unless you [repackage] them. **If your |
cgdecker | 079db39 | 2017-12-21 10:29:46 -0800 | [diff] [blame] | 78 | code is a library, we strongly recommend using the [Guava Beta Checker] to |
| 79 | ensure that you do not use any `@Beta` APIs!** |
kevinb@google.com | 95e8bd2 | 2010-04-09 17:02:12 +0000 | [diff] [blame] | 80 | |
cpovirk | 3a3e495 | 2017-09-29 10:50:56 -0700 | [diff] [blame] | 81 | 2. APIs without `@Beta` will remain binary-compatible for the indefinite |
| 82 | future. (Previously, we sometimes removed such APIs after a deprecation period. |
| 83 | The last release to remove non-`@Beta` APIs was Guava 21.0.) Even `@Deprecated` |
| 84 | APIs will remain (again, unless they are `@Beta`). We have no plans to start |
| 85 | removing things again, but officially, we're leaving our options open in case |
| 86 | of surprises (like, say, a serious security problem). |
guava.mirrorbot@gmail.com | 509fe0a | 2010-12-06 18:31:42 +0000 | [diff] [blame] | 87 | |
cgdecker | 292118d | 2018-10-18 13:32:32 -0700 | [diff] [blame] | 88 | 3. Guava has one dependency that is needed at runtime: |
| 89 | `com.google.guava:failureaccess:1.0` |
| 90 | |
| 91 | 4. Serialized forms of ALL objects are subject to change unless noted |
Colin Decker | 5b8c049 | 2014-07-07 16:37:27 -0400 | [diff] [blame] | 92 | otherwise. Do not persist these and assume they can be read by a |
| 93 | future version of the library. |
kevinb@google.com | 95e8bd2 | 2010-04-09 17:02:12 +0000 | [diff] [blame] | 94 | |
cgdecker | 292118d | 2018-10-18 13:32:32 -0700 | [diff] [blame] | 95 | 5. Our classes are not designed to protect against a malicious caller. |
fry@google.com | 3fbaf56 | 2011-01-27 19:37:40 +0000 | [diff] [blame] | 96 | You should not use them for communication between trusted and |
| 97 | untrusted code. |
| 98 | |
cgdecker | 292118d | 2018-10-18 13:32:32 -0700 | [diff] [blame] | 99 | 6. For the mainline flavor, we unit-test the libraries using only OpenJDK 1.8 on |
cgdecker | fa95e38 | 2014-10-31 12:30:47 -0700 | [diff] [blame] | 100 | Linux. Some features, especially in `com.google.common.io`, may not work |
cpovirk | 6fba8d1 | 2017-09-28 08:41:15 -0700 | [diff] [blame] | 101 | correctly in other environments. For the Android flavor, our unit tests run on |
| 102 | API level 15 (Ice Cream Sandwich). |
dpb | 4d0e0af | 2017-05-23 08:14:38 -0700 | [diff] [blame] | 103 | |
ronshapiro | 3383db7 | 2018-04-20 13:28:45 -0700 | [diff] [blame] | 104 | [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/ |
cgdecker | a91e6f2 | 2015-07-15 11:43:30 -0700 | [diff] [blame] | 106 | [Guava Explained]: https://github.com/google/guava/wiki/Home |
cgdecker | 079db39 | 2017-12-21 10:29:46 -0800 | [diff] [blame] | 107 | [Guava Beta Checker]: https://github.com/google/guava-beta-checker |
cpovirk | 08983fb | 2017-12-08 08:16:19 -0800 | [diff] [blame] | 108 | |
| 109 | <!-- References --> |
| 110 | |
cgdecker | fffd6a3 | 2018-05-25 12:32:08 -0700 | [diff] [blame] | 111 | [using Guava in your build]: https://github.com/google/guava/wiki/UseGuavaInYourBuild |
cpovirk | cabe970 | 2017-12-21 14:44:51 -0800 | [diff] [blame] | 112 | [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 |
cpovirk | 08983fb | 2017-12-08 08:16:19 -0800 | [diff] [blame] | 113 | |