Reputation: 355
I am currently using gradle integration with ecplise. Is there a way to print out the classpath of a javaexec task?
Upvotes: 20
Views: 29319
Reputation: 100756
I add this task to all my gradle projects (build.gradle.kts
syntax below):
tasks.register("saveClassPathToFile") {
doFirst {
File("classpath.txt").writeText(sourceSets["main"].runtimeClasspath.asPath)
}
}
Then in the shell:
$ ./gradlew saveClassPathToFile
$ export CLASSPATH=`cat classpath.txt`
$ java com.example.MyEntryPoint
...
Upvotes: 2
Reputation: 1442
You can use gradle/gradlew command for that:
./gradlew dependencies --configuration compileClasspath
or for the runtime classpath:
./gradlew dependencies --configuration runtimeClasspath
Upvotes: 3
Reputation: 299
sourceSets.main.compileClasspath.asPath
For printing, you can write below the line in your task:
println "Classpath = ${sourceSets.main.compileClasspath.asPath}";
Upvotes: 11
Reputation: 15199
With gradle v4 I was unable to get either of the above options to work, but using --debug
and grep classpath
did find the information.
Upvotes: 3
Reputation: 11192
Or add println configurations.runtime.resolve()
to your build.gradle
.
Upvotes: 3
Reputation: 1422
The simplest would be to set log level to info using --info
If you would like to not browse through the output you could add a line similar to this inside your JavaExec task
doFirst{
sourceSets.main.runtimeClasspath.each { println it}
}
Upvotes: 17