Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix test runtime Java versions #2918

Merged
merged 17 commits into from
Mar 16, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions .github/workflows/gradle-test.pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,32 +10,36 @@ jobs:
test-ubuntu:
strategy:
matrix:
version: [ 8, 11, 17 ]
javaVersion: [ 8, 11, 17 ]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: ${{ matrix.version }}
java-version: ${{ matrix.javaVersion }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems we can stick with Java 17 here.

Copy link
Contributor

@Goooler Goooler Mar 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressing the fix to #2938.

cache: 'maven'
- uses: gradle/gradle-build-action@v2
env:
ORG_GRADLE_PROJECT_org.jetbrains.dokka.javaToolchain.test: ${{ matrix.javaVersion }}
with:
arguments: clean test --stacktrace

test-windows:
strategy:
matrix:
version: [ 11, 17 ]
javaVersion: [ 11, 17 ]
fail-fast: false
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: ${{ matrix.version }}
java-version: ${{ matrix.javaVersion }}
cache: 'maven'
- uses: gradle/gradle-build-action@v2
env:
ORG_GRADLE_PROJECT_org.jetbrains.dokka.javaToolchain.test: ${{ matrix.javaVersion }}
with:
arguments: clean test --stacktrace --no-daemon --parallel --max-workers=1
53 changes: 53 additions & 0 deletions buildSrc/src/main/kotlin/org/jetbrains/DokkaBuildProperties.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
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(it) }
aSemy marked this conversation as resolved.
Show resolved Hide resolved

/**
* 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> =
aSemy marked this conversation as resolved.
Show resolved Hide resolved
dokkaProperty("javaToolchain.testLauncher") { JavaLanguageVersion.of(it) }
aSemy marked this conversation as resolved.
Show resolved Hide resolved

/**
* 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(it) }
aSemy marked this conversation as resolved.
Show resolved Hide resolved


private fun <T : Any> dokkaProperty(name: String, convert: (String) -> T) =
providers.gradleProperty("org.jetbrains.dokka.$name").map(convert)
aSemy marked this conversation as resolved.
Show resolved Hide resolved

companion object {
const val EXTENSION_NAME = "dokkaBuild"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,22 @@ package org.jetbrains.conventions
*/

plugins {
id("org.jetbrains.conventions.base")
`java`
}

java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(8))
languageVersion.set(dokkaBuild.mainJavaVersion)
}
}

java {
withSourcesJar()
}

tasks.withType<Test>().configureEach {
javaLauncher.set(javaToolchains.launcherFor {
languageVersion.set(dokkaBuild.testJavaLauncherVErsion)
aSemy marked this conversation as resolved.
Show resolved Hide resolved
})
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
package org.jetbrains.conventions

import org.jetbrains.DokkaBuildProperties

/**
* A convention plugin that sets up common config and sensible defaults for all subprojects.
*
* It provides the [DokkaBuildProperties] extension, for accessing common build properties.
*/

plugins {
base
}

// common Gradle configuration that should be applied to all projects
val dokkaBuildProperties =
extensions.create<DokkaBuildProperties>(DokkaBuildProperties.EXTENSION_NAME)

aSemy marked this conversation as resolved.
Show resolved Hide resolved

if (project != rootProject) {
project.group = rootProject.group
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package org.jetbrains.conventions

import org.jetbrains.configureDokkaVersion
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
Expand All @@ -12,8 +11,6 @@ plugins {

configureDokkaVersion()

val language_version: String by project

tasks.withType<KotlinCompile>().configureEach {
compilerOptions {
freeCompilerArgs.addAll(
Expand All @@ -26,7 +23,7 @@ tasks.withType<KotlinCompile>().configureEach {
)
)
allWarningsAsErrors.set(true)
languageVersion.set(KotlinVersion.fromVersion(language_version))
apiVersion.set(KotlinVersion.fromVersion(language_version))
languageVersion.set(dokkaBuild.kotlinLanguageLevel)
apiVersion.set(dokkaBuild.kotlinLanguageLevel)
}
}
25 changes: 25 additions & 0 deletions buildSrc/src/main/kotlin/org/jetbrains/internal/accessors.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package org.gradle.kotlin.dsl

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 should be marked `internal`, because they are not needed outside of the
* convention plugins project.
*/

/**
* Retrieves the [dokkaBuild][org.jetbrains.DokkaBuildProperties] extension.
*/
internal val Project.dokkaBuild: DokkaBuildProperties
get() = extensions.getByType<DokkaBuildProperties>()

/**
* Configures the [dokkaBuild][org.jetbrains.DokkaBuildProperties] extension.
*/
internal fun Project.dokkaBuild(configure: DokkaBuildProperties.() -> Unit) =
extensions.configure<DokkaBuildProperties>(configure)
4 changes: 3 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Project Settings
dokka_version=1.8.20-SNAPSHOT
org.jetbrains.dokka.javaToolchain.mainCompiler=8
org.jetbrains.dokka.javaToolchain.testLauncher=8
org.jetbrains.dokka.kotlinLanguageLevel=1.4
dokka_integration_test_parallelism=2
# Versions
kotlin_version=1.8.10
Expand All @@ -8,7 +11,6 @@ kotlinx_html_version=0.7.5
kotlin_plugin_version=213-1.8.10-release-430-IJ6777.52
jsoup_version=1.15.3
idea_version=213.6777.52
language_version=1.4
# jackson 2.13.X does not support kotlin language version 1.4, check before updating
jackson_version=2.12.7
# fixes CVE-2022-42003
Expand Down