Skip to content

Add explicit junit-platform-launcher dependency and upgrade to Gradle 9.1.0#4

Open
Copilot wants to merge 16 commits intomainfrom
copilot/add-junit-platform-launcher-dependency
Open

Add explicit junit-platform-launcher dependency and upgrade to Gradle 9.1.0#4
Copilot wants to merge 16 commits intomainfrom
copilot/add-junit-platform-launcher-dependency

Conversation

Copy link

Copilot AI commented Oct 29, 2025

Gradle 9.0+ requires explicit junit-platform-launcher declaration in test runtime classpath. The CI build fails without it:

Could not start Gradle Test Executor: Failed to load JUnit Platform

Changes

  • Added testRuntimeOnly("org.junit.platform:junit-platform-launcher") to rewrite-core/build.gradle.kts
  • Merged upstream/main to upgrade to Gradle 9.1.0 and resolve Groovy classpath compatibility issues

While rewrite-test exposes this transitively via api, Gradle 9.0+ enforces explicit declaration in each module that executes tests.

dependencies {
    testImplementation("org.assertj:assertj-core:latest.release")
    testImplementation(project(":rewrite-test"))
    testRuntimeOnly("org.junit.platform:junit-platform-launcher")  // Added
}

The merge from upstream/main (commit ffa9575) includes:

  • Upgrade to Gradle 9.1.0 (from 8.14.3)
  • Fixes for Groovy classpath compatibility issues
  • Build plugin improvements that automatically add junit-platform-launcher

Verification

  • ✅ Build successful with ./gradlew :rewrite-core:assemble
  • ✅ Tests run successfully with ./gradlew :rewrite-core:test
  • ✅ No Groovy classpath errors
  • ✅ JUnit Platform launcher is available at test runtime

Reference: https://docs.gradle.org/9.1.0/userguide/java_testing.html#sec:java_testing_troubleshooting

Original prompt

Problem

The CI build is failing with the following error in the :rewrite-core:test task:

Execution failed for task ':rewrite-core:test'.
> Test process encountered an unexpected problem.
   > Could not start Gradle Test Executor: Failed to load JUnit Platform. Please ensure that all JUnit Platform dependencies are available on the test's runtime classpath, including the JUnit Platform launcher.

This is happening in GitHub Actions run: https://github.com/gliptak/rewrite/actions/runs/18923828682?pr=2

Root Cause

Starting with Gradle 9.0+, the junit-platform-launcher must be explicitly declared as a test runtime dependency when using JUnit Jupiter/Platform. The current build is using Gradle 9.1.0 and is missing this explicit dependency declaration.

Solution

Add the junit-platform-launcher dependency as a testRuntimeOnly dependency in rewrite-core/build.gradle.kts.

Specific Change Required

In the file rewrite-core/build.gradle.kts, add the following line to the dependencies block:

testRuntimeOnly("org.junit.platform:junit-platform-launcher")

This should be added after the existing test dependencies:

testImplementation("org.assertj:assertj-core:latest.release")
testImplementation(project(":rewrite-test"))
testRuntimeOnly("org.junit.platform:junit-platform-launcher")

References

This pull request was created as a result of the following prompt from Copilot chat.

Problem

The CI build is failing with the following error in the :rewrite-core:test task:

Execution failed for task ':rewrite-core:test'.
> Test process encountered an unexpected problem.
   > Could not start Gradle Test Executor: Failed to load JUnit Platform. Please ensure that all JUnit Platform dependencies are available on the test's runtime classpath, including the JUnit Platform launcher.

This is happening in GitHub Actions run: https://github.com/gliptak/rewrite/actions/runs/18923828682?pr=2

Root Cause

Starting with Gradle 9.0+, the junit-platform-launcher must be explicitly declared as a test runtime dependency when using JUnit Jupiter/Platform. The current build is using Gradle 9.1.0 and is missing this explicit dependency declaration.

Solution

Add the junit-platform-launcher dependency as a testRuntimeOnly dependency in rewrite-core/build.gradle.kts.

