如何找出当 SBT 说“javac 返回非零退出代码"时发生了什么? [英] How to find out what happened when SBT says "javac returned nonzero exit code"?

查看:95
本文介绍了如何找出当 SBT 说“javac 返回非零退出代码"时发生了什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将我们的项目转移到 Java 8.当我运行编译时,我得到了这个:

I'm trying to move our projects to Java 8. When I run a compile I get this:

[error] (MyProject/compile:compileIncremental) javac returned nonzero exit code

Java 7 不会发生这种情况.我怀疑这与我们使用 Lombok 有关.

This doesn't happen with Java 7. I suspect it's something to do with us using Lombok.

有什么办法可以从 javac 得到实际的输出?我试过last"和lastgrep",但我只看到 SBT 日志.

Is there any way to get the actual output from the javac? I've tried "last" and "lastgrep" but I only see SBT logs.

我使用的是 SBT 0.13.8

I'm using SBT 0.13.8

谢谢.阿什利

推荐答案

当设置了 javaHome 设置时,sbt 通过 fork 进程调用 javac,并尝试进行屏幕抓取输出中的错误消息,这很容易出错.sbt 1.2.0-RC3 改进了一点,但它是一个 hack.

When javaHome setting is set, sbt calls javac by forking the process, and attempts to screen scrape the error message out of the output, which is error-prone. sbt 1.2.0-RC3 improves it a bit, but it's a hack.

避免这种情况的一种方法是确保将 javaHome 设置设为 None.大约 2015 年 sbt-extras 用于从 JAVA_HOME 环境变量中悄悄设置 javaHome,但我认为自 2016 年以来它已在 https://github.com/paulp/sbt-extras/pull/160.由于这个问题是在 2015 年 6 月提出的,也许这就是当时的问题.如果您使用的是 sbt-extras,请更新到最新版本.

One way to avoid that is to make sure javaHome setting is set to None. Around 2015 sbt-extras used to set javaHome quietly from JAVA_HOME environment variable, but I think that's been dropped since 2016 in https://github.com/paulp/sbt-extras/pull/160. Since this question was asked in June 2015, maybe that's what it was hitting at the time. If you're using sbt-extras, please update to the latest.

Parag 的答案/观察可能会进一步支持这一点:

This might be further supported by Parag's answer/observation:

当我删除 .bash_profile 中的 JAVA_HOME 变量然后重新启动终端时,错误消息在我的 Mac 上消失了.

The error message disappeared on my Mac when I removed the JAVA_HOME variable in .bash_profile and then restarting Terminal.

如果您继续使用 sbt 1.x 看到此问题,请在 https://github.com/sbt/zinc/issues/520

If you continue to see this issue using sbt 1.x, please report on https://github.com/sbt/zinc/issues/520

这篇关于如何找出当 SBT 说“javac 返回非零退出代码"时发生了什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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