Skip to content

Fix broken Windows XDK launcher labels (script changed in Gradle 9.4), adopt stable Gradle 9.x features. Also fix broken JIT Paths for Windows. - #670

Merged
lagergren merged 18 commits into
masterfrom
gradle-9.8-fixes-and-stable-features
Oct 6, 2026

Conversation

@lagergren

@lagergren lagergren commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Description

These changes come from reviewing the Gradle 9.2–9.8 release notes and the 9.x upgrade guide against the build. They contain two fixes and three features that are stable in Gradle 9.8. I deliberately left out the Gradle 10 feature previews (STABLE_CONFIGURATION_CACHE, NO_IMPLICIT_LOOKUP_IN_PARENT_PROJECTS, ENHANCED_GRAPH_ORDERING) and everything still incubating in 9.8 (parallel configuration-cache store, configure on demand, isolated projects, read-only configuration cache).

Fixes

  • Windows XDK launchers jumped to labels that no longer exist.
    • XdkDistribution injects an XDK_HOME block into xtc.bat, xcc.bat and xec.bat that ran goto end and goto fail.
    • The Windows start-script template that Gradle 9.5 reworked (we upgraded in Upgrade Gradle 9.4.1 → 9.5.0; bump Develocity to 4.4.1 #450) has no :end or :fail labels; its only exit label is :exitWithErrorLevel, which the template comments as stable. The old labels are visible in gradlew.bat before Upgrade Gradle 9.4.1 → 9.5.0; bump Develocity to 4.4.1 #450.
    • On the invalid-XDK path (no javatools\javatools.jar), goto fail therefore ended in "The system cannot find the batch label specified".
    • The block now jumps to :exitWithErrorLevel and exits with 1 on that path, using the template's own idiom.
  • The Windows launchers' XDK_HOME handling.
    • Delegation never worked: the block set and read XDK_CMD, XDK_ID and APP_ID inside one parenthesized block, and cmd.exe expands variables when it parses the whole block. The block now runs one statement per line.
    • It compared the wrong file: it checked the extensionless POSIX script; it now compares against the .bat itself (%~nx0).
    • Paths with spaces broke: the javatools.jar check is now quoted.
    • A set but missing XDK_HOME is now an error, as on POSIX, instead of being silently ignored.
  • The POSIX launchers (Linux, macOS) did not check for a valid XDK. A bad XDK_HOME failed in Java with a missing main class. They now print the same "Unable to locate a valid XDK" message as Windows and exit 1.
  • javatools' tests depended on the xdk build.
    • TypeConstantL1SpecializationTest (from JIT milestone: virtual constructors, enums and more #671) loads the compiled ecstasy.xtc. To provide it, javatools' processTestResources consumed :xdk:lib-ecstasy, while the xdk build depends on javatools.
    • That worked only because no single task depends on itself, and because building the XTC plugin compiles javatools before the xdk build is configured. --task-graph does not show that edge.
    • The test now runs in the xdk build's tests, which consume the module inside the xdk build, so javatools no longer depends on the xdk build.
    • It moved to package org.xvm.xdk because javatools.jar is sealed and its packages cannot be extended from another location.
    • The configuration is registered instead of using the Kotlin DSL by configurations.creating delegate. Gradle 9.6 deprecated that delegate, and it produced three w: warnings in CI.
  • gradle.properties contained four keys that Gradle 9.8 does not read. I checked them against the property names in the 9.8.0 distribution.
    • org.gradle.configuration-cache-problems is a misspelling of org.gradle.configuration-cache.problems; this PR renames it.
    • configuration-cache.debug, .internal.report and .ignore-valid-build-scripts do not exist and are removed, together with their comments.
    • All four values were the defaults, so behavior is unchanged.

Stable features adopted

  • Configuration-cache compatibility declared to the Plugin Portal.
    • plugin/build.gradle.kts now has compatibility { features { configurationCache = true } } (plugin-publish 2.2.1).
    • Publishing without a declaration is deprecated, and the Portal plans to reject undeclared plugins.
    • ConfigurationCacheCompatibilityTest covers configuration-cache compatibility.
    • Isolated Projects compatibility is deliberately not declared: it is untested, and once declared it must be declared in every later release.
  • Wrapper download retries (Gradle 9.5): regenerated with ./gradlew wrapper --gradle-version 9.8.0 --retries 3. Only retries=0 → retries=3 changed; the wrapper scripts and jar are identical.
  • Stricter plugin validation in build-logic.
    • Since Gradle 9.4, validatePlugins is automatically strict for published plugins, and the XTC plugin already passes. All three build-logic builds now opt in too.
    • The five task types it flagged now declare their caching intent:
      • RunIdeEnvironmentReportTask, StartLogTailTask, StopLogTailTask: @UntrackedTask, replacing their equivalent doNotTrackState(...) init blocks;
      • DockerCleanupTask: @UntrackedTask, like the existing DockerTask;
      • ValidateCredentialsTask: @DisableCachingByDefault, like ValidateSnapshotBundleTask.
    • None of these tasks declares outputs, so behavior is unchanged.

Windows CI (manual dispatch, platforms=windows-latest)

Windows CI stays manual-dispatch only. Running it showed that master fails on Windows: the same tests failed in a dispatch on unchanged master (run 37285236577). The Windows failures this PR fixes:

  • SafeTarExtractor (security): File.canonicalFile does not resolve symbolic links on Windows, so an existing link inside the extraction directory could redirect an entry outside it. Escapes are now checked with Path.toRealPath() on the longest existing prefix of the target.
  • SafeTarExtractorTest: commons-compress's TarArchiveEntry constructor rewrites \ to / on Windows, so the backslash case never reached the extractor. The test now rebuilds such entries from their header, which keeps the exact name; I checked that technique separately with JShell.
  • BundlerTest, OptionsTest: the tests compared against hard-coded Unix path strings. They now expect the escaped quoted(...) form and the File.getPath() form that the code produces.
  • SourceSetWiringTest: Gradle's ProjectBuilder keeps files under the project directory open until the JVM exits, and Windows cannot delete open files. The test's @TempDir now ignores deletion failures (TempDirDeletionStrategy.IgnoreFailures; experimental in JUnit 6.1).
  • JIT startup: NativeTypeSystem built a Path from URL.getPath(), giving /D:/.../javatools.jar, an invalid Windows path, so every JIT run failed. It now uses Path.of(url.toURI()).
  • Ecstasy OS file system:
    • The problem: Ecstasy Path only splits on /, so a native Windows path became a single segment with no parent, and FileNode.parent asserted (TestFiles).
    • The fix: an OS file node's pathString is now in Path form, so the bridge parses it as before and is unchanged.
      • Paths on the current drive are rooted at / (D:\a\b becomes /a/b).
      • Other drives become a leading segment (C:\a becomes /C:/a).
    • Natives that receive path strings accept both forms.
    • Watcher events report directories in Path form, so they match the keys the watchers are registered under.
    • The certificate manager, the one other consumer that used pathString as an OS path, converts it back with xOSFileNode.toOsPath.
    • Visible change on Windows: an OS file's toString() shows /C:/a instead of C:\a. Nothing changes outside Windows.
    • The mapping is a string-only core (windowsToStorePath, storeToWindowsPath); toStorePath and toOsPath apply it on Windows only.
    • OsPathConversionTest tests that core on every OS, so each Linux build covers the Windows mapping, including these edge cases:
      • lowercase drive letters
      • roots without a drive
      • UNC and drive-relative paths
      • no current drive
      • /C:/ with a trailing separator
      • look-alikes such as /CC:/x
      • round trips
    • Its tests on real Windows paths stay Windows-only.
  • Launcher test: .github/scripts/test-launchers.sh runs in CI after the build. It unpacks the distribution zip into a path with spaces and runs xtc, xcc and xec: the POSIX scripts on Ubuntu, the .bat scripts on Windows.
    • It checks:
      • --version and --help
      • compiling and running, including passing an argument with spaces intact
      • non-zero exit codes for a failing module, a missing module and a compile error
      • JAVA_OPTS and XTC_OPTS
      • relative and (on POSIX) symlinked launchers
      • XDK_HOME set to this XDK, to another XDK, to a directory without an XDK and to a missing directory
      • a broken XDK
    • On Windows it runs each .bat as typed at a cmd.exe prompt, because other programs start batch files through cmd /c, which mangles a quoted batch path followed by quoted arguments.
  • Workflow: the plugin integration test downloads the consumer Maven repository that only the Ubuntu build uploads, so it always failed on a Windows-only dispatch. It is now skipped there, and the build-complete gate accepts that one skip.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • Documentation or formatting/non-functional change

Resolves/Fixes

  • None filed; found while reviewing the Gradle 9.2–9.8 release notes.

How Has This Been Tested?

  • Full build: ./gradlew build passes. Configuring the whole composite without the configuration cache, with lang and manualTests attached and --warning-mode=all, prints no deprecation warnings.
  • Plugin validation:
    • validatePlugins with stricter validation passes for :aggregator, :settings-plugins, :common-plugins and :plugin. I forced those runs with --rerun-tasks, because --rerun did not reliably rerun the build-logic tasks.
    • To confirm the setting is active, I temporarily removed the DockerCleanupTask annotation: the build fails on that type. With the annotation it passes.
  • Plugin tests (RUN_INTEGRATION_TESTS=true): 58 tests, 0 failures, 0 skipped.
  • Build-logic tests (:common-plugins:test, which includes ValidateCredentialsTaskTest): 44 tests, 0 failures.
  • Untracked tasks: :lang:intellij-plugin:runIdeInfo, startLspLogTail and stopLspLogTail execute on two consecutive runs, never reported as up to date. The configuration cache was stored and then reused.
  • :docker:cleanImages -PdryRun=true: takes the dry-run path.
  • Launchers: the launcher test passes on Ubuntu (all 21 checks) and Windows (all 20; the symlink check is POSIX-only). Run against a zip with javatools.jar removed, it fails, so it catches broken launchers.
  • Moved test:
    • ./gradlew :javatools:test --task-graph lists no :xdk: tasks.
    • In the xdk build, TypeConstantL1SpecializationTest runs 40 tests with 0 skipped.
    • CI logs have no Kotlin w: warnings.
  • Formatting: CI=true ./gradlew spotlessCheck :lang:spotlessCheck passes.
  • Windows: a dispatch with platforms=windows-latest on 7b9c52cae passes (run 37339839498). :javatools:test, :common-plugins:test, :plugin:test and the manual tests (including runJitTests, runSmallFloatsJit and runSequential) executed rather than coming from cache, and the integration test was skipped as intended. The Ubuntu PR run on the same commit passes, with its integration test still running.

Test Configuration:

  • Hardware/OS: macOS 27.0.1 (arm64), Gradle 9.8.0 wrapper, Java 25
  • Command line:
    • ./gradlew build
    • ./gradlew build --dry-run --no-configuration-cache --warning-mode=all -PincludeBuildLang=true -PincludeBuildAttachLang=true -PincludeBuildAttachManualTests=true
    • ./gradlew :aggregator:validatePlugins :settings-plugins:validatePlugins :common-plugins:validatePlugins --rerun-tasks --no-build-cache
    • RUN_INTEGRATION_TESTS=true ./gradlew :plugin:test --rerun-tasks --no-build-cache
    • ./gradlew :common-plugins:test --rerun-tasks --no-build-cache
    • CI=true ./gradlew spotlessCheck :lang:spotlessCheck -PincludeBuildLang=true -PincludeBuildAttachLang=true

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

@lagergren lagergren changed the title Fix Windows XDK launcher labels and adopt stable Gradle 9.x features Fix Windows XDK launcher labels and adopt stable Gradle 9.x features. Also fix broken JIT Paths for Windows. Oct 5, 2026
@lagergren
lagergren requested review from cpurdy, ggleyzer and thegridman and removed request for ggleyzer October 5, 2026 10:26
@lagergren lagergren changed the title Fix Windows XDK launcher labels and adopt stable Gradle 9.x features. Also fix broken JIT Paths for Windows. Fix broken Windows XDK launcher labels (script changed in Gradle 9.4), adopt stable Gradle 9.x features. Also fix broken JIT Paths for Windows. Oct 5, 2026
@lagergren
lagergren requested a review from ggleyzer October 5, 2026 16:58
@lagergren
lagergren force-pushed the gradle-9.8-fixes-and-stable-features branch from 7b9c52c to 232ad01 Compare October 5, 2026 17:33

@cpurdy cpurdy left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Pushed some small edits and made some notes (TODOs) for the future.

lagergren and others added 16 commits October 6, 2026 09:31
- Windows launchers: the XDK_HOME block jumped to the :end and :fail labels, which the Gradle 9.5 start-script template no longer has. Jump to :exitWithErrorLevel instead, exiting with 1 on the invalid-XDK path.
- gradle.properties: fix the org.gradle.configuration-cache.problems key (it was spelled configuration-cache-problems) and drop three configuration-cache keys Gradle does not read. All values were defaults.
- Declare configuration-cache compatibility for the XTC plugin to the Plugin Portal.
- Retry wrapper distribution downloads up to 3 times.
- Run validatePlugins with stricter validation in the build-logic builds, and declare caching intent on the five task types it flagged.
- SafeTarExtractor: check for escapes with Path.toRealPath on the longest existing prefix of the target. File.canonicalFile does not resolve symbolic links on Windows, so an existing link inside the extraction directory could redirect an entry outside it.
- SafeTarExtractorTest: TarArchiveEntry's constructor rewrites the platform separator to '/', so on Windows the backslash case never reached the extractor. Rebuild such entries from their header to keep the exact name.
- BundlerTest: the duplicate-selection error quotes the path as a string literal, so match the quoted form; Windows backslashes appear escaped.
- SourceSetWiringTest: ignore temp directory deletion failures; ProjectBuilder keeps cache files open until the JVM exits, and Windows cannot delete open files.
… form

On Windows, new File("/lib1").getPath() is "\lib1", so matching the literal "/lib1" failed.
- NativeTypeSystem: resolve the javatools location through URL.toURI(). The URL path "/D:/.../javatools.jar" is not a valid Windows path, so every JIT run failed at startup.
- OS file system: Ecstasy Paths only split on '/', so a native Windows path such as "C:\...\test.dat" became a single segment with no parent, and FileNode.parent asserted. OS file nodes now expose a storePathString in Path form, which the bridge parses: paths on the current drive are rooted at "/" ("D:\a\b" is "/a/b"), and other drives become a leading segment ("C:\a" is "/C:/a"). Natives that receive path strings accept both forms, and watcher events report directories in Path form so they match the keys the watchers are registered under. pathString stays native, and nothing changes outside Windows.
The integration test downloads the consumer Maven repository that only the Ubuntu build uploads, so a dispatch with platforms=windows-latest always failed it. Skip the job there, and let the build-complete gate accept that skip.
…etic

toStorePath and toOsPath now recognize "C:\" and "/C:/..." with the DRIVE_ROOT and DRIVE_STORE_PATH patterns, and use File.separator and a SEPARATOR constant instead of separator literals.
pathString now returns the path in the '/'-separated form of an Ecstasy Path, so the separate storePathString property is gone and the bridge is unchanged from master. The file system natives already accept that form; the certificate manager, the one other consumer that uses pathString as an OS path, now converts it with xOSFileNode.toOsPath. On Windows, an OS file's toString() shows the Path form ("/C:/a") instead of the native one ("C:\a"); nothing changes elsewhere.
- POSIX launchers (Linux, macOS): report "Unable to locate a valid XDK" and exit 1 when javatools.jar is missing, as the Windows launchers do, instead of failing in Java with a missing main class.
- Windows launchers: the XDK_HOME block set and read XDK_CMD, XDK_ID and APP_ID inside one parenthesized block, where cmd.exe expands variables when the block is parsed, so delegating to the launcher of another XDK never happened. Run one statement per line, compare against the .bat itself (%~nx0) rather than the extensionless POSIX script, quote the javatools.jar check so XDK paths with spaces work, and require a set XDK_HOME to name an XDK, as the POSIX launchers do.
test-launchers.sh unpacks the distribution zip into a path with spaces and runs xtc, xcc and xec: the POSIX scripts on Ubuntu, the .bat scripts on Windows (manual dispatch). It checks --version and --help, compiling, running, argument passing, failure exit codes, JAVA_OPTS and XTC_OPTS, relative and (POSIX) symlinked launchers, and XDK_HOME set to this XDK, another XDK, a directory without an XDK and a missing directory, and a broken XDK.
The mapping between Windows paths and the Path form is now a string-only core, windowsToStorePath and storeToWindowsPath, that takes the current drive as a parameter; toStorePath and toOsPath apply it on Windows only. The tests of the core run everywhere, so every Linux build covers the Windows mapping and its edge cases: lowercase drive letters, roots without a drive, UNC and drive-relative paths, no current drive, "/C:/" with a trailing separator, look-alikes such as "/CC:/x", and round trips. The tests on real Windows paths stay Windows-only.
Programs start a batch file through "cmd /c", which drops the quotes of a quoted batch path when quoted arguments follow, so on Windows every check that passed a path with spaces failed before the launcher started. The test now writes each command line to a .cmd file in a path without spaces and runs that, as a cmd.exe prompt would run the command.
cmd.exe ignores leading whitespace, so the one-statement-per-line block can keep the indentation of the nested ifs it replaced.
@lagergren
lagergren force-pushed the gradle-9.8-fixes-and-stable-features branch from d140d33 to cb20823 Compare October 6, 2026 07:31
…elegate

configurations.creating as a delegated property is deprecated since Gradle 9.6. Register the configuration, which also keeps it lazy.
The test loads the compiled ecstasy module, so javatools' test resources depended on :xdk:lib-ecstasy:compileXtc while the xdk build depends on javatools. That worked only because no task waits on itself, and because building the XTC plugin compiles javatools before the xdk build is configured, which the task graph does not show.

The xdk build already compiles ecstasy.xtc and has tests that depend on javatools, so the test now runs there: its processTestResources consumes the lib-ecstasy artifact within the xdk build, and javatools no longer depends on the xdk build at all. The test moves to package org.xvm.xdk because javatools.jar is sealed, so its packages cannot be extended from another location. The configuration is registered rather than created through the deprecated Kotlin DSL delegate.
@lagergren
lagergren merged commit 0149331 into master Oct 6, 2026
10 checks passed
@lagergren
lagergren deleted the gradle-9.8-fixes-and-stable-features branch October 6, 2026 08:19
lagergren added a commit that referenced this pull request Oct 26, 2026
gradle-upgrade.sh rewrites gradle-wrapper.properties after the wrapper
task, keeping the wrapper's own policy, but it read that policy from the
file the wrapper task had just written, with Gradle's defaults: an
upgrade to 9.8.2 turned retries=3, which #670 set, into retries=0. It
now reads the policy from a copy of the file taken before the wrapper
task runs.

Validation: bin/gradle-upgrade.sh 9.8.2 from master's wrapper files
keeps retries=3 and retryBackOffMs=500, and writes the same
gradle-wrapper.properties as Dependabot's #726; before the fix it wrote
retries=0. bash -n and --check pass.

Limits: none.
lagergren added a commit that referenced this pull request Oct 26, 2026
gradle-upgrade.sh rewrites gradle-wrapper.properties after the wrapper
task, keeping the wrapper's own policy, but it read that policy from the
file the wrapper task had just written, with Gradle's defaults: an
upgrade to 9.8.2 turned retries=3, which #670 set, into retries=0. It
now reads the policy from a copy of the file taken before the wrapper
task runs.

Validation: bin/gradle-upgrade.sh 9.8.2 from master's wrapper files
keeps retries=3 and retryBackOffMs=500, and writes the same
gradle-wrapper.properties as Dependabot's #726; before the fix it wrote
retries=0. bash -n and --check pass.

Limits: none.
lagergren added a commit that referenced this pull request Oct 26, 2026
gradle-upgrade.sh rewrites gradle-wrapper.properties after the wrapper
task, keeping the wrapper's own policy, but it read that policy from the
file the wrapper task had just written, with Gradle's defaults: an
upgrade to 9.8.2 turned retries=3, which #670 set, into retries=0. It
now reads the policy from a copy of the file taken before the wrapper
task runs.

Validation: bin/gradle-upgrade.sh 9.8.2 from master's wrapper files
keeps retries=3 and retryBackOffMs=500, and writes the same
gradle-wrapper.properties as Dependabot's #726; before the fix it wrote
retries=0. bash -n and --check pass.

Limits: none.
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.

3 participants