简体   繁体   English

我如何在 gradle 中打印出 JAVA 类路径?

[英]How do i print out the JAVA classpath in gradle?

I am currently using gradle integration with ecplise.我目前正在使用与 ecplise 的 gradle 集成。 Is there a way to print out the classpath of a javaexec task?有没有办法打印出 javaexec 任务的类路径?

The simplest would be to set log level to info using --info最简单的方法是使用--info将日志级别设置为 info

If you would like to not browse through the output you could add a line similar to this inside your JavaExec task如果您不想浏览输出,可以在 JavaExec 任务中添加与此类似的行

doFirst{
  sourceSets.main.runtimeClasspath.each { println it}
}
sourceSets.main.compileClasspath.asPath

对于打印,您可以在任务中的行下方写下:

println "Classpath = ${sourceSets.main.compileClasspath.asPath}";

使用 gradle v4 我无法使上述任一选项起作用,但是使用--debuggrep classpath确实找到了信息。

或者将build.gradle println configurations.runtime.resolve()添加到你的build.gradle

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM