We recommend using the client library through Maven. We also provide binary distributions on our releases page and through 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 through 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
Clone this project in the directory of your choice:
git clone https://github.com/googleads/google-ads-java.git
Navigate to the
google-ads-java
directory.cd google-ads-java
Now run the following command to install the snapshot version of the library and examples project.
mvn clean install
The main library artifacts can be found in
google-ads/target
. The code examples can be found ingoogle-ads-examples/target
.
Use the client library in the Maven local repository
The artifacts for the client library will now be available to Maven through 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
You can use the client library artifacts directly as dependencies (in other words, outside of Maven/Gradle, for instance in the IDE build system), but this is 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.