Output the classpath string of dependencies for a Gradle project.
Unlike Maven, which provides dependency:build-classpath, Gradle doesn't offer a standard task for outputting the classpath of a project. The goal of this project is to provide that missing functionality in a simple command-line utility which behaves much like Maven's.
This Gradle classpath utility is used by the coc-groovy project.
- Java (version 1.8.0 or later)
This is the easiest way to get started.
Download the latest package from the Releases page and then extract the download.
Be sure to add the location of the gradle-classpath/bin
directory to your $PATH
.
See Building
Be sure to add the location of the build/install/gradle-classpath/bin/
directory to your $PATH
.
In its simplest form gradle-classpath
can be called like this to output the classpath of a Gradle project.
$ cd {your Gradle project directory}
$ gradle-classpath
Or the classpath can be written to a file.
$ cd {your Gradle project directory}
$ gradle-classpath --output-file classpath.txt
Or display the gradle-classpath
full usage details.
$ gradle-classpath --help
Usage: gradle-classpath [-hrV] [-d=<projectPath>] [-g=<gradleUserHomeDir>]
[-G=<gradleHome>] [-o=<outputFile>] [-s=<pathSeparator>]
Outputs the Gradle classpath to a file or STDOUT.
-d, --project-dir=<projectPath>
Path to the Gradle project. Defaults to the current
directory.
-g, --gradle-user-home=<gradleUserHomeDir>
Specifies the Gradle user home directory. Defaults to
~/.gradle.
-G, --gradle-home=<gradleHome>
Specifies the Gradle installation directory to use.
Defaults to a project-specific Gradle version.
-h, --help Show this help message and exit.
-o, --output-file=<outputFile>
Write the classpath to this file. If undefined, the
output is sent to STDOUT.
-r, --regenerate-file If 'true' it always regenerates the classpath file.
If 'false' it is not regenerated if it exists.
Defaults to 'false'
-s, --path-separator=<pathSeparator>
The character used between paths. Defaults to ':'
-V, --version Print version information and exit.
-
Clone this project and run the Gradle install task.
$ git clone https://github.com/dansomething/gradle-classpath.git $ cd gradle-classpath $ ./gradlew installDist
-
Look in
build/install/gradle-classpath
for the output.
-
Debug gradle-classpath on itself.
$ ./gradlew run --debug-jvm
-
Set breakpoints.
-
Attach a Java debugger client to port 5005.
-
Run gradle-classpath on itself.
$ ./gradlew run
-
Run gradle-classpath on itself and write the results to a file.
./gradlew run --args='-o classpath.txt'