Managing Cloud APIs and Libraries

This document describes how to enable Cloud APIs, manage service accounts and environment variables to access APIs locally, and add Cloud Client Libraries for Java to your Maven project.

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:

For Maven Projects

  1. Select Tools > Google Cloud Tools > Add Cloud libraries and Manage Cloud APIs.
  2. The Add Google 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.
  3. 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.
  4. In the Add Google Client Library to Module drop-down menu, select the module that you want to add the library to.
  5. In the Google Cloud Java drop-down menu, select the version of the Google Cloud Java BOM you want to use.
  6. 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.

  7. Select the checkbox for each library you want to add.
  8. Click Continue.
  9. 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.
  10. In the Service account name field, keep the default name or enter a new one.
  11. In the Download path field, navigate to the location where you want to download the service account key.
  12. If your API requires it, select which roles you want to add to the service account.
  13. Click OK.
  14. 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 Google Cloud Platform.
    • creates the service account and downloads its key to the specified location.
  15. To access the Google Cloud APIs locally, set the GOOGLE_APPLICATION_CREDENTIALS and GOOGLE_CLOUD_PROJECT environment variables on your local development server or on any of your local run configurations:
    1. Click the copy icon to copy the variables to your clipboard.
    2. Edit your run configuration.
    3. In the Environment Variables section, click the paste icon.
    4. For the local application server, this section appears on the Startup/Connection tab.

    5. The environment variables are automatically inserted for you.

For non-Maven Projects

  1. Select Tools > Google Cloud Tools > Manage Cloud APIs.
  2. The Manage Google Cloud APIs dialog displays the supported libraries.

    Screenshot showing the Add Cloud Libraries dialog. This
                      dialog displays the list of APIs available to add and
                      provides a work area that displays information about the
                      API.
  3. 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.
  4. Select the checkbox for each library you want to add.
  5. Click Continue.
  6. 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.
  11. Screenshot showing the confirmation that the service account
                    was created and the path to the key.

    IntelliJ makes the following updates:

    • enables the selected APIs on Google Cloud Platform.
    • creates the service account and downloads its key to the specified location.
  12. To access the Google Cloud APIs locally, set the GOOGLE_APPLICATION_CREDENTIALS and GOOGLE_CLOUD_PROJECT environment variables on your local development server or on any of your local run configurations:
    1. Click the copy icon to copy the variables to your clipboard.
    2. Edit your run configuration.
    3. In the Environment Variables section, click the paste icon.
    4. For the local application server, this section appears on the Startup/Connection tab.

    5. The environment variables are automatically inserted for you.

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.