diff --git a/.idea/.gitignore b/.idea/.gitignore
index 8b6e44d..71d8ab8 100644
--- a/.idea/.gitignore
+++ b/.idea/.gitignore
@@ -7,3 +7,4 @@
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml
+/other.xml
diff --git a/.idea/gradle.xml b/.idea/gradle.xml
index b91666f..33f7bc8 100644
--- a/.idea/gradle.xml
+++ b/.idea/gradle.xml
@@ -24,7 +24,6 @@
-
@@ -33,4 +32,4 @@
-
+
\ No newline at end of file
diff --git a/build.gradle b/build.gradle
index d8fa90a..e95dee6 100644
--- a/build.gradle
+++ b/build.gradle
@@ -17,7 +17,7 @@ subprojects {
dependencies {
kover(project(':integration-tests:agp-groovy-dsl'))
- kover(project(':integration-tests:agp-kotlin-dsl'))
+ // kover(project(':integration-tests:agp-kotlin-dsl'))
kover(project(':robolectric-extension'))
kover(project(':robolectric-extension-gradle-plugin'))
}
diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle
index 272f92d..4693865 100644
--- a/buildSrc/build.gradle
+++ b/buildSrc/build.gradle
@@ -12,7 +12,8 @@ dependencies {
compileOnly(gradleApi())
compileOnly(localGroovy())
implementation(libs.guava)
- implementation(libs.androidGradle)
+ implementation(libs.androidGradleApi)
+ implementation(libs.androidToolsCommon)
}
java {
@@ -22,18 +23,33 @@ java {
}
task downloadAarDepsPlugin {
- final from = "https://raw.githubusercontent.com/robolectric/robolectric/robolectric-${libs.versions.robolectric.get()}/buildSrc/src/main/groovy/org/robolectric/gradle/AarDepsPlugin.java"
+ final baseUrl = "https://raw.githubusercontent.com/robolectric/robolectric/robolectric-${libs.versions.robolectric.get()}/"
+ final from = [
+ "${baseUrl}buildSrc/src/main/groovy/org/robolectric/gradle/AarDepsPlugin.java",
+ "${baseUrl}buildSrc/src/main/groovy/org/robolectric/gradle/agp/ExtractAarTransform.java",
+ "${baseUrl}buildSrc/src/main/groovy/org/robolectric/gradle/agp/GenericTransformParameters.java",
+
+ ]
final groovySourceSet = sourceSets.named('main').get().allSource.sourceDirectories.find { it.name == 'groovy' } as File
- final to = new File(groovySourceSet, '/org/robolectric/gradle/AarDepsPlugin.java')
+ final to = [
+ new File(groovySourceSet, '/org/robolectric/gradle/AarDepsPlugin.java'),
+ new File(groovySourceSet, '/org/robolectric/gradle/agp/ExtractAarTransform.java'),
+ new File(groovySourceSet, '/org/robolectric/gradle/agp/GenericTransformParameters.java'),
+ ]
+
inputs.property("from", from)
- outputs.file(to)
+ outputs.files(to)
doLast {
- try {
- new URL(from).withInputStream { i -> to.withOutputStream { it << i } }
- } catch (IOException e) {
- logger.debug("Error during downloading AarDepsPlugin. Keep the stored version.\n$e")
+ from.indices.forEach { i ->
+ final url = from[i]
+ final targetFile = to[i]
+ try {
+ new URL(url).withInputStream { inputStream -> targetFile.withOutputStream { it << inputStream } }
+ } catch (IOException e) {
+ logger.debug("Error during downloading ${url.name}. Keep the stored version.\n$e")
+ }
}
}
}
diff --git a/buildSrc/src/main/groovy/org/robolectric/gradle/AarDepsPlugin.java b/buildSrc/src/main/groovy/org/robolectric/gradle/AarDepsPlugin.java
index 9322d6c..e5d1934 100644
--- a/buildSrc/src/main/groovy/org/robolectric/gradle/AarDepsPlugin.java
+++ b/buildSrc/src/main/groovy/org/robolectric/gradle/AarDepsPlugin.java
@@ -2,12 +2,12 @@
import static org.gradle.api.artifacts.type.ArtifactTypeDefinition.ARTIFACT_TYPE_ATTRIBUTE;
-import com.android.build.gradle.internal.dependency.ExtractAarTransform;
-import com.google.common.base.Joiner;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
+import java.util.Objects;
import java.util.concurrent.atomic.AtomicReference;
+import java.util.stream.Collectors;
import javax.inject.Inject;
import org.gradle.api.Action;
import org.gradle.api.Plugin;
@@ -17,6 +17,7 @@
import org.gradle.api.file.FileCollection;
import org.gradle.api.tasks.compile.JavaCompile;
import org.jetbrains.annotations.NotNull;
+import org.robolectric.gradle.agp.ExtractAarTransform;
/** Resolve aar dependencies into jars for non-Android projects. */
public class AarDepsPlugin implements Plugin {
@@ -63,7 +64,11 @@ public void execute(@NotNull Task task) {
List aarFiles = AarDepsPlugin.this.findAarFiles(t.getClasspath());
if (!aarFiles.isEmpty()) {
throw new IllegalStateException(
- "AARs on classpath: " + Joiner.on("\n ").join(aarFiles));
+ "AARs on classpath: "
+ + aarFiles.stream()
+ .filter(Objects::nonNull)
+ .map(File::toString)
+ .collect(Collectors.joining("\n ")));
}
}
}));
diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml
index 4de6cda..b187f68 100644
--- a/gradle/libs.versions.toml
+++ b/gradle/libs.versions.toml
@@ -1,8 +1,9 @@
[versions]
androidBuildTools = "34.0.0"
+androidToolsCommon = "31.5.1"
androidCompileSdk = "34"
androidGradle = "8.5.1"
-androidMinimumSdk = "14"
+androidMinimumSdk = "19"
androidxTestExtJunit = "1.2.1"
buildConfig = "5.4.0"
detekt = "1.23.6"
@@ -21,8 +22,9 @@ robolectricExtensionGradlePlugin = "0.7.0"
sources = "sources"
[libraries]
-androidGradle = { module = "com.android.tools.build:gradle", version.ref = "androidGradle" }
+androidGradleApi = { module = "com.android.tools.build:gradle-api", version.ref = "androidGradle" }
androidGradleJava11 = { module = "com.android.tools.build:gradle", version = { require = "[7.0.0,8.0.0[", prefer = "7.4.2" } }
+androidToolsCommon = { module = "com.android.tools:common", version.ref = "androidToolsCommon" }
androidxTestExtJunit = { module = "androidx.test.ext:junit", version.ref = "androidxTestExtJunit" }
detektFormatting = { module = "io.gitlab.arturbosch.detekt:detekt-formatting", version.ref = "detekt" }
detektRulesLibraries = { module = "io.gitlab.arturbosch.detekt:detekt-rules-libraries", version.ref = "detekt" }
diff --git a/integration-tests/agp-groovy-dsl/build.gradle b/integration-tests/agp-groovy-dsl/build.gradle
index 5ef4dec..468ce61 100644
--- a/integration-tests/agp-groovy-dsl/build.gradle
+++ b/integration-tests/agp-groovy-dsl/build.gradle
@@ -1,5 +1,5 @@
plugins {
- id('com.android.library')
+ alias(libs.plugins.androidLibrary)
alias(libs.plugins.kotlinAndroid)
alias(libs.plugins.kotlinxKover)
alias(libs.plugins.detekt)
diff --git a/integration-tests/agp-kotlin-dsl/build.gradle.kts b/integration-tests/agp-kotlin-dsl/build.gradle.kts
index eb480cb..64c280b 100644
--- a/integration-tests/agp-kotlin-dsl/build.gradle.kts
+++ b/integration-tests/agp-kotlin-dsl/build.gradle.kts
@@ -1,5 +1,5 @@
plugins {
- id("com.android.library")
+ alias(libs.plugins.androidLibrary)
alias(libs.plugins.kotlinAndroid)
alias(libs.plugins.kotlinxKover)
alias(libs.plugins.detekt)
diff --git a/robolectric-extension/src/test/kotlin/tech/apter/junit/jupiter/robolectric/RobolectricExtensionCustomAndroidSdkSelfTest.kt b/robolectric-extension/src/test/kotlin/tech/apter/junit/jupiter/robolectric/RobolectricExtensionCustomAndroidSdkSelfTest.kt
index 656fbcc..e9f188e 100644
--- a/robolectric-extension/src/test/kotlin/tech/apter/junit/jupiter/robolectric/RobolectricExtensionCustomAndroidSdkSelfTest.kt
+++ b/robolectric-extension/src/test/kotlin/tech/apter/junit/jupiter/robolectric/RobolectricExtensionCustomAndroidSdkSelfTest.kt
@@ -12,21 +12,21 @@ import kotlin.test.assertEquals
import kotlin.test.assertSame
@ExtendWith(RobolectricExtension::class)
-@Config(sdk = [Build.VERSION_CODES.KITKAT])
+@Config(sdk = [Build.VERSION_CODES.LOLLIPOP])
@Execution(ExecutionMode.SAME_THREAD)
class RobolectricExtensionCustomAndroidSdkSelfTest {
@Test
fun `Given a test class configured with custom runtime SDK then SDK_INT should be the version set up`() {
- assertEquals(Build.VERSION_CODES.KITKAT, Build.VERSION.SDK_INT)
- assertEquals("4.4", Build.VERSION.RELEASE)
+ assertEquals(Build.VERSION_CODES.LOLLIPOP, Build.VERSION.SDK_INT)
+ assertEquals("5.0.2", Build.VERSION.RELEASE)
}
@Nested
inner class NestedSelfTest {
@Test
fun `Given a test class configured with custom runtime SDK when call test from a nested test class then SDK_INT should be the version set up`() {
- assertEquals(Build.VERSION_CODES.KITKAT, Build.VERSION.SDK_INT)
- assertEquals("4.4", Build.VERSION.RELEASE)
+ assertEquals(Build.VERSION_CODES.LOLLIPOP, Build.VERSION.SDK_INT)
+ assertEquals("5.0.2", Build.VERSION.RELEASE)
}
@Test
@@ -38,8 +38,8 @@ class RobolectricExtensionCustomAndroidSdkSelfTest {
inner class TwoLevelNestedSelfTest {
@Test
fun `Given a test class configured with custom runtime SDK when call test from a nested test class then SDK_INT should be the version set up`() {
- assertEquals(Build.VERSION_CODES.KITKAT, Build.VERSION.SDK_INT)
- assertEquals("4.4", Build.VERSION.RELEASE)
+ assertEquals(Build.VERSION_CODES.LOLLIPOP, Build.VERSION.SDK_INT)
+ assertEquals("5.0.2", Build.VERSION.RELEASE)
}
@Test
diff --git a/robolectric-extension/src/test/kotlin/tech/apter/junit/jupiter/robolectric/RobolectricExtensionSelfTest.kt b/robolectric-extension/src/test/kotlin/tech/apter/junit/jupiter/robolectric/RobolectricExtensionSelfTest.kt
index 9809d7c..411a63d 100644
--- a/robolectric-extension/src/test/kotlin/tech/apter/junit/jupiter/robolectric/RobolectricExtensionSelfTest.kt
+++ b/robolectric-extension/src/test/kotlin/tech/apter/junit/jupiter/robolectric/RobolectricExtensionSelfTest.kt
@@ -37,9 +37,6 @@ class RobolectricExtensionSelfTest {
val application = assertDoesNotThrow { getApplicationContext() }
assertIs(application, "application")
assertTrue("onCreateCalled") { application.onCreateWasCalled }
- if (RuntimeEnvironment.useLegacyResources()) {
- assertNotNull(RuntimeEnvironment.getAppResourceTable(), "Application resource loader")
- }
}
@Test
diff --git a/settings.gradle b/settings.gradle
index 656e9ce..627a6ce 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -20,7 +20,7 @@ dependencyResolutionManagement {
rootProject.name = 'junit5-robolectric-extension'
include('integration-tests:agp-groovy-dsl')
-include('integration-tests:agp-kotlin-dsl')
+//include('integration-tests:agp-kotlin-dsl')
include('robolectric-extension')
include('robolectric-extension-gradle-plugin')