Use the client library through Maven or Gradle when possible. Binary
distributions are available through the
[Maven Central repository](https://search.maven.org/artifact/com.google.api-ads/google-ads) (see the [quick start guide](https://developers.google.com/google-ads/api/docs/client-libs/java)
for details). However, you can build the library yourself using the build
process described on this page.

The client library is built with Gradle. Dependencies are downloaded from the
Maven Central repository.

> [!NOTE]
> **Note:** If you build the library from source, ensure that you enable annotation processing in your IDE.

## Install Java Development Kit

JDK 8 or later is required to build the library. This guide assumes that Java is
installed on your machine.

## Build with Gradle

Use the included Gradle wrapper. See
[`gradle-wrapper.properties`](https://github.com/googleads/google-ads-java/blob/HEAD/gradle/wrapper/gradle-wrapper.properties) for the configured Gradle
wrapper version. You don't need a separate Gradle installation.

### Build the library

1. Clone the project into a local `google-ads-java` directory:

       git clone https://github.com/googleads/google-ads-java.git google-ads-java

2. Navigate to the `google-ads-java` directory:

       cd google-ads-java

3. Run the following command to build the snapshot version of the library and
   examples project:

       ./gradlew build

   > [!NOTE]
   > **Note:** On Windows, use `gradlew` instead of `./gradlew`.

4. Export the client library to your local Maven repository:

       ./gradlew publishToMavenLocal

   > [!NOTE]
   > **Note:** You can export the library to a local repository even if you have not used or installed Maven previously. Directories are created as needed.

## Use the client library in a local Maven repository

After a successful build and export, the artifacts for the client library are
available to Maven and Gradle from your local repository (typically
`~/.m2/repository/com/google/api-ads/google-ads/`). Check
[`gradle.properties`](https://github.com/googleads/google-ads-java/blob/HEAD/gradle.properties) for the current `SNAPSHOT` version string,
and then add a dependency on that `SNAPSHOT` version to your project build
files.

In Maven (`pom.xml`):

    <dependency>
      <groupId>com.google.api-ads</groupId>
      <artifactId>google-ads</artifactId>
      <version>VERSION-SNAPSHOT</version>
    </dependency>

In Gradle (`build.gradle`):

    implementation 'com.google.api-ads:google-ads:VERSION-SNAPSHOT'