Skip to content

Commit

Permalink
feat: Build the extension and the plugin with Java 11 (#66)
Browse files Browse the repository at this point in the history
diff --git a/.idea/kotlinc.xml b/.idea/kotlinc.xml
index fe63bb6..148fdd2 100644
--- a/.idea/kotlinc.xml
+++ b/.idea/kotlinc.xml
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <project version="4">
   <component name="KotlinJpsPluginSettings">
-    <option name="version" value="1.9.23" />
+    <option name="version" value="1.9.24" />
   </component>
 </project>
\ No newline at end of file
diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle
index 801d827..272f92d 100644
--- a/buildSrc/build.gradle
+++ b/buildSrc/build.gradle
@@ -17,7 +17,7 @@ dependencies {

 java {
     toolchain {
-        languageVersion.set(JavaLanguageVersion.of(libs.versions.jvmToolchain.get()))
+        languageVersion.set(JavaLanguageVersion.of(libs.versions.jvmToolchainMin.get()))
     }
 }

diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml
index 0769243..aa68d24 100644
--- a/gradle/libs.versions.toml
+++ b/gradle/libs.versions.toml
@@ -11,17 +11,19 @@ gradlePluginPublish = "1.2.1"
 guava = "33.2.0-jre"
 junit4 = "4.13.2"
 junit5 = "5.10.2"
+jvmToolchainMin = "11"
 jvmToolchain = "17"
 kotlin = "1.9.24"
 kover = "0.8.0"
 robolectric = "4.12.1"
-robolectricAndroidAll = "14-robolectric-10818077"
+robolectricAndroidAll = "13-robolectric-9030017"
 robolectricExtensionGradlePlugin = "0.6.1"
 # Use when bom also added to the dependencies
 sources = "sources"

 [libraries]
 androidGradle = { module = "com.android.tools.build:gradle", version.ref = "androidGradle" }
+androidGradleJdk11 = { module = "com.android.tools.build:gradle", version.require = "7.0.4" }
 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/robolectric-extension-gradle-plugin/build.gradle b/robolectric-extension-gradle-plugin/build.gradle
index c69cfc8..4d21850 100644
--- a/robolectric-extension-gradle-plugin/build.gradle
+++ b/robolectric-extension-gradle-plugin/build.gradle
@@ -17,7 +17,7 @@ buildConfig {
 }

 kotlin {
-    jvmToolchain(libs.versions.jvmToolchain.get().toInteger())
+    jvmToolchain(libs.versions.jvmToolchainMin.get().toInteger())
 }

 detekt {
@@ -33,12 +33,12 @@ dependencies {
     detektPlugins(libs.detektFormatting)
     detektPlugins(libs.detektRulesLibraries)
     compileOnly(gradleApi())
-    compileOnly(libs.androidGradle)
+    compileOnly(libs.androidGradleJdk11)
     testImplementation(gradleTestKit())
     testImplementation(platform(libs.junit5Bom))
     testImplementation(libs.junit5JupiterApi)
     testImplementation(libs.kotlinTestJUnit5)
-    testImplementation(libs.androidGradle)
+    testImplementation(libs.androidGradleJdk11)
     testRuntimeOnly(libs.junit5JupiterEngine)
 }

diff --git a/robolectric-extension-gradle-plugin/src/main/kotlin/tech/apter/robolectric/junit/jupiter/gradle/plugin/RobolectricJUnitJupiterGradlePlugin.kt b/robolectric-extension-gradle-plugin/src/main/kotlin/tech/apter/robolectric/junit/jupiter/gradle/plugin/RobolectricJUnitJupiterGradlePlugin.kt
index 1028f97..1a017e0 100644
--- a/robolectric-extension-gradle-plugin/src/main/kotlin/tech/apter/robolectric/junit/jupiter/gradle/plugin/RobolectricJUnitJupiterGradlePlugin.kt
+++ b/robolectric-extension-gradle-plugin/src/main/kotlin/tech/apter/robolectric/junit/jupiter/gradle/plugin/RobolectricJUnitJupiterGradlePlugin.kt
@@ -52,7 +52,7 @@ class RobolectricJUnitJupiterGradlePlugin : Plugin<Project> {
     }

     private fun Project.enableIncludeAndroidResources() {
-        val androidExtension = extensions.findByName("android") as? CommonExtension<*, *, *, *, *, *>
+        val androidExtension = extensions.findByName("android") as? CommonExtension<*, *, *, *>
         @Suppress("UnstableApiUsage")
         androidExtension?.testOptions?.unitTests?.isIncludeAndroidResources = true
     }
diff --git a/robolectric-extension/build.gradle b/robolectric-extension/build.gradle
index 4f48e93..d5baa57 100644
--- a/robolectric-extension/build.gradle
+++ b/robolectric-extension/build.gradle
@@ -17,7 +17,7 @@ configurations.configureEach { configuration ->
 }

 kotlin {
-    jvmToolchain(libs.versions.jvmToolchain.get().toInteger())
+    jvmToolchain(libs.versions.jvmToolchainMin.get().toInteger())
 }

 robolectricJUnitJupiter {
diff --git a/robolectric-extension/src/test/kotlin/tech/apter/junit/jupiter/robolectric/internal/JUnit5RobolectricSandboxBuilderTest.kt b/robolectric-extension/src/test/kotlin/tech/apter/junit/jupiter/robolectric/internal/JUnit5RobolectricSandboxBuilderTest.kt
index bbf131b..4ef46c6 100644
--- a/robolectric-extension/src/test/kotlin/tech/apter/junit/jupiter/robolectric/internal/JUnit5RobolectricSandboxBuilderTest.kt
+++ b/robolectric-extension/src/test/kotlin/tech/apter/junit/jupiter/robolectric/internal/JUnit5RobolectricSandboxBuilderTest.kt
@@ -22,8 +22,8 @@ class JUnit5RobolectricSandboxBuilderTest {
     fun `Given the same arguments when call build twice then should return two different sandboxes with the same classloader `() {
         // Given
         val instrumentationConfiguration = createInstrumentationConfiguration()
-        val runtimeSdk: Sdk = TestUtil.sdkCollection.getSdk(34)
-        val compileSdk: Sdk = TestUtil.sdkCollection.getSdk(34)
+        val runtimeSdk: Sdk = TestUtil.sdkCollection.getSdk(33)
+        val compileSdk: Sdk = TestUtil.sdkCollection.getSdk(33)
         val resourcesMode: ResourcesMode = ResourcesMode.BINARY
         val sqLiteMode: SQLiteMode.Mode = SQLiteMode.Mode.NATIVE

@@ -45,11 +45,11 @@ class JUnit5RobolectricSandboxBuilderTest {
     fun `Given different arguments when call build twice then should return two different sandboxes with different classloaders`() {
         // Given
         val instrumentationConfiguration1 = createInstrumentationConfiguration()
-        val runtimeSdk1: Sdk = TestUtil.sdkCollection.getSdk(34)
-        val compileSdk1: Sdk = TestUtil.sdkCollection.getSdk(34)
+        val runtimeSdk1: Sdk = TestUtil.sdkCollection.getSdk(33)
+        val compileSdk1: Sdk = TestUtil.sdkCollection.getSdk(33)
         val instrumentationConfiguration2 = createInstrumentationConfiguration()
-        val runtimeSdk2: Sdk = TestUtil.sdkCollection.getSdk(33)
-        val compileSdk2: Sdk = TestUtil.sdkCollection.getSdk(33)
+        val runtimeSdk2: Sdk = TestUtil.sdkCollection.getSdk(32)
+        val compileSdk2: Sdk = TestUtil.sdkCollection.getSdk(32)
         val resourcesMode: ResourcesMode = ResourcesMode.BINARY
         val sqLiteMode: SQLiteMode.Mode = SQLiteMode.Mode.NATIVE

diff --git a/robolectric-extension/src/test/resources/robolectric.properties b/robolectric-extension/src/test/resources/robolectric.properties
index 979b5ee..3525a65 100644
--- a/robolectric-extension/src/test/resources/robolectric.properties
+++ b/robolectric-extension/src/test/resources/robolectric.properties
@@ -1 +1,2 @@
-sdk=34
+sdk=33
+packageName=tech.apter.junit.jupiter.robolectric
  • Loading branch information
warnyul committed May 23, 2024
1 parent 9fdf04a commit 56f70a9
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .idea/kotlinc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion buildSrc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ dependencies {

java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(libs.versions.jvmToolchain.get()))
languageVersion.set(JavaLanguageVersion.of(libs.versions.jvmToolchainMin.get()))
}
}

Expand Down
4 changes: 3 additions & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,19 @@ gradlePluginPublish = "1.2.1"
guava = "33.2.0-jre"
junit4 = "4.13.2"
junit5 = "5.10.2"
jvmToolchainMin = "11"
jvmToolchain = "17"
kotlin = "1.9.24"
kover = "0.8.0"
robolectric = "4.12.1"
robolectricAndroidAll = "14-robolectric-10818077"
robolectricAndroidAll = "13-robolectric-9030017"
robolectricExtensionGradlePlugin = "0.6.1"
# Use when bom also added to the dependencies
sources = "sources"

[libraries]
androidGradle = { module = "com.android.tools.build:gradle", version.ref = "androidGradle" }
androidGradleJdk11 = { module = "com.android.tools.build:gradle", version.require = "7.0.4" }
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" }
Expand Down
6 changes: 3 additions & 3 deletions robolectric-extension-gradle-plugin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ buildConfig {
}

kotlin {
jvmToolchain(libs.versions.jvmToolchain.get().toInteger())
jvmToolchain(libs.versions.jvmToolchainMin.get().toInteger())
}

detekt {
Expand All @@ -33,12 +33,12 @@ dependencies {
detektPlugins(libs.detektFormatting)
detektPlugins(libs.detektRulesLibraries)
compileOnly(gradleApi())
compileOnly(libs.androidGradle)
compileOnly(libs.androidGradleJdk11)
testImplementation(gradleTestKit())
testImplementation(platform(libs.junit5Bom))
testImplementation(libs.junit5JupiterApi)
testImplementation(libs.kotlinTestJUnit5)
testImplementation(libs.androidGradle)
testImplementation(libs.androidGradleJdk11)
testRuntimeOnly(libs.junit5JupiterEngine)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class RobolectricJUnitJupiterGradlePlugin : Plugin<Project> {
}

private fun Project.enableIncludeAndroidResources() {
val androidExtension = extensions.findByName("android") as? CommonExtension<*, *, *, *, *, *>
val androidExtension = extensions.findByName("android") as? CommonExtension<*, *, *, *>
@Suppress("UnstableApiUsage")
androidExtension?.testOptions?.unitTests?.isIncludeAndroidResources = true
}
Expand Down
2 changes: 1 addition & 1 deletion robolectric-extension/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ configurations.configureEach { configuration ->
}

kotlin {
jvmToolchain(libs.versions.jvmToolchain.get().toInteger())
jvmToolchain(libs.versions.jvmToolchainMin.get().toInteger())
}

robolectricJUnitJupiter {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ class JUnit5RobolectricSandboxBuilderTest {
fun `Given the same arguments when call build twice then should return two different sandboxes with the same classloader `() {
// Given
val instrumentationConfiguration = createInstrumentationConfiguration()
val runtimeSdk: Sdk = TestUtil.sdkCollection.getSdk(34)
val compileSdk: Sdk = TestUtil.sdkCollection.getSdk(34)
val runtimeSdk: Sdk = TestUtil.sdkCollection.getSdk(33)
val compileSdk: Sdk = TestUtil.sdkCollection.getSdk(33)
val resourcesMode: ResourcesMode = ResourcesMode.BINARY
val sqLiteMode: SQLiteMode.Mode = SQLiteMode.Mode.NATIVE

Expand All @@ -45,11 +45,11 @@ class JUnit5RobolectricSandboxBuilderTest {
fun `Given different arguments when call build twice then should return two different sandboxes with different classloaders`() {
// Given
val instrumentationConfiguration1 = createInstrumentationConfiguration()
val runtimeSdk1: Sdk = TestUtil.sdkCollection.getSdk(34)
val compileSdk1: Sdk = TestUtil.sdkCollection.getSdk(34)
val runtimeSdk1: Sdk = TestUtil.sdkCollection.getSdk(33)
val compileSdk1: Sdk = TestUtil.sdkCollection.getSdk(33)
val instrumentationConfiguration2 = createInstrumentationConfiguration()
val runtimeSdk2: Sdk = TestUtil.sdkCollection.getSdk(33)
val compileSdk2: Sdk = TestUtil.sdkCollection.getSdk(33)
val runtimeSdk2: Sdk = TestUtil.sdkCollection.getSdk(32)
val compileSdk2: Sdk = TestUtil.sdkCollection.getSdk(32)
val resourcesMode: ResourcesMode = ResourcesMode.BINARY
val sqLiteMode: SQLiteMode.Mode = SQLiteMode.Mode.NATIVE

Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
sdk=34
sdk=33
packageName=tech.apter.junit.jupiter.robolectric

0 comments on commit 56f70a9

Please sign in to comment.