Pour discuter de nos produits et nous faire part de vos commentaires, rejoignez le canal Discord officiel Google Ads sur le serveur de la communauté Google Advertising and Measurement.
Compiler la bibliothèque cliente pour Java à partir de la source
Restez organisé à l'aide des collections
Enregistrez et classez les contenus selon vos préférences.
Nous vous recommandons d'utiliser la bibliothèque cliente via Maven. Nous fournissons également des distributions binaires sur notre page de versions et via le référentiel central Maven (consultez notre guide de démarrage rapide pour en savoir plus). Toutefois, vous pouvez créer la bibliothèque vous-même en suivant le processus de compilation décrit ci-dessous.
La bibliothèque cliente est conçue avec Gradle. Les dépendances sont téléchargées depuis le dépôt Maven Central.
Installer le kit de développement Java
JDK 1.8 ou version ultérieure est requis pour compiler la bibliothèque. Pour les besoins de ce guide, nous partons du principe que Java est installé sur votre machine.
Compiler avec Gradle
Nous vous recommandons d'utiliser le wrapper Gradle inclus. Pour consulter la version actuelle, voir gradle/wrapper/gradle-wrapper.properties. Vous n'avez pas besoin d'installer Gradle séparément.
Compiler la bibliothèque
Clonez ce projet dans le répertoire de votre choix. Le suffixe .git dans l'URL est facultatif.
Exécutez la commande suivante pour créer la version instantanée de la bibliothèque et du projet d'exemples.
./gradlewbuild
Exportez la bibliothèque cliente vers un dépôt Maven local.
./gradlewpublishToMavenLocal
Utiliser la bibliothèque cliente dans un dépôt Maven local
Une fois la compilation et l'exportation réussies, les artefacts de la bibliothèque cliente sont disponibles pour Maven/Gradle à partir du dépôt local (généralement ~/.m2/repository/com/google/api-ads/google-ads/). Ajoutez une dépendance à la version SNAPSHOT qui vient d'être compilée à tous les fichiers de compilation de projet ultérieurs. La version est définie dans gradle.properties.
Sauf indication contraire, le contenu de cette page est régi par une licence Creative Commons Attribution 4.0, et les échantillons de code sont régis par une licence Apache 2.0. Pour en savoir plus, consultez les Règles du site Google Developers. Java est une marque déposée d'Oracle et/ou de ses sociétés affiliées.
Dernière mise à jour le 2025/08/26 (UTC).
[null,null,["Dernière mise à jour le 2025/08/26 (UTC)."],[[["\u003cp\u003eThe Google Ads client library is best used through Maven, with binary distributions also available.\u003c/p\u003e\n"],["\u003cp\u003eBuilding the library requires JDK 1.8 or later and is accomplished using the included Gradle wrapper.\u003c/p\u003e\n"],["\u003cp\u003eAfter building, the library can be exported to a local Maven repository for use in other projects.\u003c/p\u003e\n"],["\u003cp\u003eThe library is built from the google-ads-java Github repository and can be used in Maven or Gradle projects.\u003c/p\u003e\n"]]],[],null,["# Building the client library for Java from source\n\nWe recommend using the client library through Maven. We also provide binary\ndistributions on our releases page and through the [Maven central\nrepository](//search.maven.org/artifact/com.google.api-ads/google-ads)\n(see our [quick start](/google-ads/api/docs/client-libs/java/quick-start) guide for details). However, you can build\nthe library yourself using the following build process described.\n\nThe client library is built with Gradle. Dependencies are downloaded from the\nMaven Central repository.\n| **Note:** If you build the library from source, ensure that you enable annotation processing in your IDE.\n\nInstall Java development kit\n----------------------------\n\nJDK 1.8 or later is required to build the library. We'll assume that Java is\ninstalled on your machine for the purposes of this guide.\n\nBuild with Gradle\n-----------------\n\nWe recommend using the included Gradle wrapper. See\n[`gradle/wrapper/gradle-wrapper.properties`](https://github.com/googleads/google-ads-java/blob/HEAD/gradle.properties)\nfor the current version. You do not need a separate Gradle installation.\n\n### Build the library\n\n1. Clone this project in the directory of your choice. The `.git` suffix in the\n URL is optional.\n\n git clone https://github.com/googleads/google-ads-java.git\n\n2. Navigate to the `google-ads-java` directory.\n\n cd google-ads-java\n\n3. Run the following command to build the snapshot version of the library\n and examples project.\n\n ./gradlew build\n\n | **Note:** On Windows, use `gradlew` instead of `./gradlew`.\n4. Export the client library to a local Maven repository.\n\n ./gradlew publishToMavenLocal\n\n | **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.\n\nUse the client library in a local Maven repository\n--------------------------------------------------\n\nAfter a successful build and export, the artifacts for the client library are\navailable to Maven/Gradle from the local repository (typically\n`~/.m2/repository/com/google/api-ads/google-ads/`). Add a dependency on the\nSNAPSHOT version that was just built to any subsequent project build files. The\nversion is defined in\n[gradle.properties](https://github.com/googleads/google-ads-java/blob/main/gradle.properties)."]]