You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CONTRIBUTING.md
+16Lines changed: 16 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,6 +15,22 @@ Using maven for build/test
15
15
After you cloned the repository use Maven for building and running the tests.
16
16
Maven 3.0+ is required.
17
17
18
+
When downloading the source, we recommend you obtain service account credentials.
19
+
These credentials will allow you to run integration tests using `mvn verify` in command line.
20
+
Follow step 2 of the [authentication instructions](https://github.com/GoogleCloudPlatform/gcloud-java#authentication) to generate and use JSON service account credentials.
21
+
22
+
It's also important to test that changes don't break compatibility with App/Compute Engine and when running elsewhere.
23
+
To run tests on different platforms, try deploying the apps available on the [gcloud-java-examples](https://github.com/GoogleCloudPlatform/gcloud-java-examples) repository.
24
+
End-to-end tests should ensure that gcloud-java works when running on the
25
+
26
+
* App Engine production environment (see the docs for [uploading your app to production App Engine](https://cloud.google.com/appengine/docs/java/tools/maven#uploading_your_app_to_production_app_engine))
27
+
* App Engine development server (see the docs for [testing your app with the development server](https://cloud.google.com/appengine/docs/java/tools/maven#testing_your_app_with_the_development_server))
28
+
* Compute Engine (see the [Getting Started Guide](https://cloud.google.com/compute/docs/quickstart), and be sure to [enable the appropriate APIs](https://github.com/GoogleCloudPlatform/gcloud-common/tree/master/authentication#on-google-compute-engine))
29
+
* Your desktop (using `mvn exec:java`, for example)
30
+
31
+
When changes are made to authentication and project ID-related code, authentication and project ID inference should be tested using all relevant methods detailed in the [authentication docs](https://github.com/GoogleCloudPlatform/gcloud-java#authentication) and [project ID docs](https://github.com/GoogleCloudPlatform/gcloud-java#specifying-a-project-id).
32
+
33
+
Known issue: If you have installed the Google Cloud SDK, be sure to log in (using `gcloud auth login`) before running tests. Though the Datastore tests use a local Datastore emulator that doesn't require authentication, they will not run if you have the Google Cloud SDK installed but aren't authenticated.
-[`BigQueryExample`](https://github.com/GoogleCloudPlatform/gcloud-java/blob/master/gcloud-java-examples/src/main/java/com/google/gcloud/examples/BigQueryExample.java) - A simple command line interface providing some of Cloud BigQuery's functionality
46
+
- Read more about using this application on the [`gcloud-java-examples` docs page](http://googlecloudplatform.github.io/gcloud-java/apidocs/?com/google/gcloud/examples/BigQueryExample.html).
47
+
-[`Bookshelf`](https://github.com/GoogleCloudPlatform/getting-started-java/tree/master/bookshelf) - An App Engine app that manages a virtual bookshelf.
48
+
- This app uses `gcloud-java` to interface with Cloud Datastore and Cloud Storage. It also uses Cloud SQL, another Google Cloud Platform service.
35
49
-[`DatastoreExample`](https://github.com/GoogleCloudPlatform/gcloud-java/blob/master/gcloud-java-examples/src/main/java/com/google/gcloud/examples/DatastoreExample.java) - A simple command line interface for the Cloud Datastore
36
50
- Read more about using this application on the [`gcloud-java-examples` docs page](http://googlecloudplatform.github.io/gcloud-java/apidocs/?com/google/gcloud/examples/DatastoreExample.html).
51
+
-[`ResourceManagerExample`](https://github.com/GoogleCloudPlatform/gcloud-java/blob/master/gcloud-java-examples/src/main/java/com/google/gcloud/examples/ResourceManagerExample.java) - A simple command line interface providing some of Cloud Resource Manager's functionality
52
+
- Read more about using this application on the [`gcloud-java-examples` docs page](http://googlecloudplatform.github.io/gcloud-java/apidocs/?com/google/gcloud/examples/ResourceManagerExample.html).
53
+
-[`SparkDemo`](https://github.com/GoogleCloudPlatform/java-docs-samples/blob/master/managedvms/sparkjava) - An example of using gcloud-java-datastore from within the SparkJava and App Engine Managed VM frameworks.
54
+
- Read about how it works on the example's [README page](https://github.com/GoogleCloudPlatform/java-docs-samples/tree/master/managedvms/sparkjava#how-does-it-work).
37
55
-[`StorageExample`](https://github.com/GoogleCloudPlatform/gcloud-java/blob/master/gcloud-java-examples/src/main/java/com/google/gcloud/examples/StorageExample.java) - A simple command line interface providing some of Cloud Storage's functionality
38
56
- Read more about using this application on the [`gcloud-java-examples` docs page](http://googlecloudplatform.github.io/gcloud-java/apidocs/?com/google/gcloud/examples/StorageExample.html).
39
57
58
+
Specifying a Project ID
59
+
-----------------------
60
+
61
+
Most `gcloud-java` libraries require a project ID. There are multiple ways to specify this project ID.
62
+
63
+
1. When using `gcloud-java` libraries from within Compute/App Engine, there's no need to specify a project ID. It is automatically inferred from the production environment.
64
+
2. When using `gcloud-java` elsewhere, you can do one of the following:
65
+
* Supply the project ID when building the service options. For example, to use Datastore from a project with ID "PROJECT_ID", you can write:
* Specify the environment variable `GCLOUD_PROJECT` to be your desired project ID.
71
+
* Set the project ID using the [Google Cloud SDK](https://cloud.google.com/sdk/?hl=en). To use the SDK, [download the SDK](https://cloud.google.com/sdk/?hl=en) if you haven't already, and set the project ID from the command line. For example:
72
+
73
+
```
74
+
gcloud config set project PROJECT_ID
75
+
```
76
+
77
+
`gcloud-java` determines the project ID from the following sources in the listed order, stopping once it finds a value:
78
+
79
+
1. Project ID supplied when building the service options
80
+
2. Project ID specified by the environment variable `GCLOUD_PROJECT`
81
+
3. App Engine project ID
82
+
4. Google Cloud SDK project ID
83
+
5. Compute Engine project ID
84
+
40
85
Authentication
41
86
--------------
42
87
43
-
There are multiple ways to authenticate to use Google Cloud services.
88
+
First, ensure that the necessary Google Cloud APIs are enabled for your project. To do this, follow the instructions on the [authentication document](https://github.com/GoogleCloudPlatform/gcloud-common/blob/master/authentication/readme.md#authentication) shared by all the gcloud language libraries.
89
+
90
+
Next, choose a method for authenticating API requests from within your project:
44
91
45
92
1. When using `gcloud-java` libraries from within Compute/App Engine, no additional authentication steps are necessary.
46
93
2. When using `gcloud-java` libraries elsewhere, there are two options:
47
-
*[Generate a JSON service account key](https://cloud.google.com/storage/docs/authentication?hl=en#service_accounts). Supply a path to the downloaded JSON credentials file when building the options supplied to datastore/storage constructor.
48
-
* If running locally for development/testing, you can use use [Google Cloud SDK](https://cloud.google.com/sdk/?hl=en). To use the SDK authentication, [download the SDK](https://cloud.google.com/sdk/?hl=en) if you haven't already. Then login using the SDK (`gcloud auth login` in command line), and set your current project using `gcloud config set project PROJECT_ID`.
94
+
*[Generate a JSON service account key](https://cloud.google.com/storage/docs/authentication?hl=en#service_accounts). After downloading that key, you must do one of the following:
95
+
* Define the environment variable GOOGLE_APPLICATION_CREDENTIALS to be the location of the key. For example:
* Supply the JSON credentials file when building the service options. For example, this Storage object has the necessary permissions to interact with your Google Cloud Storage data:
* If running locally fordevelopment/testing, you can use use Google Cloud SDK. Download the SDK if you haven't already, then login using the SDK (`gcloud auth login`incommand line). Be sure to set your project ID as described above.
107
+
108
+
`gcloud-java` looks forcredentialsin the following order, stopping once it finds credentials:
109
+
110
+
1. Credentials supplied when building the service options
111
+
2. App Engine credentials
112
+
3. Key file pointed to by the GOOGLE_APPLICATION_CREDENTIALS environment variable
113
+
4. Google Cloud SDK credentials
114
+
5. Compute Engine credentials
115
+
116
+
Google Cloud BigQuery (Alpha)
117
+
----------------------
118
+
119
+
- [API Documentation][bigquery-api]
120
+
- [Official Documentation][cloud-bigquery-docs]
121
+
122
+
#### Preview
123
+
124
+
Here is a code snippet showing a simple usage example from within Compute/App Engine. Note that you
125
+
must [supply credentials](#authentication) and a project ID if running this snippet elsewhere.
Here is a code snippet showing a simple usage example. Note that you must supply Google SDK credentials forthis service, not other forms of authentication listedin the [Authentication section](#authentication).
To get help, follow the `gcloud-java` links in the `gcloud-*` [shared Troubleshooting document](https://github.com/GoogleCloudPlatform/gcloud-common/blob/master/troubleshooting/readme.md#troubleshooting).
275
+
132
276
Java Versions
133
277
-------------
134
278
@@ -155,7 +299,7 @@ Contributing
155
299
156
300
Contributions to this library are always welcome and highly encouraged.
157
301
158
-
See [CONTRIBUTING] for more information on how to get started.
302
+
See `gcloud-java`'s [CONTRIBUTING] documentation and the `gcloud-*` [shared documentation](https://github.com/GoogleCloudPlatform/gcloud-common/blob/master/contributing/readme.md#how-to-contribute-to-gcloud)for more information on how to get started.
159
303
160
304
Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms. See [Code of Conduct][code-of-conduct] for more information.
161
305
@@ -166,7 +310,7 @@ Apache 2.0 - See [LICENSE] for more information.
0 commit comments