1# Guava: Google Core Libraries for Java 2 3[![Latest release](https://img.shields.io/github/release/google/guava.svg)](https://github.com/google/guava/releases/latest) 4[![Build Status](https://travis-ci.org/google/guava.svg?branch=master)](https://travis-ci.org/google/guava) 5 6Guava is a set of core Java libraries from Google that includes new collection types 7(such as multimap and multiset), immutable collections, a graph library, and 8utilities for concurrency, I/O, hashing, caching, primitives, strings, and more! It 9is widely used on most Java projects within Google, and widely used by many 10other companies as well. 11 12Guava comes in two flavors. 13 14* The JRE flavor requires JDK 1.8 or higher. 15* If you need support for JDK 1.7 or Android, use the Android flavor. You can 16 find the Android Guava source in the [`android` directory]. 17 18[`android` directory]: https://github.com/google/guava/tree/master/android 19 20## Adding Guava to your build 21 22Guava's Maven group ID is `com.google.guava`, and its artifact ID is `guava`. 23Guava provides two different "flavors": one for use on a (Java 8+) JRE and one 24for use on Android or Java 7 or by any library that wants to be compatible with 25either of those. These flavors are specified in the Maven version field as 26either `30.0-jre` or `30.0-android`. For more about depending on Guava, see 27[using Guava in your build]. 28 29To add a dependency on Guava using Maven, use the following: 30 31```xml 32<dependency> 33 <groupId>com.google.guava</groupId> 34 <artifactId>guava</artifactId> 35 <version>30.0-jre</version> 36 <!-- or, for Android: --> 37 <version>30.0-android</version> 38</dependency> 39``` 40 41To add a dependency using Gradle: 42 43```gradle 44dependencies { 45 // Pick one: 46 47 // 1. Use Guava in your implementation only: 48 implementation("com.google.guava:guava:30.0-jre") 49 50 // 2. Use Guava types in your public API: 51 api("com.google.guava:guava:30.0-jre") 52 53 // 3. Android - Use Guava in your implementation only: 54 implementation("com.google.guava:guava:30.0-android") 55 56 // 4. Android - Use Guava types in your public API: 57 api("com.google.guava:guava:30.0-android") 58} 59``` 60 61For more information on when to use `api` and when to use `implementation`, 62consult the 63[Gradle documentation on API and implementation separation](https://docs.gradle.org/current/userguide/java_library_plugin.html#sec:java_library_separation). 64 65## Snapshots and Documentation 66 67Snapshots of Guava built from the `master` branch are available through Maven 68using version `HEAD-jre-SNAPSHOT`, or `HEAD-android-SNAPSHOT` for the Android 69flavor. 70 71- Snapshot API Docs: [guava][guava-snapshot-api-docs] 72- Snapshot API Diffs: [guava][guava-snapshot-api-diffs] 73 74## Learn about Guava 75 76- Our users' guide, [Guava Explained] 77- [A nice collection](http://www.tfnico.com/presentations/google-guava) of 78 other helpful links 79 80## Links 81 82- [GitHub project](https://github.com/google/guava) 83- [Issue tracker: Report a defect or feature request](https://github.com/google/guava/issues/new) 84- [StackOverflow: Ask "how-to" and "why-didn't-it-work" questions](https://stackoverflow.com/questions/ask?tags=guava+java) 85- [guava-announce: Announcements of releases and upcoming significant changes](http://groups.google.com/group/guava-announce) 86- [guava-discuss: For open-ended questions and discussion](http://groups.google.com/group/guava-discuss) 87 88## IMPORTANT WARNINGS 89 901. APIs marked with the `@Beta` annotation at the class or method level are 91 subject to change. They can be modified in any way, or even removed, at any 92 time. If your code is a library itself (i.e., it is used on the CLASSPATH of 93 users outside your own control), you should not use beta APIs unless you 94 [repackage] them. **If your code is a library, we strongly recommend using 95 the [Guava Beta Checker] to ensure that you do not use any `@Beta` APIs!** 96 972. APIs without `@Beta` will remain binary-compatible for the indefinite 98 future. (Previously, we sometimes removed such APIs after a deprecation 99 period. The last release to remove non-`@Beta` APIs was Guava 21.0.) Even 100 `@Deprecated` APIs will remain (again, unless they are `@Beta`). We have no 101 plans to start removing things again, but officially, we're leaving our 102 options open in case of surprises (like, say, a serious security problem). 103 1043. Guava has one dependency that is needed at runtime: 105 `com.google.guava:failureaccess:1.0.1` 106 1074. Serialized forms of ALL objects are subject to change unless noted 108 otherwise. Do not persist these and assume they can be read by a future 109 version of the library. 110 1115. Our classes are not designed to protect against a malicious caller. You 112 should not use them for communication between trusted and untrusted code. 113 1146. For the mainline flavor, we unit-test the libraries using only OpenJDK 1.8 115 on Linux. Some features, especially in `com.google.common.io`, may not work 116 correctly in other environments. For the Android flavor, our unit tests run 117 on API level 15 (Ice Cream Sandwich). 118 119[guava-snapshot-api-docs]: https://guava.dev/releases/snapshot-jre/api/docs/ 120[guava-snapshot-api-diffs]: https://guava.dev/releases/snapshot-jre/api/diffs/ 121[Guava Explained]: https://github.com/google/guava/wiki/Home 122[Guava Beta Checker]: https://github.com/google/guava-beta-checker 123 124<!-- References --> 125 126[using Guava in your build]: https://github.com/google/guava/wiki/UseGuavaInYourBuild 127[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 128 129