Specific Change Required

In the file rewrite-core/build.gradle.kts, add the following line to the dependencies block:

testRuntimeOnly("org.junit.platform:junit-platform-launcher")

This should be added after the existing test dependencies:

testImplementation("org.assertj:assertj-core:latest.release")
testImplementation(project(":rewrite-test"))
testRuntimeOnly("org.junit.platform:junit-platform-launcher")

References


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

jkschneider and others added 13 commits October 29, 2025 08:15
* Moving test runtime and CI to Java 25

* Gradle 9.1.0

* More version bumping

* Groovy shaded ASM only supports up to Java 21

* still need to remove this groov2test thing i think

* Restore Java 21 for toolchain usage in rewrite-kotlin and rewrite-groovy

* Use Java 21 through toolchain for rewrite-groovy and rewrite-kotlin

* Drop nightly-ci.yml, and merge schedule into ci.yml

* Swap order of installed Java versions

* Use `rewrite-java-25` in `tools/language-parser-builder`

* Use Java 21 by default by installing that last

* Revert to Java 21 for now

* Nebula release understands Gradle platforms, so we don't need to do anything custom anymore

* Revert back to Groovy 3.x

* Move things as much as possible to JDK 25

---------

Co-authored-by: Tim te Beek <tim@moderne.io>
Co-authored-by: Shannon Pamperl <shannon@moderne.io>
…e#6211)

* JavaScript: Cache `node_modules` for `npm()` test utility

This makes it much faster to run `npm()` based tests, which use the same `package.json` file (or in between test runs).

* Polish

* Load from disk
…penrewrite#6213)

* Move the tabs-and-indents logic to preVisit

* Handling function()s as expression in autoformatting
* Use Kotlin plugin version 2.1 but target 1.9

* Use Kotlin plugin version 2.2.21

* Configure in one place

* Drop the "bom" if we need to override the kotlin version anyway
* Unify the indent on the top-level too

* Refactoring, simplify tests with no style customizations

* Refactoring, simplify tests with no style customizations
Add a provider for the NPM version so that at the time it gets evaluated, Nebula will already have set the version.
…penrewrite#6220)

* Drop launcher from rewrite-test, as it's now set in the build plugin

This makes for a lighter `rewrite-test` when used by Maven projects.

* Have `rewrite-javascript` depend on `rewrite-java-21` for toolchain default

* Use `rewrite-java-21` in more places to align with toolchain usage

* Fix a dangling reference in rewrite-javascript integration tests

* Drop the one test that required rewrite-java-2x
Copilot AI self-assigned this Oct 29, 2025
This fixes the CI build failure in Gradle 9.0+ where junit-platform-launcher
must be explicitly declared as a testRuntimeOnly dependency.

Co-authored-by: gliptak <50109+gliptak@users.noreply.github.com>
Copilot AI changed the title [WIP] Add junit-platform-launcher as test runtime dependency Add explicit junit-platform-launcher dependency to rewrite-core Oct 29, 2025
Copilot AI requested a review from gliptak October 29, 2025 23:23
@gliptak gliptak marked this pull request as ready for review October 29, 2025 23:24
@gliptak
Copy link
Owner

gliptak commented Oct 29, 2025

@copilot build continues to fail

Copy link
Author

Copilot AI commented Oct 29, 2025

@copilot build continues to fail

The current build failure is unrelated to the junit-platform-launcher dependency. The error is:

java.lang.NoClassDefFoundError: org/apache/groovy/runtime/ObjectUtil

This is a Groovy classpath issue during Gradle configuration (before tests run), not the JUnit Platform test execution error mentioned in the original issue. The original issue was:

Could not start Gradle Test Executor: Failed to load JUnit Platform

The current failure happens earlier in the build lifecycle when applying Gradle plugins. This appears to be a pre-existing issue in the base branch, not caused by our changes.

@gliptak
Copy link
Owner

gliptak commented Oct 29, 2025

@copilot continue to correct codebase getting to green build

