所有警告与Eclipse Java编译器(3.6.2)的错误一样 [英] All warnings as errors with the Eclipse Java compiler (3.6.2)

查看:242
本文介绍了所有警告与Eclipse Java编译器(3.6.2)的错误一样的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在命令行运行时,如何使用Eclipse Java编译器(ECJ)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?

较新版本(至少3.8.2)具有 -err:all 标志,但是这是不可用于3.6.2。我有其他选择吗?

Newer versions (at least, 3.8.2) have the -err:all flag, however this isn't available in 3.6.2. Do I have any other options?

我发现了这个问题( Javac:将警告视为错误 ),它建议使用未记录的 -Werror 标志,但只是似乎为了工作javac。

I've found this question (Javac: Treat warnings as errors) which recommends the undocumented -Werror flag, but that only seems to work for javac.

注意:由于各种原因完全无法控制,我必须使用ECJ 3.6.2。因此,切换到较新版本或javac不是一个选项(至少在不久的将来)!

Note: For various reasons completely out of my control, I must use ECJ 3.6.2. So switching to a newer version or javac is not an option (at least, not in the immediate future)!



*另外似乎被称为JDT核心批量编译器

推荐答案

我不认为有办法指定err:all,解决方案:

I don't think there's a way to specify err:all, but there's a decent workaround:


  1. 创建一个eclipse项目。

  2. 项目>属性> Java编译器>错误/警告。

  3. 启用项目特定的设置。

  4. 将所有内容设置为错误级别(烦人,但一次性操作)

  5. 生成一个org.eclipse.jdt.core.prefs文件。

  6. 使用project / .settings / org.eclipse.jdt.core.prefs文件您的编译过程。

  1. Create an eclipse project.
  2. Project > Properties > Java Compiler > Errors / Warnings.
  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.
  6. Use the project/.settings/org.eclipse.jdt.core.prefs file in your compile process.

以下是使用蚂蚁的示例:

Here's an example using 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> 

这篇关于所有警告与Eclipse Java编译器(3.6.2)的错误一样的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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