Google Ads API का बिल ऑफ़ मटीरियल (बीओएम), डिपेंडेंसी के वर्शन मैनेज करता है. इससे Guava और GAX जैसी लाइब्रेरी के साथ डिपेंडेंसी के टकराव से बचा जा सकता है. इन लाइब्रेरी का इस्तेमाल अन्य फ़्रेमवर्क भी करते हैं. बीओएम यह पक्का करता है कि आपने इन डिपेंडेंसी के उन वर्शन का इस्तेमाल किया हो जिनकी जांच Google Ads क्लाइंट लाइब्रेरी के साथ की गई है.
क्लाइंट लाइब्रेरी के आर्टफ़ैक्ट इस्तेमाल करने का यह सबसे सही तरीका है.
Maven कॉन्फ़िगरेशन
<dependencyManagement> में बीओएम जोड़ें और अपनी pom.xml फ़ाइल में google-ads का एलान करें:
<!-- Import the Bill of Materials (BOM) to ensure you're using compatible
versions of all google-ads libraries. -->
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.google.api-ads</groupId>
<artifactId>google-ads-bom</artifactId>
<version>46.1.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<!-- Add the google-ads dependency, without a version. The version is
managed by the BOM. -->
<dependency>
<groupId>com.google.api-ads</groupId>
<artifactId>google-ads</artifactId>
</dependency>
Gradle कॉन्फ़िगरेशन
Gradle 5.0 और इसके बाद के वर्शन में, platform() का इस्तेमाल करके, BOM को नेटिव तरीके से इंपोर्ट किया जा सकता है.
Groovy DSL (build.gradle) में:
// Import the Bill of Materials (BOM).
implementation platform('com.google.api-ads:google-ads-bom:46.1.0')
// Add the google-ads dependency, without a version.
implementation 'com.google.api-ads:google-ads'
Kotlin DSL (build.gradle.kts) में:
// Import the Bill of Materials (BOM).
implementation(platform("com.google.api-ads:google-ads-bom:46.1.0"))
// Add the google-ads dependency, without a version.
implementation("com.google.api-ads:google-ads")
बीओएम में शामिल डिपेंडेंसी के बारे में जानकारी देना
Google Ads API बीओएम में, कई सामान्य लाइब्रेरी के वर्शन मैनेज करने की सुविधा शामिल है. जैसे, Guava, Protobuf, GAX, और gRPC. डिपेंडेंसी से जुड़ी संभावित समस्याओं से बचने के लिए, बीओएम में शामिल डिपेंडेंसी के वर्शन के बारे में नहीं बताना चाहिए. BOM, इन लाइब्रेरी के वर्शन को अपने-आप मैनेज करता है. इससे यह पक्का होता है कि ये लाइब्रेरी एक-दूसरे के साथ काम करती हैं.
उदाहरण के लिए, Maven में Guava डिपेंडेंसी का एलान करने के लिए, इसका इस्तेमाल करें:
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<!-- NO VERSION SPECIFIED -->
</dependency>
Gradle Groovy DSL (build.gradle) में:
implementation 'com.google.guava:guava' // NO VERSION SPECIFIED
Gradle Kotlin DSL (build.gradle.kts) में:
implementation("com.google.guava:guava") // NO VERSION SPECIFIED
वर्शन को शामिल न करने पर, बीओएम इसे मैनेज करता है. इससे, डिपेंडेंसी के वर्शन के साथ काम न करने की वजह से होने वाली समस्याओं से बचा जा सकता है. डिपेंडेंसी के टकराव के सामान्य इंडिकेटर में NoSuchMethodError या ClassNotFoundException शामिल हैं. इन्हें अक्सर इस बात की पुष्टि करके ठीक किया जा सकता है कि बीओएम मैनेज की गई सभी डिपेंडेंसी में कोई वर्शन तय नहीं किया गया है.