Adding Cloud Client Libraries to Your Maven Projects

This document describes how to add Cloud Client Libraries for Java to your Maven project. It also describes how to create a service account and download its key.

Before You Begin

Follow the Quickstart to install and setup IntelliJ IDEA.

Adding the Cloud Client Libraries

To add libraries to your project in IntelliJ:

  1. Select Tools > Google Cloud Tools > Add Cloud libraries.

    The Add Cloud Libraries dialog displays the supported libraries.

    Screenshot showing the Add Cloud Libraries dialog. This dialog
 provides a drop-down menu to select a module to add the libraries to,
 displays the list of APIs available to add, and provides a work area that
 displays information about the API.

  2. In the GCP Project: field, be sure that the right project and account are shown. If not, click the ellipse to pick the correct project and account.

  3. In the Add Client Library to Module drop-down menu, select the module that you want to add the library to.

  4. In the Google Cloud Java drop-down menu, select the version of the Google Cloud Java BOM you want to use.

    Google Cloud Java solves version conflicts between libraries by adding the Google Cloud Java Bill of Materials (BOM) to the pom.xml file of your projects.

  5. Select the checkbox for each library you want to add.

  6. Click Add Client Library.

    The Enable GCP APIs and Manage Service Accounts Confirmation dialog displays.

    Screenshot showing the confirmation dialog for adding roles to a new
 service account and for entering a path to download the key. The dialog
 also displays the APIs that will be added to the project.

  7. In the Service account name field, keep the default name or enter a new one.

  8. In the Download path field, navigate to the location where you want to download the service account key.

  9. If your API requires it, select which roles you want to add to the service account.

  10. Click OK.

    Screenshot showing the confirmation that the
 service account was created and the path to the key.

    IntelliJ makes the following updates:

    • adds the selected dependencies to your pom.xml.

    • enables the selected APIs on the Google Cloud Platform.

    • creates the service account and downloads its key to the specified location.

  11. To access the Google Cloud APIs locally, set the following environment variables on your local development server:

    • add GOOGLE_APPLICATION_CREDENTIALS and set its value to the path of your service account key.

    • add GOOGLE_CLOUD_PROJECT and set its value to the ID of your project.

What's next

Was this page helpful? Let us know how we did:

Send feedback about...

Cloud Tools for IntelliJ
Need help? Visit our support page.