diff --git a/README.md b/README.md index 675a8da1f..ae1fd336b 100644 --- a/README.md +++ b/README.md @@ -229,6 +229,7 @@ composeVersion | The version for the Jetpack Compose dependencies to use for Esp sourceCompatibility | The minimum version of JVM the project sources are compatible with. The default value is `VERSION_1_8` | VERSION_12 targetCompatibility | The target version of JVM the project sources are compatible with. The default value is `VERSION_1_8` | VERSION_12 jvmTarget | Target version of the generated JVM bytecode as a string. The default value is `1_8` | `1_10` +annotationVersion | The target version of `androidx.annotation:annotation` pakage. By default the version from the app [build.gradle.kts](https://github.com/appium/appium-espresso-driver/blob/master/espresso-server/app/build.gradle.kts) is used | '1.2.0' ### additionalAppDependencies diff --git a/espresso-server/app/build.gradle.kts b/espresso-server/app/build.gradle.kts index 437052b6b..85ef43a1e 100644 --- a/espresso-server/app/build.gradle.kts +++ b/espresso-server/app/build.gradle.kts @@ -86,6 +86,7 @@ android { val kotlinVersion = rootProject.extra["appiumKotlin"] val composeVersion = getStringProperty("appiumComposeVersion", Version.compose) +val annotationVersion = getStringProperty("appiumAnnotationVersion", Version.annotation) dependencies { implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.jar")))) @@ -95,7 +96,7 @@ dependencies { testImplementation("org.powermock:powermock-classloading-xstream:${Version.mocklib}") testImplementation("org.powermock:powermock-module-junit4-rule:${Version.mocklib}") testImplementation("org.powermock:powermock-module-junit4:${Version.mocklib}") - testImplementation("androidx.annotation:annotation:${Version.annotation}") + testImplementation("androidx.annotation:annotation:${annotationVersion}") testImplementation("androidx.test.espresso:espresso-contrib:${Version.espresso}") testImplementation("androidx.test.espresso:espresso-core:${Version.espresso}") testImplementation("androidx.test.espresso:espresso-web:${Version.espresso}") @@ -114,7 +115,7 @@ dependencies { testImplementation("androidx.compose.ui:ui-test:${composeVersion}") testImplementation("androidx.compose.ui:ui-test-junit4:${composeVersion}") - androidTestImplementation("androidx.annotation:annotation:${Version.annotation}") + androidTestImplementation("androidx.annotation:annotation:${annotationVersion}") androidTestImplementation("androidx.test.espresso:espresso-contrib:${Version.espresso}") { // Exclude transitive dependencies to limit conflicts with AndroidX libraries from AUT. // Link to PR with fix and discussion https://github.com/appium/appium-espresso-driver/pull/596 @@ -137,6 +138,15 @@ dependencies { // additionalAndroidTestDependencies placeholder (don't change or delete this line) } +configurations.all { + resolutionStrategy.eachDependency { + // To avoid "androidx.annotation:annotation" version conflict. + if (requested.group == "androidx.annotation" && !requested.name.contains("annotation")) { + useVersion(annotationVersion) + } + } +} + tasks.withType { systemProperty("skipespressoserver", "true") } diff --git a/lib/server-builder.js b/lib/server-builder.js index c527b48ee..b49cdf024 100644 --- a/lib/server-builder.js +++ b/lib/server-builder.js @@ -22,7 +22,8 @@ const VERSION_KEYS = [ 'sourceCompatibility', 'targetCompatibility', 'jvmTarget', - 'composeVersion' + 'composeVersion', + 'annotationVersion' ]; function buildServerSigningConfig (args) {