Build the client library for Java from source

  • The client library can be used through Maven, binary distributions, or built from source.

  • Building the library requires JDK 1.8 or later and is done using Gradle.

  • After building, the library can be exported to a local Maven repository for use in other projects.

Use the client library through Maven or Gradle when possible. Binary distributions are available through the Maven Central repository (see the quick start guide 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.

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 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
    
  4. Export the client library to your local Maven repository:

    ./gradlew publishToMavenLocal
    

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 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'