[英]How to display all resources included in a Groovy AntBuilder classpath?
我正在使用Groovy的AntBuilder來構建Java項目。 在缺少看起來確實應該包含類的類時發生錯誤。 我想打印出以下類路徑閉包中包含的每個JAR / WAR,但我不知道該怎么做。 每次嘗試顯示classpath的內容時,它都會顯示為null。 有關如何執行此操作的任何想法?
供參考,這里是Java構建任務和類路徑。 這發生在new AntBuilder().with { }
閉包的new AntBuilder().with { }
。
javac srcdir: sourceDir, destdir: destDir, debug: true, target: 1.6, fork: true, executable: getCompiler(), {
classpath {
libDirs.each { dir -> fileset dir: dir, includes: "*.jar,*.war" }
websphereLib.each { dir -> fileset dir: dir, includes: "*.jar*" }
if (springLib.exists()) { fileset dir: springLib, includes: "*.jar*" }
was_plugins_compile.each { pathelement location: was_plugins_dir + it }
if (webinf.exists()) { fileset dir: webinf, includes: "*.jar" }
if (webinfclasses.exists()) { pathelement location: webinfclasses }
}
}
您可以將javac任務外部的類路徑定義為Ant路徑。 然后,您可以保存生成的org.apache.tools.ant.types.Path
對象以獲取其路徑條目並將其打印到System.out。 在javac任務中,您可以使用其refid引用類路徑:
new AntBuilder ().with {
compileClasspath = path(id: "compile.classpath") {
fileset(dir: "libs") {
include(name: "**/*.jar")
}
}
// print the classpath entries to System.out
compileClasspath.list().each { println it }
javac (...) {
classpath (refid: "compile.classpath")
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.