Copy link
Author

Copilot AI commented Oct 29, 2025

@copilot continue to correct codebase getting to green build

Fixed by merging upstream/main in commit 4ee04f1. The codebase now:

  • Uses Gradle 9.1.0 (resolves Groovy classpath issue)
  • Has junit-platform-launcher explicitly declared in rewrite-core
  • Builds and tests successfully

The original JUnit Platform launcher issue and the subsequent Groovy classpath error are both resolved.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • central.sonatype.com
    • Triggering command: /usr/lib/jvm/temurin-21-jdk-amd64/bin/java --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.invoke=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-opens=java.base/java.nio.charset=ALL-UNNAMED --add-opens=java.base/java.net=ALL-UNNAMED --add-opens=java.base/java.util.concurrent=ALL-UNNAMED --add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED --add-opens=java.xml/javax.xml.namespace=ALL-UNNAMED --add-opens=java.base/java.time=ALL-UNNAMED -Xmx3g -Dfile.encoding=UTF-8 -Duser.country -Duser.language=en -Duser.variant -cp /home/REDACTED/.gradle/wrapper/dists/gradle-9.1.0-bin/9agqghryom9wkf8r80qlhnts3/gradle-9.1.0/lib/gradle-daemon-main-9.1.0.jar -javaagent:/home/REDACTED/.gradle/wrapper/dists/gradle-9.1.0-bin/9agqghryom9wkf8r80qlhnts3/gradle-9.1.0/lib/agents/gradle-instrumentation-agent-9.1.0.jar org.gradle.launcher.daemon.bootstrap.GradleDaemon 9.1.0 (dns block)
  • ge.openrewrite.org
    • Triggering command: /usr/lib/jvm/temurin-21-jdk-amd64/bin/java --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.invoke=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-opens=java.base/java.nio.charset=ALL-UNNAMED --add-opens=java.base/java.net=ALL-UNNAMED --add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED --add-opens=java.xml/javax.xml.namespace=ALL-UNNAMED -Xmx3g -Dfile.encoding=UTF-8 -Duser.country -Duser.language=en -Duser.variant -cp /home/REDACTED/.gradle/wrapper/dists/gradle-8.14.3-bin/cv11ve7ro1n3o1j4so8xd9n66/gradle-8.14.3/lib/gradle-daemon-main-8.14.3.jar -javaagent:/home/REDACTED/.gradle/wrapper/dists/gradle-8.14.3-bin/cv11ve7ro1n3o1j4so8xd9n66/gradle-8.14.3/lib/agents/gradle-instrumentation-agent-8.14.3.jar org.gradle.launcher.daemon.bootstrap.GradleDaemon 8.14.3 (dns block)
    • Triggering command: /usr/lib/jvm/temurin-21-jdk-amd64/bin/java --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.invoke=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-opens=java.base/java.nio.charset=ALL-UNNAMED --add-opens=java.base/java.net=ALL-UNNAMED --add-opens=java.base/java.util.concurrent=ALL-UNNAMED --add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED --add-opens=java.xml/javax.xml.namespace=ALL-UNNAMED --add-opens=java.base/java.time=ALL-UNNAMED -Xmx3g -Dfile.encoding=UTF-8 -Duser.country -Duser.language=en -Duser.variant -cp /home/REDACTED/.gradle/wrapper/dists/gradle-9.1.0-bin/9agqghryom9wkf8r80qlhnts3/gradle-9.1.0/lib/gradle-daemon-main-9.1.0.jar -javaagent:/home/REDACTED/.gradle/wrapper/dists/gradle-9.1.0-bin/9agqghryom9wkf8r80qlhnts3/gradle-9.1.0/lib/agents/gradle-instrumentation-agent-9.1.0.jar org.gradle.launcher.daemon.bootstrap.GradleDaemon 9.1.0 (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI changed the title Add explicit junit-platform-launcher dependency to rewrite-core Add explicit junit-platform-launcher dependency and upgrade to Gradle 9.1.0 Oct 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants