Skip to content

Commit

Permalink
Update required Java version to 11 (#617 / #627)
Browse files Browse the repository at this point in the history
Related: #617
PR: #627
  • Loading branch information
Bukama authored and nipafx committed Dec 20, 2022
1 parent b9dc377 commit 0037f1c
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 53 deletions.
16 changes: 7 additions & 9 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,10 @@ jobs:
with:
arguments: --scan spotlessCheck

# Our full integration job, which will build for a matrix out of our supported
# Java versions, operating systems, modular or not, and various JUnit versions.
# This build is executed on all tags and the default branch. Furthermore, we will
# also execute this for pull requests with the label `full-build`.
# Our full integration job, which will build for a matrix out of our
# supported Java versions, operating systems and various JUnit versions.
# This build is executed on all tags and the default branch as well as
# for pull requests with the label `full-build`.
full-featured:
if: (contains(github.event.pull_request.labels.*.name, 'full-build') || !github.event.pull_request)
needs: basic
Expand All @@ -118,9 +118,8 @@ jobs:
matrix:
java: [ 11, 17, 18 ]
junit-version: [ '5.9.0' ]
modular: [true, false]
os: [ubuntu, macos, windows]
name: with Java ${{ matrix.java }}, JUnit ${{ matrix.junit-version }}, Modular ${{ matrix.modular }} on ${{ matrix.os }}
name: with Java ${{ matrix.java }}, JUnit ${{ matrix.junit-version }} on ${{ matrix.os }}
steps:
- name: Check out repo
uses: actions/checkout@v2
Expand All @@ -133,7 +132,7 @@ jobs:
- name: Gradle build
uses: gradle/gradle-build-action@v2
with:
arguments: --refresh-dependencies -PmodularBuild=${{ matrix.modular }} -PjunitVersion=${{ matrix.junit-version }} --stacktrace --scan clean build -x spotlessCheck
arguments: --refresh-dependencies -PjunitVersion=${{ matrix.junit-version }} --stacktrace --scan clean build -x spotlessCheck

# We want to be up-to-date and know issues with future Java versions as soon as possible.
# Furthermore, we also would love to see our build working with the latest Gradle version.
Expand All @@ -147,7 +146,6 @@ jobs:
strategy:
matrix:
junit-version: [ '5.9.0' ]
modular: [true, false]
os: [ubuntu, macos, windows]
name: Experimental build with newest JDK early-access build and Gradle release candidate
# Gradle doesn't work with JDK EA builds, so we launch it with a supported Java version,
Expand Down Expand Up @@ -178,7 +176,7 @@ jobs:
uses: gradle/gradle-build-action@v2
with:
gradle-version: release-candidate
arguments: --refresh-dependencies -PexperimentalJavaVersion=${{ env.EXPERIMENTAL_JAVA }} -PmodularBuild=${{ matrix.modular }} -PjunitVersion=${{ matrix.junit-version }} -Porg.gradle.java.installations.auto-download=false --stacktrace --scan clean build -x spotlessCheck
arguments: --refresh-dependencies -PexperimentalJavaVersion=${{ env.EXPERIMENTAL_JAVA }} -PjunitVersion=${{ matrix.junit-version }} -Porg.gradle.java.installations.auto-download=false --stacktrace --scan clean build -x spotlessCheck

# A release will be created if there is a `version` defined and `releasing` is set to `true`.
# If not, this stage will be ignored.
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Check out [junit-pioneer.org](https://junit-pioneer.org/), particularly [the doc
## A Pioneer's Mission

JUnit Pioneer provides extensions for [JUnit 5](https://github.com/junit-team/junit5/) and its Jupiter API.
It does not limit itself to proven ideas with wide application but is purposely open to experiments.
It does not limit itself to proven ideas with wide application but is purposely open to experimentation.
It aims to spin off successful and cohesive portions into sibling projects or back into the JUnit 5 code base.

To enable easy exchange of code with JUnit 5, JUnit Pioneer copies most of its infrastructure, from code style to build tool and configuration to continuous integration.
Expand Down Expand Up @@ -50,8 +50,8 @@ testCompile group: 'org.junit-pioneer', name: 'junit-pioneer', version: /*...*/

## Dependencies

JUnit Pioneer is compiled against Java 8 (built with JDK 11), but comes as a module (i.e. with a `module-info.class`) named _org.junitpioneer_.
That means it can be used on all Java versions 8 and higher on class path and module path.
Starting with release 2.0, JUnit Pioneer is compiled against **Java 11** and comes as a module (i.e. with a `module-info.class`) named _org.junitpioneer_.
That means it can be used on all Java versions 11 and higher on class path and module path.

Pioneer does not only use JUnit 5's API, but also other artifacts from its ecosystem such as [`junit-platform-commons`](https://mvnrepository.com/artifact/org.junit.platform/junit-platform-commons).
To avoid dependency issues (e.g. in [junit-pioneer#343](https://github.com/junit-pioneer/junit-pioneer/issues/343)), you should add the JUnit 5 BOM ([`junit-bom`](https://mvnrepository.com/artifact/org.junit/junit-bom)) to your project instead of defining all dependency versions manually.
Expand Down
49 changes: 10 additions & 39 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ plugins {
id("com.diffplug.spotless") version "6.4.2"
id("at.zierler.yamlvalidator") version "1.5.0"
id("org.sonarqube") version "3.3"
id("org.moditect.gradleplugin") version "1.0.0-rc3"
id("org.shipkit.shipkit-changelog") version "1.1.15"
id("org.shipkit.shipkit-github-release") version "1.1.15"
id("com.github.ben-manes.versions") version "0.42.0"
Expand All @@ -24,23 +23,18 @@ plugins.withType<JavaPlugin>().configureEach {
group = "org.junit-pioneer"
description = "JUnit 5 Extension Pack"

val modularBuild : String by project
val experimentalJavaVersion : String? by project
val experimentalBuild: Boolean = experimentalJavaVersion?.isNotEmpty() ?: false

val targetJavaVersion = JavaVersion.VERSION_1_8
val targetJavaVersion = JavaVersion.VERSION_11

java {
if (experimentalBuild) {
toolchain {
languageVersion.set(JavaLanguageVersion.of(experimentalJavaVersion!!))
}
} else {
sourceCompatibility = if (modularBuild.toBoolean()) {
JavaVersion.VERSION_11
} else {
targetJavaVersion
}
sourceCompatibility = targetJavaVersion
}
withJavadocJar()
withSourcesJar()
Expand Down Expand Up @@ -114,16 +108,6 @@ sonarqube {
}
}

moditect {
addMainModuleInfo {
version = project.version
overwriteExistingFiles.set(true)
module {
moduleInfoFile = rootProject.file("src/main/module/module-info.java")
}
}
}

publishing {
publications {
create<MavenPublication>("maven") {
Expand Down Expand Up @@ -204,14 +188,6 @@ extraJavaModuleInfo {
tasks {

sourceSets {
main {
if (modularBuild.toBoolean())
java.srcDir("src/main/module")
}
test {
if (modularBuild.toBoolean())
java.srcDir("src/test/module")
}
create("demo") {
java {
srcDir("src/demo/java")
Expand Down Expand Up @@ -239,32 +215,27 @@ tasks {

// Prepares test-related JVM args
val moduleName = "org.junitpioneer"
val targetModule = if (modularBuild.toBoolean()) moduleName else "ALL-UNNAMED"
// See https://docs.gradle.org/current/userguide/java_testing.html#sec:java_testing_modular_patching
val patchModuleArg = "--patch-module=$moduleName=${compileJava.get().destinationDirectory.asFile.get().path}"
val testJvmArgs = listOf(
// Ignore these options on Java 8
"-XX:+IgnoreUnrecognizedVMOptions",
// EnvironmentVariableUtils: make java.util.Map accessible
"--add-opens=java.base/java.util=$targetModule",
"--add-opens=java.base/java.util=$moduleName",
// EnvironmentVariableUtils: make java.lang.System accessible
"--add-opens=java.base/java.lang=$targetModule",
"--add-opens=java.base/java.lang=$moduleName",
patchModuleArg
)

compileTestJava {
options.encoding = "UTF-8"
options.compilerArgs.add("-Werror")
if (modularBuild.toBoolean()) {
options.compilerArgs.add(patchModuleArg)
}
options.compilerArgs.add(patchModuleArg)
var xlintArg = "-Xlint:all"
if (modularBuild.toBoolean()) {
xlintArg += ",-exports,-requires-automatic"
// missing-explicit-ctor was added in Java 16. This causes errors on test classes, which don't have one.
if (JavaVersion.current() >= JavaVersion.VERSION_16) {
xlintArg += ",-missing-explicit-ctor"
}
xlintArg += ",-exports,-requires-automatic"
// missing-explicit-ctor was added in Java 16. This causes errors on test classes, which don't have one.
if (JavaVersion.current() >= JavaVersion.VERSION_16) {
xlintArg += ",-missing-explicit-ctor"
}
options.compilerArgs.add(xlintArg)
}
Expand Down Expand Up @@ -343,7 +314,7 @@ tasks {
// Set javadoc `--release` flag (affects which warnings and errors are reported)
// (Note: Gradle adds one leading '-' to the option on its own)
// Have to use at least Java 9 to support modular build
addStringOption("-release", maxOf(11, targetJavaVersion.majorVersion.toInt()).toString())
addStringOption("-release", targetJavaVersion.majorVersion.toInt().toString())

// Enable doclint, but ignore warnings for missing tags, see
// https://docs.oracle.com/en/java/javase/17/docs/specs/man/javadoc.html#additional-options-provided-by-the-standard-doclet
Expand Down
1 change: 0 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@ junitVersion=5.9.0

# Ensure sufficient heap size, especially for Sonar.
org.gradle.jvmargs=-Xmx8g
modularBuild=false
org.gradle.java.installations.fromEnv=JDK_EXPERIMENTAL
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* and its Jupiter API.
*
* <p>Pioneer does not limit itself to proven ideas with wide application but is purposely open to
* experiments. It aims to spin off successful and cohesive portions into sibling projects or back
* experimentation. It aims to spin off successful and cohesive portions into sibling projects or back
* into the JUnit 5 code base.
*
* <p>The dependencies on Jupiter modules could be marked as <code>transitive</code> but that would
Expand Down
File renamed without changes.

0 comments on commit 0037f1c

Please sign in to comment.