Google Ads API BOM (Bill of Materials)은 종속 항목
버전 관리를 통해 다른 프레임워크에서도 사용되는 Guava 및 GAX
와 같은 라이브러리와의 종속 항목 충돌을 방지합니다. BOM은 Google Ads 클라이언트 라이브러리로 테스트된 이러한 종속 항목의 정확한 버전을 사용하도록 보장합니다.
클라이언트 라이브러리 아티팩트를 사용하는 것이 좋습니다.
Maven 구성
<dependencyManagement>에 BOM을 추가하고 google-ads 파일에서
pom.xml을 선언합니다.
<!-- 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>48.0.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:48.0.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:48.0.0"))
// Add the google-ads dependency, without a version.
implementation("com.google.api-ads:google-ads")
BOM에서 다루는 종속 항목 선언
Google Ads API BOM에는 여러
일반 라이브러리(예: Guava, Protobuf, GAX, gRPC)의 버전 관리가 포함되어 있습니다. 잠재적인 종속 항목 충돌을 방지하려면 BOM에서 다루는 종속 항목을 선언할 때 버전을 지정하지 않아야 합니다. 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
버전을 생략하면 BOM에서 버전을 관리할 수 있으므로 호환되지 않는 종속 항목 버전으로 인해 발생하는 문제를 방지할 수 있습니다. 종속 항목 충돌의 일반적인 지표로는 NoSuchMethodError 또는 ClassNotFoundException이 있으며, 이러한 오류는 BOM 관리 종속 항목에 버전이 지정되지 않도록 함으로써 해결할 수 있는 경우가 많습니다.