diff --git a/.github/workflows/build-all-examples.yml b/.github/workflows/build-all-examples.yml index 2f7588da..a45d6e44 100644 --- a/.github/workflows/build-all-examples.yml +++ b/.github/workflows/build-all-examples.yml @@ -4,6 +4,7 @@ on: branches: - main - 'r5.*' + - 'develop/*' pull_request: branches: - '*' @@ -24,7 +25,7 @@ jobs: distribution: temurin - uses: sbt/setup-sbt@234370af1319038bf8dc432f8a7e4b83078a1781 # v1.1.11 - name: 'Build all examples' - run: java src/Builder.java + run: java src/Builder.java --exclude=junit-jupiter-starter-ant,junit-jupiter-starter-bazel,junit-modular-world - name: 'Check automation for updating versions' run: java src/Updater.java 42 if: github.repository == 'junit-team/junit-examples' && github.ref == 'refs/heads/main' diff --git a/junit-jupiter-extensions/build.gradle b/junit-jupiter-extensions/build.gradle index 53d461dc..d4c23093 100644 --- a/junit-jupiter-extensions/build.gradle +++ b/junit-jupiter-extensions/build.gradle @@ -6,18 +6,24 @@ plugins { repositories { mavenCentral() + maven { + url = "https://central.sonatype.com/repository/maven-snapshots" + mavenContent { + snapshotsOnly() + includeGroupByRegex("org\\.junit.*") + } + } } version = '1.0.0-SNAPSHOT' tasks.withType(JavaCompile).configureEach { - sourceCompatibility = 1.8 - targetCompatibility = 1.8 + options.release = 17 options.compilerArgs += '-parameters' } dependencies { - api(platform("org.junit:junit-bom:5.13.2")) + api(platform("org.junit:junit-bom:6.0.0-RC2")) api("org.junit.jupiter:junit-jupiter-api") { because 'building extensions in "main" using JUnit Jupiter API' } diff --git a/junit-jupiter-starter-ant/build.sh b/junit-jupiter-starter-ant/build.sh index a394c018..28e7fbba 100755 --- a/junit-jupiter-starter-ant/build.sh +++ b/junit-jupiter-starter-ant/build.sh @@ -4,11 +4,11 @@ set -e # # Set constants. # -junit_platform_version='1.13.2' +junit_version='6.0.0-RC2' ant_version='1.10.15' ant_folder="apache-ant-${ant_version}" ant_archive="${ant_folder}-bin.tar.gz" -standalone_jar="${ant_folder}/lib/junit-platform-console-standalone-${junit_platform_version}.jar" +standalone_jar="${ant_folder}/lib/junit-platform-console-standalone-${junit_version}.jar" # # Load and extract Apache Ant. @@ -23,8 +23,8 @@ fi # Load and store junit-platform-console-standalone jar into ${ANT_HOME}/lib. # if [ ! -f "${standalone_jar}" ]; then - echo "Downloading junit-platform-console-standalone $junit_platform_version..." - curl --silent --show-error --fail "https://repo1.maven.org/maven2/org/junit/platform/junit-platform-console-standalone/${junit_platform_version}/junit-platform-console-standalone-${junit_platform_version}.jar" \ + echo "Downloading junit-platform-console-standalone $junit_version..." + curl --silent --show-error --fail "https://repo1.maven.org/maven2/org/junit/platform/junit-platform-console-standalone/${junit_version}/junit-platform-console-standalone-${junit_version}.jar" \ --output "${standalone_jar}" fi diff --git a/junit-jupiter-starter-bazel/MODULE.bazel b/junit-jupiter-starter-bazel/MODULE.bazel index 0cef70cf..2ef3fb7d 100644 --- a/junit-jupiter-starter-bazel/MODULE.bazel +++ b/junit-jupiter-starter-bazel/MODULE.bazel @@ -1,6 +1,4 @@ -JUNIT_JUPITER_VERSION = "5.13.2" - -JUNIT_PLATFORM_VERSION = "1.13.2" +JUNIT_VERSION = "6.0.0-RC2" bazel_dep(name = "rules_jvm_external", version = "6.7") bazel_dep(name = "contrib_rules_jvm", version = "0.29.0") @@ -9,11 +7,11 @@ maven = use_extension("@rules_jvm_external//:extensions.bzl", "maven") maven.install( artifacts = [ - "org.junit.platform:junit-platform-launcher:%s" % JUNIT_PLATFORM_VERSION, - "org.junit.platform:junit-platform-reporting:%s" % JUNIT_PLATFORM_VERSION, - "org.junit.jupiter:junit-jupiter-api:%s" % JUNIT_JUPITER_VERSION, - "org.junit.jupiter:junit-jupiter-params:%s" % JUNIT_JUPITER_VERSION, - "org.junit.jupiter:junit-jupiter-engine:%s" % JUNIT_JUPITER_VERSION, + "org.junit.platform:junit-platform-launcher:%s" % JUNIT_VERSION, + "org.junit.platform:junit-platform-reporting:%s" % JUNIT_VERSION, + "org.junit.jupiter:junit-jupiter-api:%s" % JUNIT_VERSION, + "org.junit.jupiter:junit-jupiter-params:%s" % JUNIT_VERSION, + "org.junit.jupiter:junit-jupiter-engine:%s" % JUNIT_VERSION, ], repositories = [ "https://repo1.maven.org/maven2", diff --git a/junit-jupiter-starter-gradle-groovy/build.gradle b/junit-jupiter-starter-gradle-groovy/build.gradle index 524b7ebd..15e1a2bf 100644 --- a/junit-jupiter-starter-gradle-groovy/build.gradle +++ b/junit-jupiter-starter-gradle-groovy/build.gradle @@ -6,11 +6,18 @@ plugins { repositories { mavenCentral() + maven { + url = "https://central.sonatype.com/repository/maven-snapshots" + mavenContent { + snapshotsOnly() + includeGroupByRegex("org\\.junit.*") + } + } } dependencies { implementation(localGroovy()) - testImplementation(platform('org.junit:junit-bom:5.13.2')) + testImplementation(platform('org.junit:junit-bom:6.0.0-RC2')) testImplementation('org.junit.jupiter:junit-jupiter') testRuntimeOnly('org.junit.platform:junit-platform-launcher') } diff --git a/junit-jupiter-starter-gradle-kotlin/build.gradle.kts b/junit-jupiter-starter-gradle-kotlin/build.gradle.kts index ffd5868d..1558585e 100644 --- a/junit-jupiter-starter-gradle-kotlin/build.gradle.kts +++ b/junit-jupiter-starter-gradle-kotlin/build.gradle.kts @@ -1,4 +1,4 @@ -import org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_1_8 +import org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_17 import org.jetbrains.kotlin.gradle.tasks.KotlinCompile plugins { @@ -7,10 +7,16 @@ plugins { repositories { mavenCentral() + maven(url = "https://central.sonatype.com/repository/maven-snapshots") { + mavenContent { + snapshotsOnly() + includeGroupByRegex("org\\.junit.*") + } + } } dependencies { - testImplementation(platform("org.junit:junit-bom:5.13.2")) + testImplementation(platform("org.junit:junit-bom:6.0.0-RC2")) testImplementation("org.junit.jupiter:junit-jupiter") testRuntimeOnly("org.junit.platform:junit-platform-launcher") } @@ -23,9 +29,9 @@ tasks.test { } tasks.withType().configureEach { - options.release.set(8) + options.release.set(17) } tasks.withType().configureEach { - compilerOptions.jvmTarget = JVM_1_8 + compilerOptions.jvmTarget = JVM_17 } diff --git a/junit-jupiter-starter-gradle/build.gradle b/junit-jupiter-starter-gradle/build.gradle index abb7cc6d..b561e47e 100644 --- a/junit-jupiter-starter-gradle/build.gradle +++ b/junit-jupiter-starter-gradle/build.gradle @@ -6,10 +6,17 @@ plugins { repositories { mavenCentral() + maven { + url = "https://central.sonatype.com/repository/maven-snapshots" + mavenContent { + snapshotsOnly() + includeGroupByRegex("org\\.junit.*") + } + } } dependencies { - testImplementation(platform('org.junit:junit-bom:5.13.2')) + testImplementation(platform('org.junit:junit-bom:6.0.0-RC2')) testImplementation('org.junit.jupiter:junit-jupiter') testRuntimeOnly('org.junit.platform:junit-platform-launcher') } diff --git a/junit-jupiter-starter-maven-kotlin/pom.xml b/junit-jupiter-starter-maven-kotlin/pom.xml index 65e932e6..46e17831 100644 --- a/junit-jupiter-starter-maven-kotlin/pom.xml +++ b/junit-jupiter-starter-maven-kotlin/pom.xml @@ -20,7 +20,7 @@ org.junit junit-bom - 5.13.2 + 6.0.0-RC2 pom import @@ -82,4 +82,17 @@ + + + maven-central-snapshots + https://central.sonatype.com/repository/maven-snapshots + + true + + + false + + + + diff --git a/junit-jupiter-starter-maven/pom.xml b/junit-jupiter-starter-maven/pom.xml index e24a22d9..c36038af 100644 --- a/junit-jupiter-starter-maven/pom.xml +++ b/junit-jupiter-starter-maven/pom.xml @@ -18,7 +18,7 @@ org.junit junit-bom - 5.13.2 + 6.0.0-RC2 pom import @@ -42,4 +42,17 @@ + + + maven-central-snapshots + https://central.sonatype.com/repository/maven-snapshots + + true + + + false + + + + diff --git a/junit-jupiter-starter-sbt/build.sbt b/junit-jupiter-starter-sbt/build.sbt index 2d9fc61c..8b3c90e1 100644 --- a/junit-jupiter-starter-sbt/build.sbt +++ b/junit-jupiter-starter-sbt/build.sbt @@ -8,8 +8,9 @@ lazy val root = project name := "junit-jupiter-starter-sbt", libraryDependencies ++= Seq( "net.aichler" % "jupiter-interface" % JupiterKeys.jupiterVersion.value % Test, - "org.junit.jupiter" % "junit-jupiter" % "5.13.2" % Test, - "org.junit.platform" % "junit-platform-launcher" % "1.13.2" % Test, + "org.junit.jupiter" % "junit-jupiter" % "6.0.0-RC2" % Test, + "org.junit.platform" % "junit-platform-launcher" % "6.0.0-RC2" % Test, ), - testOptions += Tests.Argument(jupiterTestFramework, "--display-mode=tree") + testOptions += Tests.Argument(jupiterTestFramework, "--display-mode=tree"), + resolvers += "Maven Central Snapshots" at "https://central.sonatype.com/repository/maven-snapshots" ) diff --git a/junit-migration-gradle/README.md b/junit-migration-gradle/README.md index 865031ef..251b8857 100644 --- a/junit-migration-gradle/README.md +++ b/junit-migration-gradle/README.md @@ -60,7 +60,7 @@ Jupiter TestEngine. ```groovy dependencies { - testImplementation("org.junit.jupiter:junit-jupiter:5.13.2") + testImplementation("org.junit.jupiter:junit-jupiter:6.0.0-RC2") } ``` @@ -71,7 +71,7 @@ on the JUnit Vintage TestEngine implementation similar to the following. ```groovy dependencies { testImplementation("junit:junit:4.13.2") - testRuntimeOnly("org.junit.vintage:junit-vintage-engine:5.13.2") + testRuntimeOnly("org.junit.vintage:junit-vintage-engine:6.0.0-RC2") } ``` diff --git a/junit-migration-gradle/build.gradle b/junit-migration-gradle/build.gradle index 93834a7b..f5e25d50 100644 --- a/junit-migration-gradle/build.gradle +++ b/junit-migration-gradle/build.gradle @@ -7,10 +7,17 @@ plugins { repositories { mavenCentral() + maven { + url = "https://central.sonatype.com/repository/maven-snapshots" + mavenContent { + snapshotsOnly() + includeGroupByRegex("org\\.junit.*") + } + } } dependencies { - testImplementation(platform("org.junit:junit-bom:5.13.2")) + testImplementation(platform("org.junit:junit-bom:6.0.0-RC2")) testImplementation("org.junit.jupiter:junit-jupiter") { because 'allows to write and run Jupiter tests' diff --git a/junit-migration-maven/pom.xml b/junit-migration-maven/pom.xml index c98fc197..74e640bb 100644 --- a/junit-migration-maven/pom.xml +++ b/junit-migration-maven/pom.xml @@ -19,7 +19,7 @@ org.junit junit-bom - 5.13.2 + 6.0.0-RC2 pom import @@ -69,4 +69,17 @@ + + + + maven-central-snapshots + https://central.sonatype.com/repository/maven-snapshots + + true + + + false + + + diff --git a/junit-modular-world/src/build/Project.java b/junit-modular-world/src/build/Project.java index 0dc03556..fdbf8b71 100644 --- a/junit-modular-world/src/build/Project.java +++ b/junit-modular-world/src/build/Project.java @@ -43,23 +43,22 @@ void compile() throws Exception { // // download main and test dependencies // - String platformVersion = "1.13.1"; - String jupiterVersion = "5.13.1"; - String vintageVersion = "5.13.1"; - get("lib", "org.junit.platform", "junit-platform-commons", platformVersion); - get("lib", "org.junit.platform", "junit-platform-console", platformVersion); - get("lib", "org.junit.platform", "junit-platform-engine", platformVersion); - get("lib", "org.junit.platform", "junit-platform-launcher", platformVersion); - get("lib", "org.junit.platform", "junit-platform-reporting", platformVersion); - get("lib", "org.junit.jupiter", "junit-jupiter-api", jupiterVersion); - get("lib", "org.junit.jupiter", "junit-jupiter-params", jupiterVersion); - get("lib", "org.junit.jupiter", "junit-jupiter-engine", jupiterVersion); - get("lib", "org.junit.vintage", "junit-vintage-engine", vintageVersion); + String junitVersion = "6.0.0-RC2"; + get("lib", "org.junit.platform", "junit-platform-commons", junitVersion); + get("lib", "org.junit.platform", "junit-platform-console", junitVersion); + get("lib", "org.junit.platform", "junit-platform-engine", junitVersion); + get("lib", "org.junit.platform", "junit-platform-launcher", junitVersion); + get("lib", "org.junit.platform", "junit-platform-reporting", junitVersion); + get("lib", "org.junit.jupiter", "junit-jupiter-api", junitVersion); + get("lib", "org.junit.jupiter", "junit-jupiter-params", junitVersion); + get("lib", "org.junit.jupiter", "junit-jupiter-engine", junitVersion); + get("lib", "org.junit.vintage", "junit-vintage-engine", junitVersion); get("lib", "junit", "junit", "4.13.2"); get("lib", "org.hamcrest", "hamcrest-core", "1.3"); get("lib", "org.apiguardian", "apiguardian-api", "1.1.2"); + get("lib", "org.jspecify", "jspecify", "1.0.0"); get("lib", "org.opentest4j", "opentest4j", "1.3.0"); - get("lib", "org.opentest4j.reporting", "open-test-reporting-tooling-spi", "0.2.3"); + get("lib", "org.opentest4j.reporting", "open-test-reporting-tooling-spi", "0.2.4"); get("lib", "net.jqwik", "jqwik-api", "1.9.3"); get("lib", "net.jqwik", "jqwik-engine", "1.9.3"); @@ -310,19 +309,25 @@ String[] toArray() { } } - int run(String tool, String... args) { + void run(String tool, String... args) { printCommandDetails("run", tool, args); - return ToolProvider.findFirst(tool).get().run(System.out, System.err, args); + checkExitCode(ToolProvider.findFirst(tool).get().run(System.out, System.err, args)); } - int exe(String executable, String... args) throws Exception { + void exe(String executable, String... args) throws Exception { printCommandDetails("exe", executable, args); ProcessBuilder processBuilder = new ProcessBuilder(executable); Arrays.stream(args).forEach(processBuilder.command()::add); processBuilder.redirectErrorStream(true); Process process = processBuilder.start(); process.getInputStream().transferTo(System.out); - return process.waitFor(); + checkExitCode(process.waitFor()); + } + + private void checkExitCode(int exitCode) { + if (exitCode != 0) { + System.exit(exitCode); + } } void printCommandDetails(String context, String command, String... args) { diff --git a/junit-multiple-engines/build.gradle.kts b/junit-multiple-engines/build.gradle.kts index d1a077bb..510360e3 100644 --- a/junit-multiple-engines/build.gradle.kts +++ b/junit-multiple-engines/build.gradle.kts @@ -11,11 +11,18 @@ plugins { repositories { mavenCentral() + maven(url = "https://central.sonatype.com/repository/maven-snapshots") { + mavenContent { + snapshotsOnly() + includeGroupByRegex("org\\.junit.*") + } + } + } dependencies { val junit4Version = "4.13.2" - val junitBomVersion = "5.13.2" + val junitBomVersion = "6.0.0-RC2" // Use junit-bom to align versions // https://docs.gradle.org/current/userguide/managing_transitive_dependencies.html#sec:bom_import diff --git a/src/Updater.java b/src/Updater.java index 4fe32bbb..6742b402 100644 --- a/src/Updater.java +++ b/src/Updater.java @@ -22,36 +22,35 @@ @SuppressWarnings({"WeakerAccess", "SameParameterValue"}) class Updater { - private static final String VERSION_REGEX = "([0-9.]+)"; + private static final String VERSION_REGEX = "([0-9.]+(?:-[A-Z]+[0-9]*)?)"; public static void main(String[] args) throws Exception { new Updater(args[0]).update(); } - private final String jupiterVersion; + private final String newVersion; - public Updater(String jupiterVersion) { - this.jupiterVersion = jupiterVersion; + public Updater(String newVersion) { + this.newVersion = newVersion; } void update() throws IOException { - var gradleBomReplacement = new Replacement("org.junit:junit-bom:" + VERSION_REGEX, VersionType.BOM); - var mavenBomReplacement = new Replacement( - Pattern.compile(""" - \\s*org.junit - \\s*junit-bom - \\s*([0-9.]+) - """, Pattern.MULTILINE), - VersionType.BOM + var gradleBomReplacement = Pattern.compile("org.junit:junit-bom:" + VERSION_REGEX); + var mavenBomReplacement = Pattern.compile( + """ + \\s*org.junit + \\s*junit-bom + \\s*""" + VERSION_REGEX + "", + Pattern.MULTILINE ); + System.out.println(mavenBomReplacement); update(Path.of("junit-jupiter-extensions/build.gradle"), List.of(gradleBomReplacement)); update(Path.of("junit-jupiter-starter-ant/build.sh"), List.of( - new Replacement("junit_platform_version='" + VERSION_REGEX + "'", VersionType.PLATFORM) + Pattern.compile("junit_version='" + VERSION_REGEX + "'") )); update(Path.of("junit-jupiter-starter-bazel/MODULE.bazel"), List.of( - new Replacement("JUNIT_JUPITER_VERSION = \"" + VERSION_REGEX + '"', VersionType.JUPITER), - new Replacement("JUNIT_PLATFORM_VERSION = \"" + VERSION_REGEX + '"', VersionType.PLATFORM) + Pattern.compile("JUNIT_VERSION = \"" + VERSION_REGEX + '"') )); update(Path.of("junit-jupiter-starter-gradle/build.gradle"), List.of(gradleBomReplacement)); update(Path.of("junit-jupiter-starter-gradle-groovy/build.gradle"), List.of(gradleBomReplacement)); @@ -59,39 +58,36 @@ void update() throws IOException { update(Path.of("junit-jupiter-starter-maven/pom.xml"), List.of(mavenBomReplacement)); update(Path.of("junit-jupiter-starter-maven-kotlin/pom.xml"), List.of(mavenBomReplacement)); update(Path.of("junit-jupiter-starter-sbt/build.sbt"), List.of( - new Replacement("\"org.junit.jupiter\" % \"junit-jupiter\" % \"" + VERSION_REGEX + '"', VersionType.JUPITER), - new Replacement("\"org.junit.platform\" % \"junit-platform-launcher\" % \"" + VERSION_REGEX + '"', VersionType.PLATFORM) + Pattern.compile("\"org.junit.jupiter\" % \"junit-jupiter\" % \"" + VERSION_REGEX + '"'), + Pattern.compile("\"org.junit.platform\" % \"junit-platform-launcher\" % \"" + VERSION_REGEX + '"') )); update(Path.of("junit-migration-gradle/build.gradle"), List.of(gradleBomReplacement)); update(Path.of("junit-migration-gradle/README.md"), List.of( - new Replacement("org.junit.jupiter:junit-jupiter:" + VERSION_REGEX, VersionType.JUPITER), - new Replacement("org.junit.vintage:junit-vintage-engine:" + VERSION_REGEX, VersionType.VINTAGE) + Pattern.compile("org.junit.jupiter:junit-jupiter:" + VERSION_REGEX), + Pattern.compile("org.junit.vintage:junit-vintage-engine:" + VERSION_REGEX) )); update(Path.of("junit-migration-maven/pom.xml"), List.of(mavenBomReplacement)); update(Path.of("junit-modular-world/src/build/Project.java"), List.of( - new Replacement("platformVersion = \"" + VERSION_REGEX + '"', VersionType.PLATFORM), - new Replacement("jupiterVersion = \"" + VERSION_REGEX + '"', VersionType.JUPITER), - new Replacement("vintageVersion = \"" + VERSION_REGEX + '"', VersionType.VINTAGE) + Pattern.compile("junitVersion = \"" + VERSION_REGEX + '"') )); update(Path.of("junit-multiple-engines/build.gradle.kts"), List.of( - new Replacement("junitBomVersion = \"" + VERSION_REGEX + '"', VersionType.BOM) + Pattern.compile("junitBomVersion = \"" + VERSION_REGEX + '"') )); } - void update(Path path, List replacements) throws IOException { + void update(Path path, List patterns) throws IOException { System.out.printf("Updating %s...", path); System.out.flush(); int matches = 0; var content = new StringBuilder(Files.readString(path)); - for (var replacement : replacements) { + for (var pattern : patterns) { var minIndex = 0; - var matcher = replacement.regex.matcher(content); + var matcher = pattern.matcher(content); while (matcher.find(minIndex)) { matches++; int start = matcher.start(1); int end = matcher.end(1); int oldLength = end - start; - String newVersion = replacement.newVersion(jupiterVersion); content.replace(start, end, newVersion); minIndex = end + newVersion.length() - oldLength; } @@ -102,24 +98,4 @@ void update(Path path, List replacements) throws IOException { throw new IllegalStateException("No matches found in " + path); } } - - record Replacement(Pattern regex, VersionType versionType) { - Replacement(String regex, VersionType versionType) { - this(Pattern.compile(regex), versionType); - } - - String newVersion(String jupiterVersion) { - return switch (versionType) { - case BOM, JUPITER, VINTAGE -> jupiterVersion; - case PLATFORM -> jupiterVersion.replaceFirst("\\d+\\.", "1."); - }; - } - } - - enum VersionType { - BOM, - JUPITER, - PLATFORM, - VINTAGE - } }