java Ant 无法构建:“编译失败;有关详细信息,请参阅编译器错误输出。”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14874172/
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
Ant fails to build:"Compile failed; see the compiler error output for details."
提问by Dzmitry Kashlach
I have the same problem as in this two questions:
我有与这两个问题相同的问题:
I've detected which line of code causes this issue.
我已经检测到哪一行代码导致了这个问题。
org.apache.jmeter.protocol.http.proxy.gui.ProxyControlGui proxyControlGui =
new org.apache.jmeter.protocol.http.proxy.gui.ProxyControlGui();
This string is used in:
该字符串用于:
package org.apache.jmeter;
public class JMeter implements JMeterPlugin {
ProxyControlGUI
代理控制GUI
package org.apache.jmeter.protocol.http.proxy.gui;
public class ProxyControlGui extends LogicControllerGui implements JMeterGUIComponent, ActionListener, ItemListener, KeyListener, UnsharedComponent
If I comment this string - build is successful.
Compiler does not complain during developing in IDE.
如果我评论这个字符串 - 构建成功。
编译器在 IDE 中开发期间不会抱怨。
I need to know:
我需要知道:
- what's the reason of such behavior?
- where to see log with details(I'm new with ant)?
- how rewrite code to avoid javac error?
- 这种行为的原因是什么?
- 在哪里可以看到带有详细信息的日志(我是蚂蚁的新手)?
- 如何重写代码以避免javac错误?
Log from running ant in CL:
在 CL 中运行 ant 的日志:
Buildfile: D:\src\apache-jmeter-custom\build.xml
compile-core:
[javac] Compiling 1 source file to D:\src\apache-jmeter-custom\build\core
[javac] warning: [options] bootstrap class path not set in conjunction with -source 1.6
[javac] D:\src\apache-jmeter-custom\src\core\org\apache\jmeter\JMeter.java:360: error: package org.apache.jmeter.protocol.http.proxy.gui does not exist
[javac] org.apache.jmeter.protocol.http.proxy.gui.ProxyControlGui proxyControlGui =
[javac] ^
[javac] D:\src\apache-jmeter-custom\src\core\org\apache\jmeter\JMeter.java:361: error: package org.apache.jmeter.protocol.http.proxy.gui does not exist
[javac] new org.apache.jmeter.protocol.http.proxy.gui.ProxyControlGui();
[javac] ^
[javac] 2 errors
[javac] 1 warning
Ant log from IDEA:
来自 IDEA 的 Ant 日志:
Compiling 1 source file to D:\src\apache-jmeter-custom\build\core
: [options] bootstrap class path not set in conjunction with -source 1.6
D:\src\apache-jmeter-custom\src\core\org\apache\jmeter\JMeter.java (360:58)error: package org.apache.jmeter.protocol.http.proxy.gui does not exist
D:\src\apache-jmeter-custom\src\core\org\apache\jmeter\JMeter.java (361:70)error: package org.apache.jmeter.protocol.http.proxy.gui does not exist
2 errors
1 warning
Thanks in advance.
提前致谢。
回答by aksappy
Ant is a build tool which looks up the dependencies which we specify in the ivy.xml and uses a script to compile the sources after loading the dependencies into the classpath. If there is a compiler failure during your ant script and IDE is not showing an error, the probable reason is that the jar required for building the class is available in the IDE build path and not in the Ant IVY.xml.
Ant 是一个构建工具,它查找我们在 ivy.xml 中指定的依赖项,并在将依赖项加载到类路径后使用脚本来编译源代码。如果在您的 ant 脚本期间编译器失败并且 IDE 没有显示错误,可能的原因是构建类所需的 jar 在 IDE 构建路径中可用,而不是在 Ant IVY.xml 中。