通过 Ant 任务运行 javac 时如何查看编译器输出? [英] How to see the compiler output when running javac through an Ant task?

查看:36
本文介绍了通过 Ant 任务运行 javac 时如何查看编译器输出?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在通过 javac 时,是否有任何明确解释和简单的方法来查看编译器输出>Ant 任务?

Is there any clearly explained and simple way to see the compiler output when running javac through an Ant task?

这是我的 javac Ant 标签:

Here is my javac Ant tag:

<javac srcdir="${myproject.src}" destdir="${myproject.class}">
    <!-- ... -->
</javac>

这是我收到的唯一错误消息:

Here is the only error message I get:

/path/to/build.xml:42: Compile failed; see the compiler error output for details.

问题是我不知道如何查看编译器错误输出的详细信息...

The problem is that I don't know how to see the compiler error output for details...

几个可能有用的配置元素:

Few configuration elements that may help:

  • 蚂蚁 1.6.5
  • Windows 7 x64
  • Java 1.6.0_20 x32
  • 通过 Eclipse 启动目标

我知道在 SO 上有一些相关的已回答问题,但没有一个能真正回答这个简单的问题:

I know there are some related answered questions on SO, but none of them really answers this simple questions:

  • https://stackoverflow.com/a/1275552/1225328: I can't add the specific library that allows the compile tag;
  • https://stackoverflow.com/a/1264622/1225328: this manages Ant's output rather than the compiler's one;
  • Compile failed; see the compiler error output for details: too vague to solve anything;
  • Ant : Compile failed; see the compiler error output for details: no answer...
  • etc.

推荐答案

我认为您正在寻找 verbose="true" 属性.

I think you're looking for the verbose="true" attribute.

向编译器询问详细输出;默认为否.

Asks the compiler for verbose output; defaults to no.

您已经在评论中提到这不会打印您的错误原因.好吧,我认为你的情况还有其他事情发生.我有一个示例项目,无论哪种方式都打印了我的错误原因.这是带有 verbose="false" 的输出:

You already mentioned in the comments that this doesn't print the cause of your error. Well I think something else is going on in your situation. I have a sample project and either way the cause of my error was printed. Here's the output with 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

您的代码有一些奇怪和特定的东西导致了错误的错误消息.你能创建一个重现错误的示例项目吗?

Something strange and specific to your code is causing the bad error message. Can you create a sample project that reproduces the error?

正如您所提到的,debug="true" 不是您要查找的属性.

As you mentioned, debug="true" is not the attribute you're looking for.

指示是否应使用调试信息编译源代码;默认为关闭.如果设置为 off, -g:none 将在支持它的编译器的命令行上传递(对于其他编译器,将不使用命令行参数).如果设置为 true,则 debuglevel 属性的值决定命令行参数.

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" 所做的.如果它关闭,你不会得到行号.

You know when you get stack trace and it has line numbers in it? That's what debug="true" does. If it's off, you don't get line numbers.

这篇关于通过 Ant 任务运行 javac 时如何查看编译器输出?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