Как отобразить все ресурсы, включенные в Groovy AntBuilder classpath? - PullRequest
1 голос
/ 10 мая 2011

Я использую Antovuilder от Groovy для создания Java-проекта. Происходит ошибка, когда отсутствуют классы, которые действительно должны быть включены. Я хочу распечатать каждый JAR / WAR, который включен в следующее закрытие classpath, но я не могу понять, как это сделать. Каждый раз, когда я пытался отобразить содержимое classpath, оно отображается как нулевое. Есть идеи как это сделать?

Для справки, вот задача сборки 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 }
   }
}

1 Ответ

3 голосов
/ 11 мая 2011

Вы можете определить путь к классам вне задачи javac как путь Ant.Затем вы можете сохранить получившийся объект org.apache.tools.ant.types.Path, получить его пути и распечатать их в System.out.В задаче javac вы можете ссылаться на classpath с помощью его 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")
    }
}
...