1

Groovy の AntBuilder を使用して Java プロジェクトを構築しています。実際には含まれているように見えるクラスが欠落しているというエラーが発生しています。次のクラスパス クロージャに含まれるすべての JAR/WAR を出力したいのですが、その方法がわかりません。クラスパスの内容を表示しようとするたびに、null として表示されます。これを行う方法についてのアイデアはありますか?

参考までに、ここに 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 }
   }
}
4

1 に答える 1

3

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")
    }
}
于 2011-05-10T21:01:13.073 に答える