Google Ads API BOM (Bill of Materials)은 종속 항목 버전을 관리하여 다른 프레임워크에서도 사용하는 Guava 및 GAX와 같은 라이브러리와의 종속 항목 충돌을 방지합니다. BOM을 사용하면 Google Ads 클라이언트 라이브러리로 테스트된 정확한 버전의 종속 항목을 사용할 수 있습니다.
이는 클라이언트 라이브러리 아티팩트를 사용하는 권장 방법입니다.
Maven 구성
BOM을 <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>48.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:48.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:48.1.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 관리 종속 항목에 버전이 지정되지 않도록 하여 해결할 수 있습니다.