繁体   English   中英

如何显示Groovy AntBuilder类路径中包含的所有资源?

[英]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.

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