Skip to content

Commit ff02edd

Browse files
authored
internal: readme cleanup (googleapis#1111)
* internal: readme cleanup Also document steps to build and test, incl getting google-play-services jar installed.
1 parent 98c160e commit ff02edd

2 files changed

Lines changed: 185 additions & 112 deletions

File tree

README.md

Lines changed: 183 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,52 @@
1010
- [Documentation](#Documentation)
1111
- [Links](#Links)
1212

13-
## <a name='maintenance'>Library maintenance</a>
13+
## Library maintenance
1414

15-
This client library is supported but in maintenance mode only. We are fixing necessary bugs and adding essential features to ensure this library continues to meet your needs for accessing Google APIs. Non-critical issues will be closed. Any issue may be reopened if it is causing ongoing problems.
15+
This client library is supported but in maintenance mode only. We are fixing necessary bugs and
16+
adding essential features to ensure this library continues to meet your needs for accessing Google
17+
APIs. Non-critical issues will be closed. Any issue may be reopened if it is causing ongoing problems.
1618

17-
If you're working with **Google Cloud Platform** APIs such as Datastore, Pub/Sub and many others, consider using the [Cloud Client Libraries for Java](https://github.com/GoogleCloudPlatform/google-cloud-java) instead. These are the new and idiomatic Java libraries targeted specifically at Google Cloud Platform Services.
19+
If you're working with **Google Cloud Platform** APIs such as Datastore, Pub/Sub and many others,
20+
consider using the [Cloud Client Libraries for Java](https://github.com/GoogleCloudPlatform/google-cloud-java)
21+
instead. These are the new and idiomatic Java libraries targeted specifically at Google Cloud
22+
Platform Services.
1823

19-
## <a name='Overview'>Overview<a/>
24+
## Building locally
2025

21-
The Google APIs Client Library for Java is a flexible, efficient, and powerful Java client library for accessing any HTTP-based API on the web, not just Google APIs.
26+
##### One time setup
27+
28+
```
29+
mkdir /tmp/foo && cd /tmp/foo
30+
wget https://dl.google.com/dl/android/maven2/com/google/android/gms/play-services-basement/8.3.0/play-services-basement-8.3.0.aar
31+
unzip play-services-basement-8.3.0.aar
32+
mvn install:install-file \
33+
-Dfile=classes.jar \
34+
-DgroupId=com.google.android.google-play-services \
35+
-DartifactId=google-play-services \
36+
-Dversion=1 \
37+
-Dpackaging=jar
38+
cd -
39+
40+
# we need the google-http-java-client jar cached locally
41+
git clone https://github.com/google/google-http-java-client.git
42+
cd google-http-java-client && mvn compile && mvn install && cd ..
43+
44+
# we need the google-oauth-java-client jar cached locally
45+
git clone https://github.com/google/google-oauth-java-client.git
46+
cd google-oauth-java-client && mvn compile && mvn install
47+
```
48+
49+
##### Building And Testing
50+
51+
```
52+
mvn install
53+
```
54+
55+
## Overview
56+
57+
The Google APIs Client Library for Java is a flexible, efficient, and powerful Java client library
58+
for accessing any HTTP-based API on the web, not just Google APIs.
2259

2360
The library has the following features:
2461
- A powerful [OAuth 2.0](https://developers.google.com/api-client-library/java/google-api-java-client/oauth2) library with a consistent interface.
@@ -30,152 +67,193 @@ The library has the following features:
3067

3168
To use Google's Java client libraries to call any Google API, you need two libraries:
3269

33-
- The core Google APIs Client Library for Java (google-api-java-client), which is the generic runtime library described here. This library provides functionality common to all APIs, for example HTTP transport, error handling, authentication, JSON parsing, media download/upload, and batching.
34-
- An auto-generated Java library for the API you are accessing, for example the [generated Java library for the BigQuery API](https://github.com/google/google-api-java-client-samples/tree/master/bigquery-appengine-sample/src/main/java/com/google/api/client/sample/bigquery/appengine/dashboard). These generated libraries include API-specific information such as the root URL, and classes that represent entities in the context of the API. These classes are useful for making conversions between JSON objects and Java objects.
70+
- The core Google APIs Client Library for Java (google-api-java-client), which is the generic
71+
runtime library described here. This library provides functionality common to all APIs, for example
72+
HTTP transport, error handling, authentication, JSON parsing, media download/upload, and batching.
73+
- An auto-generated Java library for the API you are accessing, for example
74+
the [generated Java library for the BigQuery API](https://github.com/google/google-api-java-client-samples/tree/master/bigquery-appengine-sample/src/main/java/com/google/api/client/sample/bigquery/appengine/dashboard).
75+
These generated libraries include API-specific information such as the root URL, and classes that
76+
represent entities in the context of the API. These classes are useful for making conversions
77+
between JSON objects and Java objects.
3578

36-
To find the generated library for a Google API, visit [Google APIs Client Library for Java](https://developers.google.com/api-client-library/java/apis/). The API-specific Java packages include both the core google-api-java-client and the client-specific libraries.
79+
To find the generated library for a Google API, visit [Google APIs Client Library for Java](https://developers.google.com/api-client-library/java/apis/).
80+
The API-specific Java packages include both the core google-api-java-client and the client-specific
81+
libraries.
3782

3883
If you are using the old GData library, you need to
3984
[migrate](https://github.com/google/gdata-java-client/blob/wiki/MigratingToGoogleApiJavaClient.md).
4085

4186
### Developing for Android
4287

43-
If you are developing for Android and the Google API you want to use is included in the [Google Play Services library](https://developer.android.com/google/play-services/index.html), you should use that library for the best performance and experience.
88+
If you are developing for Android and the Google API you want to use is included in the
89+
[Google Play Services library](https://developer.android.com/google/play-services/index.html), you
90+
should use that library for the best performance and experience.
4491

45-
To access other Google APIs, you can use the Google APIs Client Library for Java, which supports [Android 1.5 (or higher)](https://developers.google.com/api-client-library/java/google-api-java-client/android).
92+
To access other Google APIs, you can use the Google APIs Client Library for Java, which supports
93+
[Android 1.5 (or higher)](https://developers.google.com/api-client-library/java/google-api-java-client/android).
4694

4795
### Other Java environments
4896

49-
In addition to Android 1.5 or higher, the Google APIs Client Library for Java supports the following Java environments:
50-
- Java 5 (or higher), standard (SE) and enterprise (EE)
51-
- [Google App Engine](https://developers.google.com/api-client-library/java/google-api-java-client/app-engine)
97+
In addition to Android 1.5 or higher, the Google APIs Client Library for Java supports the following
98+
Java environments:
99+
100+
- Java 5 (or higher), standard (SE) and enterprise (EE)
101+
- [Google App Engine](https://developers.google.com/api-client-library/java/google-api-java-client/app-engine)
52102

53103
Not supported: Google Web Toolkit (GWT), Java mobile (ME), and Java 1.4 (or earlier).
54104

55-
## <a name='Highlighted_Features'>Highlighted Features<a/>
105+
## Highlighted Features
106+
56107
- **The library makes it simple to call Google APIs.**
57108

58-
You can call Google APIs using Google service-specific generated libraries with the Google APIs Client Library for Java. Here's an example that makes a call to the [Google Calendar API](https://developers.google.com/google-apps/calendar/):
109+
You can call Google APIs using Google service-specific generated libraries with the Google APIs
110+
Client Library for Java. Here's an example that makes a call to the
111+
[Google Calendar API](https://developers.google.com/google-apps/calendar/):
59112

60-
```java
61-
// Show events on user's calendar.
62-
View.header("Show Calendars");
63-
CalendarList feed = client.calendarList().list().execute();
64-
View.display(feed);
65-
```
113+
```java
114+
// Show events on user's calendar.
115+
View.header("Show Calendars");
116+
CalendarList feed = client.calendarList().list().execute();
117+
View.display(feed);
118+
```
66119

67120
- **The library makes authentication easier.**
68121

69-
The authentication library can reduce the amount of code needed to handle [OAuth 2.0](https://developers.google.com/api-client-library/java/google-api-java-client/oauth2), and sometimes a few lines is all you need. For example:
70-
71-
```java
72-
/** Authorizes the installed application to access user's protected data. */
73-
private static Credential authorize() throws Exception {
74-
// load client secrets
75-
GoogleClientSecrets clientSecrets = GoogleClientSecrets.load(JSON_FACTORY,
76-
new InputStreamReader(CalendarSample.class.getResourceAsStream("/client_secrets.json")));
77-
// set up authorization code flow
78-
GoogleAuthorizationCodeFlow flow = new GoogleAuthorizationCodeFlow.Builder(
79-
httpTransport, JSON_FACTORY, clientSecrets,
80-
Collections.singleton(CalendarScopes.CALENDAR)).setDataStoreFactory(dataStoreFactory)
81-
.build();
82-
// authorize
83-
return new AuthorizationCodeInstalledApp(flow, new LocalServerReceiver()).authorize("user");
84-
}
85-
```
122+
The authentication library can reduce the amount of code needed to handle
123+
[OAuth 2.0](https://developers.google.com/api-client-library/java/google-api-java-client/oauth2),
124+
and sometimes a few lines is all you need. For example:
125+
126+
```java
127+
/** Authorizes the installed application to access user's protected data. */
128+
private static Credential authorize() throws Exception {
129+
// load client secrets
130+
GoogleClientSecrets clientSecrets = GoogleClientSecrets.load(JSON_FACTORY,
131+
new InputStreamReader(CalendarSample.class.getResourceAsStream("/client_secrets.json")));
132+
// set up authorization code flow
133+
GoogleAuthorizationCodeFlow flow = new GoogleAuthorizationCodeFlow.Builder(
134+
httpTransport, JSON_FACTORY, clientSecrets,
135+
Collections.singleton(CalendarScopes.CALENDAR)).setDataStoreFactory(dataStoreFactory)
136+
.build();
137+
// authorize
138+
return new AuthorizationCodeInstalledApp(flow, new LocalServerReceiver()).authorize("user");
139+
}
140+
```
141+
86142
- **The library makes batching and media upload/download easier.**
87143

88-
The library offers helper classes for [batching](https://developers.google.com/api-client-library/java/google-api-java-client/batch), [media upload](https://developers.google.com/api-client-library/java/google-api-java-client/media-upload), and [media download](https://developers.google.com/api-client-library/java/google-api-java-client/media-download).
144+
The library offers helper classes for
145+
[batching](https://developers.google.com/api-client-library/java/google-api-java-client/batch),
146+
[media upload](https://developers.google.com/api-client-library/java/google-api-java-client/media-upload),
147+
and [media download](https://developers.google.com/api-client-library/java/google-api-java-client/media-download).
89148

90149
- **The library runs on Google App Engine.**
91150

92-
[App Engine-specific helpers](https://developers.google.com/api-client-library/java/google-api-java-client/app-engine) make quick work of authenticated calls to APIs, and you do not need to worry about exchanging code for tokens. For example:
93-
94-
```java
95-
@Override
96-
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
97-
AppIdentityCredential credential =
98-
new AppIdentityCredential(Arrays.asList(UrlshortenerScopes.URLSHORTENER));
99-
Urlshortener shortener =
100-
new Urlshortener.Builder(new UrlFetchTransport(), new JacksonFactory(), credential)
101-
.build();
102-
UrlHistory history = shortener.URL().list().execute();
103-
...
104-
}
105-
```
151+
[App Engine-specific helpers](https://developers.google.com/api-client-library/java/google-api-java-client/app-engine)
152+
make quick work of authenticated calls to APIs, and you do not need to worry about exchanging code for tokens.
153+
For example:
154+
155+
```java
156+
@Override
157+
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
158+
AppIdentityCredential credential =
159+
new AppIdentityCredential(Arrays.asList(UrlshortenerScopes.URLSHORTENER));
160+
Urlshortener shortener =
161+
new Urlshortener.Builder(new UrlFetchTransport(), new JacksonFactory(), credential)
162+
.build();
163+
UrlHistory history = shortener.URL().list().execute();
164+
...
165+
}
166+
```
106167

107168
- **The library runs on [Android (@Beta)](#@Beta).**
108169

109-
If you are developing for Android and the Google API you want to use is included in the [Google Play Services library](https://developer.android.com/google/play-services/index.html), you should use that library for the best performance and experience.
110-
111-
To access other Google APIs, you can use the Google Client Library for Java's Android-specific helper classes, which are are well-integrated with [Android AccountManager](http://developer.android.com/reference/android/accounts/AccountManager.html ). For example:
112-
113-
```java
114-
@Override
115-
public void onCreate(Bundle savedInstanceState) {
116-
super.onCreate(savedInstanceState);
117-
// Google Accounts
118-
credential =
119-
GoogleAccountCredential.usingOAuth2(this, Collections.singleton(TasksScopes.TASKS));
120-
SharedPreferences settings = getPreferences(Context.MODE_PRIVATE);
121-
credential.setSelectedAccountName(settings.getString(PREF_ACCOUNT_NAME, null));
122-
// Tasks client
123-
service =
124-
new com.google.api.services.tasks.Tasks.Builder(httpTransport, jsonFactory, credential)
125-
.setApplicationName("Google-TasksAndroidSample/1.0").build();
126-
}
127-
```
170+
If you are developing for Android and the Google API you want to use is included in the
171+
[Google Play Services library](https://developer.android.com/google/play-services/index.html),
172+
you should use that library for the best performance and experience.
173+
174+
To access other Google APIs, you can use the Google Client Library for Java's Android-specific
175+
helper classes, which are are well-integrated with
176+
[Android AccountManager](http://developer.android.com/reference/android/accounts/AccountManager.html).
177+
For example:
178+
179+
```java
180+
@Override
181+
public void onCreate(Bundle savedInstanceState) {
182+
super.onCreate(savedInstanceState);
183+
// Google Accounts
184+
credential =
185+
GoogleAccountCredential.usingOAuth2(this, Collections.singleton(TasksScopes.TASKS));
186+
SharedPreferences settings = getPreferences(Context.MODE_PRIVATE);
187+
credential.setSelectedAccountName(settings.getString(PREF_ACCOUNT_NAME, null));
188+
// Tasks client
189+
service =
190+
new com.google.api.services.tasks.Tasks.Builder(httpTransport, jsonFactory, credential)
191+
.setApplicationName("Google-TasksAndroidSample/1.0").build();
192+
}
193+
```
128194

129195
- **The library is easy to install.**
130196

131-
The Google APIs Client Library for Java is easy to install, and you can download the binary directly from the [Downloads page](https://developers.google.com/api-client-library/java/google-api-java-client/download), or you can use Maven or Gradle.
132-
To use Maven, add the following lines to your pom.xml file:
197+
The Google APIs Client Library for Java is easy to install, and you can download the binary
198+
directly from the [Downloads page](https://developers.google.com/api-client-library/java/google-api-java-client/download),
199+
or you can use Maven or Gradle.
200+
201+
To use Maven, add the following lines to your pom.xml file:
133202

134-
```maven
135-
<project>
136-
<dependencies>
137-
<dependency>
138-
<groupId>com.google.api-client</groupId>
139-
<artifactId>google-api-client</artifactId>
140-
<version>1.23.0</version>
141-
</dependency>
142-
</dependencies>
143-
</project>
144-
```
203+
```maven
204+
<project>
205+
<dependencies>
206+
<dependency>
207+
<groupId>com.google.api-client</groupId>
208+
<artifactId>google-api-client</artifactId>
209+
<version>1.23.0</version>
210+
</dependency>
211+
</dependencies>
212+
</project>
213+
```
145214

146-
To use Gradle, add the following lines to your build.gradle file:
215+
To use Gradle, add the following lines to your build.gradle file:
147216

148-
```gradle
149-
repositories {
150-
mavenCentral()
151-
}
152-
dependencies {
153-
compile 'com.google.api-client:google-api-client:1.23.0'
154-
}
155-
```
217+
```gradle
218+
repositories {
219+
mavenCentral()
220+
}
221+
dependencies {
222+
compile 'com.google.api-client:google-api-client:1.23.0'
223+
}
224+
```
156225

157-
## <a name='Dependencies'>Dependencies<a/>
158-
This library is built on top of two common libraries, also built by Google, and also designed to work with any HTTP service on the web:
159-
* [Google HTTP Client Library for Java](https://github.com/google/google-http-java-client)
160-
* [Google OAuth Client Library for Java](https://github.com/google/google-oauth-java-client)
226+
## Dependencies
227+
This library is built on top of two common libraries, also built by Google, and also designed to
228+
work with any HTTP service on the web:
161229

162-
## <a name='Warnings'>Important Warnings<a/>
230+
- [Google HTTP Client Library for Java](https://github.com/google/google-http-java-client)
231+
- [Google OAuth Client Library for Java](https://github.com/google/google-oauth-java-client)
163232

164-
### <a name='Beta'>@Beta<a/>
233+
## Important Warnings
165234

166-
Features marked with the @Beta annotation at the class or method level are subject to change. They might be modified in any way, or even removed, in any major release. You should not use beta features if your code is a library itself (that is, if your code is used on the CLASSPATH of users outside your own control).
235+
### @Beta
167236

168-
### <a name='Deprecations'>Deprecations<a/>
237+
Features marked with the @Beta annotation at the class or method level are subject to change. They
238+
might be modified in any way, or even removed, in any major release. You should not use beta features
239+
if your code is a library itself (that is, if your code is used on the CLASSPATH of users outside
240+
your own control).
169241

170-
Deprecated non-beta features will be removed eighteen months after the release in which they are first deprecated. You must fix your usages before this time. If you don't, any type of breakage might result, and you are not guaranteed a compilation error.
242+
### Deprecations
243+
244+
Deprecated non-beta features will be removed eighteen months after the release in which they are
245+
first deprecated. You must fix your usages before this time. If you don't, any type of breakage
246+
might result, and you are not guaranteed a compilation error.
247+
248+
## Documentation
171249

172-
## <a name='Documentation'>Documentation<a/>
173250
- [Developer's Guide](https://developers.google.com/api-client-library/java/google-api-java-client/dev-guide)
174251
- [Libraries and Samples](https://developers.google.com/api-client-library/java/apis/)
175252
- [JavaDoc](https://developers.google.com/api-client-library/java/google-api-java-client/reference/index)
176253
- [Get Help](https://developers.google.com/api-client-library/java/google-api-java-client/support)
177254

178-
## <a name='Links'>Links<a/>
255+
## Links
256+
179257
- Blogs
180258
- [Announcements](http://google-api-java-client.blogspot.com/)
181259
- [Announcements](http://googledevelopers.blogspot.com/)

pom.xml

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -286,13 +286,8 @@
286286
<artifactId>google-api-client-xml</artifactId>
287287
<version>${project.version}</version>
288288
</dependency>
289-
<!-- mvn install:install-file \
290-
-Dfile=$ANDROID_HOME/extras/google/google_play_services/libs/google-play-services.jar \
291-
-DgroupId=com.google.android.google-play-services \
292-
-DartifactId=google-play-services \
293-
-Dversion=1 \
294-
-Dpackaging=jar
295-
-->
289+
290+
<!-- See README.md about installing this jar -->
296291
<dependency>
297292
<groupId>com.google.android.google-play-services</groupId>
298293
<artifactId>google-play-services</artifactId>

0 commit comments

Comments
 (0)