代码之家  ›  专栏  ›  技术社区  ›  mainstringargs

将Ant文件集回送到屏幕进行调试

  •  36
  • mainstringargs  · 技术社区  · 14 年前

    我有这个:

        <ivy:buildlist reference="build-path">
            <fileset dir="${root.dir}">
                <include name="*/build.xml" />
                <include name="controllers/*/build.xml" />
            </fileset>
        </ivy:buildlist>
    
    
        <subant buildpathref="build-path">
            <target name="jar.all" />
            <target name="publish-local" />
        </subant>
    

    我想要回显“构建路径”引用中的所有内容(用于调试某些内容)。

    我已经尝试过:

    <echo>${build-path}</echo>
    

    但它只是重复了确切的文本“$构建路径”

    3 回复  |  直到 14 年前
        1
  •  54
  •   martin clayton egrunin    14 年前

    你可以使用 documented (说实话,它就在那儿……) toString 帮手:

    <echo message="My build-path is ${toString:build-path}" />
    
        2
  •  23
  •   Frank    14 年前

    要调试文件集中包含的文件,可以使用此示例,该示例以可读格式打印文件集的内容:

    <?xml version="1.0" encoding="UTF-8"?>
    <project name="de.foo.ant" basedir=".">
    
    <!-- Print path manually -->
    <target name="print-path-manually" description="" >
        <path id="example.path">
            <fileset dir="${ant.library.dir}"/>
        </path>
    
        <!-- Format path -->
        <pathconvert pathsep="${line.separator}|   |-- "             
            property="echo.path.compile"             
            refid="example.path">
        </pathconvert>
        <echo>${echo.path.compile}</echo>
    </target>
    
    </project>
    

    其输出为:

    Buildfile: D:\Workspaces\IvyTutorial\de.foo.ant\prettyPrintPath.xml
    print-path-manually:
     [echo] D:\Programme\eclipse-rcp-helios-SR1-win32\eclipse\plugins\org.apache.ant_1.7.1.v20100518-1145\lib\ant-antlr.jar
     [echo] |   |-- D:\Programme\eclipse-rcp-helios-SR1-win32\eclipse\plugins\org.apache.ant_1.7.1.v20100518-1145\lib\ant-apache-bcel.jar
     [echo] |   |-- D:\Programme\eclipse-rcp-helios-SR1-win32\eclipse\plugins\org.apache.ant_1.7.1.v20100518-1145\lib\ant-apache-bsf.jar
     [echo] |   |-- D:\Programme\eclipse-rcp-helios-SR1-win32\eclipse\plugins\org.apache.ant_1.7.1.v20100518-1145\lib\ant-apache-log4j.jar
     [echo] |   |-- D:\Programme\eclipse-rcp-helios-SR1-win32\eclipse\plugins\org.apache.ant_1.7.1.v20100518-1145\lib\ant-apache-oro.jar
     [echo] |   |-- D:\Programme\eclipse-rcp-helios-SR1-win32\eclipse\plugins\org.apache.ant_1.7.1.v20100518-1145\lib\ant-apache-regexp.jar
     [echo] |   |-- D:\Programme\eclipse-rcp-helios-SR1-win32\eclipse\plugins\org.apache.ant_1.7.1.v20100518-1145\lib\ant-apache-resolver.jar
    ....
    
        3
  •  9
  •   matt b    14 年前

    启用Ant的调试日志记录:

    $ ant -h
    ant [options] [target [target2 [target3] ...]]
    Options:
    ...
      -verbose, -v           be extra verbose
      -debug, -d             print debugging information
    

    请注意,虽然这将生成大量输出,但最好将输出捕获到文件,然后在文本编辑器中查找文件集信息:

    ant -debug compile > ant-out.txt