Building the client library for Java from source

We recommend using the client library via Maven. We also provide binary distributions on our releases page and via the Maven central repository (see our quick start guide for details).

Install Java development kit

JDK > 1.8 is required to build the library. We'll assume that Java is installed on your machine for the purposes of this guide.

Install Apache Maven

The client library is built with Apache Maven. Maven is a build system with an integrated dependency manager/resolver. It is used to build the core client library and download its dependencies from the Maven central repository.

We advise using at least version 3.5.0 (although > 3.0.0 should be functional).

Linux

Maven is commonly available via operating system package managers. For example:

# Debian-based systems (Debian/Ubuntu/Mint etc.)
sudo apt-get install maven

# Redhat-based systems (Fedora/RHEL/CentOS etc.)
sudo yum install maven

Alternatively download and install from the Apache Maven website.

MacOS & Windows

Download and install from the Apache Maven website.

Build the library

  1. Clone this project in the directory of your choice via:

    git clone https://github.com/googleads/google-ads-java.git
    
  2. Navigate to the google-ads-java directory.

    cd google-ads-java
    
  3. Now run the following command to install the snapshot version of the library and examples project.

    mvn clean install
    
  4. The main library artifacts can be found in google-ads/target. The code examples can be found in google-ads-examples/target.

Use the client library via Maven local repository

The artifacts for the client library will now be available to Maven via the local repository. Add a dependency on the SNAPSHOT version that was just built to your pom.xml.

Use the client library to call the API from another project

If you want to use the client library artifacts directly as dependencies (i.e. outside of Maven/Gradle, for instance in the IDE build system) this is possible, but strongly discouraged.

In addition to the JAR from google-ads/target, you will likely also need the JARs for all dependencies.

Run the following command to copy the dependencies to a target directory:

mvn dependency:copy-dependencies -f google-ads/pom.xml

Optionally, specify -DoutputDirectory=/copy/here to copy to a specified directory.