在通过Ant 运行javac
时,是否有任何清楚解释且简单的方法可以查看编译器输出?任务?
这是我的 javac
Ant 标签:
<javac srcdir="${myproject.src}" destdir="${myproject.class}">
<!-- ... -->
</javac>
这是我收到的唯一错误消息:
/path/to/build.xml:42: Compile failed; see the compiler error output for details.
问题是我不知道如何查看编译器错误输出了解详情...
一些可能有帮助的配置元素:
- Ant 1.6.5
- Windows 7 x64
- Java 1.6.0_20 x32
- 通过 Eclipse 启动目标
我知道关于 SO 有一些相关的已回答问题,但没有一个人真正回答了这个简单的问题:
- https://stackoverflow.com/a/1275552/1225328 : 我不能添加允许
compile
标签的特定库; - https://stackoverflow.com/a/1264622/1225328 :这管理 Ant 的输出,而不是编译器的输出;
- Compile failed; see the compiler error output for details : 太模糊,无法解决任何问题;
- Ant : Compile failed; see the compiler error output for details : 没有答案...
- 等等
最佳答案
我认为您正在寻找 verbose="true"
属性。
Asks the compiler for verbose output; defaults to no.
您已经在评论中提到这不会打印您的错误原因。好吧,我认为您的情况还发生了其他事情。我有一个示例项目,无论哪种方式都打印了我的错误原因。这是 verbose="false"
的输出:
[mkdir] Created dir: C:\Projects\MavenSandbox\target\classes
[javac] C:\Projects\MavenSandbox\mavensandbox.xml:284: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds
[javac] Compiling 3 source files to C:\Projects\MavenSandbox\target\classes
[javac] C:\Projects\MavenSandbox\src\main\java\com\sandbox\Sandbox.java:8: error: cannot find symbol
[javac] System.out.prinln("Hello, I\'m the best!");
[javac] ^
[javac] symbol: method prinln(String)
[javac] location: variable out of type PrintStream
[javac] 1 error
某些奇怪且特定于您的代码的东西导致了错误消息。你能创建一个重现错误的示例项目吗?
正如您所提到的, debug="true"
不是您要查找的属性。
Indicates whether source should be compiled with debug information; defaults to off. If set to off, -g:none will be passed on the command line for compilers that support it (for other compilers, no command line argument will be used). If set to true, the value of the debuglevel attribute determines the command line argument.
您知道何时获得堆栈跟踪并且其中包含行号吗?这就是 debug="true"
所做的。如果它关闭,您将不会获得行号。
关于java - 通过 Ant 任务运行 javac 时如何查看编译器输出?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17492022/