diff --git a/dokka-integration-tests/gradle/src/main/kotlin/org/jetbrains/dokka/it/gradle/TestedVersions.kt b/dokka-integration-tests/gradle/src/main/kotlin/org/jetbrains/dokka/it/gradle/TestedVersions.kt index 2618efbdb91..b2f153709db 100644 --- a/dokka-integration-tests/gradle/src/main/kotlin/org/jetbrains/dokka/it/gradle/TestedVersions.kt +++ b/dokka-integration-tests/gradle/src/main/kotlin/org/jetbrains/dokka/it/gradle/TestedVersions.kt @@ -14,7 +14,7 @@ open class AllSupportedTestedVersionsArgumentsProvider : TestedVersionsArguments object TestedVersions { - val LATEST = BuildVersions("8.5", "2.0.0-Beta4") + val LATEST = BuildVersions("8.6", "2.0.0-Beta4") /** * All supported Gradle/Kotlin versions, including [LATEST] diff --git a/dokka-runners/runner-gradle-plugin-classic/src/test/kotlin/org/jetbrains/dokka/gradle/AndroidAutoConfigurationTest.kt b/dokka-runners/runner-gradle-plugin-classic/src/test/kotlin/org/jetbrains/dokka/gradle/AndroidAutoConfigurationTest.kt index 3cedf563bd2..c61aefbf628 100644 --- a/dokka-runners/runner-gradle-plugin-classic/src/test/kotlin/org/jetbrains/dokka/gradle/AndroidAutoConfigurationTest.kt +++ b/dokka-runners/runner-gradle-plugin-classic/src/test/kotlin/org/jetbrains/dokka/gradle/AndroidAutoConfigurationTest.kt @@ -10,13 +10,13 @@ import org.gradle.api.internal.project.ProjectInternal import org.gradle.kotlin.dsl.configure import org.gradle.kotlin.dsl.withType import org.gradle.testfixtures.ProjectBuilder +import org.jetbrains.dokka.gradle.utils.isAgpRunnable import kotlin.test.* class AndroidAutoConfigurationTest { - // Lazy because it throws an error if an Android test is run under Java 8 - private val project by lazy { - ProjectBuilder.builder().build().also { project -> + private val project = ProjectBuilder.builder().build().also { project -> + if (isAgpRunnable()) { project.plugins.apply("com.android.library") project.plugins.apply("org.jetbrains.kotlin.android") project.plugins.apply("org.jetbrains.dokka") @@ -27,15 +27,17 @@ class AndroidAutoConfigurationTest { } @Test - @Ignore("Current version of AGP requiers Java 11. TODO: if expected, disable this test for Java 8") fun `at least one dokka task created`() { + if (!isAgpRunnable()) return + val dokkaTasks = project.tasks.withType().toList() assertTrue(dokkaTasks.isNotEmpty(), "Expected at least one dokka task") } @Test - @Ignore("Current version of AGP requiers Java 11. TODO: if expected, disable this test for Java 8") fun `all default source sets are present in dokka`() { + if (!isAgpRunnable()) return + val dokkaTasks = project.tasks.withType().toList() dokkaTasks.forEach { task -> val sourceSets = task.dokkaSourceSets.toList() @@ -54,8 +56,8 @@ class AndroidAutoConfigurationTest { @Test fun `test source sets are suppressed`() { val dokkaTasks = project.tasks.withType().toList() - val projectInternal = (project as ProjectInternal) - projectInternal.evaluate() + project as ProjectInternal + project.evaluate() dokkaTasks.flatMap { it.dokkaSourceSets }.forEach { sourceSet -> if ("test" in sourceSet.name.toLowerCase()) { assertTrue( @@ -75,8 +77,8 @@ class AndroidAutoConfigurationTest { @Test fun `source sets have non-empty classpath`() { val dokkaTasks = project.tasks.withType().toList() - val projectInternal = (project as ProjectInternal) - projectInternal.evaluate() + project as ProjectInternal + project.evaluate() dokkaTasks.flatMap { it.dokkaSourceSets } .filterNot { it.name == "androidTestRelease" && it.suppress.get() } // androidTestRelease has empty classpath, but it makes no sense for suppressed source set diff --git a/dokka-runners/runner-gradle-plugin-classic/src/test/kotlin/org/jetbrains/dokka/gradle/GradleDokkaSourceSetBuilderTest.kt b/dokka-runners/runner-gradle-plugin-classic/src/test/kotlin/org/jetbrains/dokka/gradle/GradleDokkaSourceSetBuilderTest.kt index fd9edd86604..1362d56d66e 100644 --- a/dokka-runners/runner-gradle-plugin-classic/src/test/kotlin/org/jetbrains/dokka/gradle/GradleDokkaSourceSetBuilderTest.kt +++ b/dokka-runners/runner-gradle-plugin-classic/src/test/kotlin/org/jetbrains/dokka/gradle/GradleDokkaSourceSetBuilderTest.kt @@ -9,6 +9,7 @@ import org.gradle.api.Project import org.gradle.kotlin.dsl.closureOf import org.gradle.testfixtures.ProjectBuilder import org.jetbrains.dokka.* +import org.jetbrains.dokka.gradle.utils.isAgpRunnable import org.jetbrains.kotlin.gradle.plugin.sources.DefaultKotlinSourceSet import java.net.URI import kotlin.test.* @@ -397,8 +398,9 @@ class GradleDokkaSourceSetBuilderTest { @Test - @Ignore("Current version of AGP requiers Java 11. TODO: if expected, disable this test for Java 8") fun noAndroidSdkLink() { + if (!isAgpRunnable()) return + val sourceSet = GradleDokkaSourceSetBuilder("", project) assertFalse(sourceSet.noAndroidSdkLink.get(), "Expected 'noAndroidSdkLink' to be set to false by default") diff --git a/dokka-runners/runner-gradle-plugin-classic/src/test/kotlin/org/jetbrains/dokka/gradle/utils/AgpUtils.kt b/dokka-runners/runner-gradle-plugin-classic/src/test/kotlin/org/jetbrains/dokka/gradle/utils/AgpUtils.kt new file mode 100644 index 00000000000..5cdb66e359e --- /dev/null +++ b/dokka-runners/runner-gradle-plugin-classic/src/test/kotlin/org/jetbrains/dokka/gradle/utils/AgpUtils.kt @@ -0,0 +1,18 @@ +/* + * Copyright 2014-2024 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + */ + +package org.jetbrains.dokka.gradle.utils + +/** + * AGP 7+ is compiled with Java 8, but requires Java 11+ to run: + * + * > EvalIssueException: Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8. + */ +fun isAgpRunnable(): Boolean { + val javaVersion = when (val specVersion = System.getProperty("java.specification.version")) { + "1.8" -> 8 + else -> specVersion.toInt() + } + return javaVersion >= 11 +}