Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix test runtime Java versions (#2918)
Fixes #2917 Co-authored-by: Goooler <wangzongler@gmail.com>
- Loading branch information
Showing
8 changed files
with
132 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
build-logic/src/main/kotlin/org/jetbrains/DokkaBuildProperties.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package org.jetbrains | ||
|
||
import org.gradle.api.provider.Provider | ||
import org.gradle.api.provider.ProviderFactory | ||
import org.gradle.jvm.toolchain.JavaLanguageVersion | ||
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion | ||
import javax.inject.Inject | ||
|
||
/** | ||
* Common build properties used to build Dokka subprojects. | ||
* | ||
* This is an extension created by the [org.jetbrains.conventions.Base_gradle] convention plugin. | ||
* | ||
* Default values are set in the root `gradle.properties`, and can be overridden via | ||
* [CLI args, system properties, and environment variables](https://docs.gradle.org/current/userguide/build_environment.html#sec:project_properties) | ||
*/ | ||
abstract class DokkaBuildProperties @Inject constructor( | ||
private val providers: ProviderFactory, | ||
) { | ||
|
||
/** | ||
* The main version of Java that should be used to build Dokka source code. | ||
* | ||
* Updating the Java target is a breaking change. | ||
*/ | ||
val mainJavaVersion: Provider<JavaLanguageVersion> = | ||
dokkaProperty("javaToolchain.mainCompiler", JavaLanguageVersion::of) | ||
|
||
/** | ||
* The version of Java that should be used to run Dokka tests. | ||
* | ||
* This value is set in CI/CD environments to make sure that Dokka still works with different | ||
* versions of Java. | ||
*/ | ||
val testJavaLauncherVersion: Provider<JavaLanguageVersion> = | ||
dokkaProperty("javaToolchain.testLauncher", JavaLanguageVersion::of) | ||
.orElse(mainJavaVersion) | ||
|
||
/** | ||
* The Kotlin language level that Dokka artifacts are compiled to support. | ||
* | ||
* Updating the language level is a breaking change. | ||
*/ | ||
val kotlinLanguageLevel: Provider<KotlinVersion> = | ||
dokkaProperty("kotlinLanguageLevel", KotlinVersion::fromVersion) | ||
|
||
|
||
private fun <T : Any> dokkaProperty(name: String, convert: (String) -> T) = | ||
providers.gradleProperty("org.jetbrains.dokka.$name").map(convert) | ||
|
||
companion object { | ||
const val EXTENSION_NAME = "dokkaBuild" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 10 additions & 1 deletion
11
build-logic/src/main/kotlin/org/jetbrains/conventions/base.gradle.kts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
build-logic/src/main/kotlin/org/jetbrains/internal/gradleKotlinDslAccessors.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
@file:Suppress("PackageDirectoryMismatch") | ||
|
||
package org.gradle.kotlin.dsl // for convenience use a default package for gradle.kts scripts | ||
|
||
import org.gradle.api.Project | ||
import org.jetbrains.DokkaBuildProperties | ||
|
||
/* | ||
* Utility functions for accessing Gradle extensions that are created by convention plugins. | ||
* | ||
* (Gradle can't generate the nice DSL accessors for the project that defines them) | ||
* | ||
* These functions are not needed outside the convention plugins project and should be marked as | ||
* `internal` | ||
*/ | ||
|
||
/** | ||
* Retrieves the [dokkaBuild][org.jetbrains.DokkaBuildProperties] extension. | ||
*/ | ||
internal val Project.dokkaBuild: DokkaBuildProperties | ||
get() = extensions.getByType() | ||
|
||
/** | ||
* Configures the [dokkaBuild][org.jetbrains.DokkaBuildProperties] extension. | ||
*/ | ||
internal fun Project.dokkaBuild(configure: DokkaBuildProperties.() -> Unit) = | ||
extensions.configure(configure) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters