Skip to content

For JDK9+, converts classpath JVM arguments into a file-based argument (support long paths on Windows)

License

Notifications You must be signed in to change notification settings

redocksoft/classpath-to-file-gradle-plugin

Repository files navigation

Classpath to File Gradle Plugin

Overview

When the classpath for a Gradle JavaExec or Test task is long, Windows command executions fail due to Windows path length limitations. The error usually seen in this case is CreateProcess error=206, The filename or extension is too long.

This plugin uses the capability of JDK9+ to pass the classpath to the JVM in an "argument file" instead (see java Command-Line Argument Files, thus avoiding the OS limitation.

In addition, this avoids modifying classloading or any other runtime behavior, which is not the case with other solutions such as ones that modify the classpath in the manifest. See:

This plugin takes inspiration from those plugins, but operates in a completely different way.

See this answer to How to set a long Java classpath in Windows? at StackOverflow for more details about this solution.

See this upstream Gradle issue about potentially providing a solution to this problem in Gradle core: gradle/gradle#1989. Hopefully an upstream solution to this will eliminate the need for this plugin.

Version Compatibility

  • Gradle 8.8+ (may work on earlier versions, but untested)

  • Java 8+.

⚠ Works only if configuration caching is disabled ⚠

Installation

Simply add:

plugins {
  id 'com.redock.classpathtofile' version '0.1.0'
}

to your build.

For more details, follow the steps described at the Gradle Plugin Portal page.

About

For JDK9+, converts classpath JVM arguments into a file-based argument (support long paths on Windows)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages