Java 将 ant 文件集回显到屏幕以进行调试
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3934309/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Echoing out ant fileset to screen for Debugging
提问by mainstringargs
I have this:
我有这个:
<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>
I want to echo out everything that is in the "build-path" reference (for debugging some things).
我想回显“构建路径”参考中的所有内容(用于调试某些内容)。
I have tried:
我试过了:
<echo>${build-path}</echo>
but it just echos that exact text "${build-path}"
但它只是回应那个确切的文本“${build-path}”
采纳答案by martin clayton
You can use the documented(honest, it's in there somewhere...) toString
helper:
您可以使用记录在案的(老实说,它在某处......)toString
助手:
<echo message="My build-path is ${toString:build-path}" />
回答by matt b
Enable ant's debug logging:
启用 ant 的调试日志记录:
$ ant -h
ant [options] [target [target2 [target3] ...]]
Options:
...
-verbose, -v be extra verbose
-debug, -d print debugging information
Note though that this will generate a ton of output, so it may be best to capture the output to a file and then find the fileset info in a text editor:
请注意,这将生成大量输出,因此最好将输出捕获到文件中,然后在文本编辑器中查找文件集信息:
ant -debug compile > ant-out.txt
回答by Frank
To debug what files are include in your fileset you can use this example, which prints the contents of a fileset in a readable format:
要调试文件集中包含哪些文件,您可以使用此示例,它以可读格式打印文件集的内容:
<?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>
Output of this is:
这个的输出是:
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
....