简体   繁体   English

所有警告都是Eclipse Java编译器(3.6.2)的错误

[英]All warnings as errors with the Eclipse Java compiler (3.6.2)

How do I treat warnings as errors with the Eclipse Java compiler (ECJ) 3.6.2 * when running from the command-line ? 从命令行运行时,如何使用Eclipse Java编译器(ECJ)3.6.2 *将警告视为错误?

Newer versions (at least, 3.8.2) have the -err:all flag, however this isn't available in 3.6.2. 较新的版本(至少3.8.2)具有-err:all标志,但是在3.6.2中不可用。 Do I have any other options? 我还有其他选择吗?

I've found this question ( Javac: Treat warnings as errors ) which recommends the undocumented -Werror flag, but that only seems to work for javac. 我发现了这个问题( Javac:将警告视为错误 ),它建议使用未记录的-Werror标志,但这似乎仅适用于javac。

Note: For various reasons completely out of my control, I must use ECJ 3.6.2. 注意:由于种种原因,我完全无法控制,我必须使用ECJ 3.6.2。 So switching to a newer version or javac is not an option (at least, not in the immediate future)! 因此,切换到较新版本或javac是不可行的(至少不是在不久的将来)!


* Also seems to be known as the "JDT Core Batch Compiler" . *也似乎被称为“ JDT Core Batch编译器”

I don't think there's a way to specify err:all, but there's a decent workaround: 我认为没有办法指定err:all,但是有一个不错的解决方法:

  1. Create an eclipse project. 创建一个蚀项目。
  2. Project > Properties > Java Compiler > Errors / Warnings. 项目>属性> Java编译器>错误/警告。
  3. Enable project specific settings. 启用项目特定的设置。
  4. Set everything to Error level by hand (annoying, but a one time operation). 手动将所有内容设置为错误级别(烦人,但一次性操作)。
  5. That generates a org.eclipse.jdt.core.prefs file. 生成一个org.eclipse.jdt.core.prefs文件。
  6. Use the project/.settings/org.eclipse.jdt.core.prefs file in your compile process. 在编译过程中使用project / .settings / org.eclipse.jdt.core.prefs文件。

Here's an example using ant: 这是使用ant的示例:

<javac srcdir="${test-unit.dir}" destdir="${target-test-classes.dir}" 
        classpathref="test.classpath" source="1.6" target="1.6" debug="true" 
        includeAntRuntime="false" compiler="org.eclipse.jdt.core.JDTCompilerAdapter">
    <compilerclasspath location="./libs/ecj-3.7.2.jar" />
    <compilerarg line="-time -properties .settings/org.eclipse.jdt.core.prefs" />
</javac> 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM