Skip to content

Commit

Permalink
Update dependency-on-stubs build.gradle to use AGP
Browse files Browse the repository at this point in the history
There were several issues with the dependency-on-stubs build.gradle:

1) The original intent of this test is to ensure that the runtime classpath
does not contain the android-all jar, but the android-all was explicitly being
used in the runtime classpath.

2) The android-29 stubs jar was hardcoded in the dependency-on-stubs
build.gradle. It is not guaranteed that android-29 will be installed.

Update the dependency-on-stubs to use AGP, and remove the runtime dependency on
android-all.

Fixes #8962

PiperOrigin-RevId: 622020695
  • Loading branch information
hoisie authored and Copybara-Service committed Apr 5, 2024
1 parent b7244e3 commit 479f1fc
Showing 1 changed file with 21 additions and 9 deletions.
30 changes: 21 additions & 9 deletions integration_tests/dependency-on-stubs/build.gradle
Original file line number Diff line number Diff line change
@@ -1,18 +1,30 @@
import org.robolectric.gradle.RoboJavaModulePlugin
import org.robolectric.gradle.AndroidProjectConfigPlugin

apply plugin: RoboJavaModulePlugin
apply plugin: 'com.android.library'
apply plugin: AndroidProjectConfigPlugin

// test with a project that depends on the stubs jar, not org.robolectric:android-all

dependencies {
api project(":robolectric")
api libs.junit4
android {
compileSdk 33
namespace 'org.robolectric'

defaultConfig {
minSdk 19
targetSdk 33
}

testImplementation files("${System.getenv("ANDROID_HOME")}/platforms/android-29/android.jar")
compileOptions {
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
}

testCompileOnly AndroidSdk.MAX_SDK.coordinates // compile against latest Android SDK
testRuntimeOnly AndroidSdk.MAX_SDK.coordinates
testOptions.unitTests.includeAndroidResources true
}

dependencies {
testImplementation project(":robolectric")
testImplementation libs.junit4
testImplementation libs.truth
testImplementation libs.mockito
testImplementation libs.hamcrest.junit
}

0 comments on commit 479f1fc

Please sign in to comment.