如何显示 Groovy AntBuilder 类路径中包含的所有资源?
我正在使用 Groovy 的 AntBuilder 来构建一个 Java 项目。如果缺少看起来确实应该包含的类,则会发生错误。我想打印出以下类路径闭包中包含的每个 JAR/WAR,但我不知道如何做到这一点。每次我尝试显示类路径的内容时,它都显示为空。关于如何做到这一点有什么想法吗?
作为参考,这里是 java 构建任务和类路径。这发生在 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 }
}
}
I am using Groovy's AntBuilder to build a Java project. An error is occurring where classes are missing that really look like they should be included. I want to print out every JAR/WAR that's included in the following classpath closure, but I can't figure out how to do that. Every time I've tried to display the contents of classpath, it shows up as null. Any ideas on how to do this?
For reference, here's the java build task and the classpath. This occurs within a new AntBuilder().with { }
closure.
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 }
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以将 javac 任务外部的类路径定义为 Ant 路径。然后,您可以保存生成的 org.apache.tools.ant.types.Path 对象以获取其路径条目并将其打印到 System.out。在 javac 任务中,您可以通过其 refid 引用类路径:
You could define the classpath outside the javac task as an Ant path. Then you can save the resulting
org.apache.tools.ant.types.Path
object to get its path entries and print them to System.out. Within the javac task you can reference the classpath with its refid: