简体   繁体   English

Gradle 构建后,Intellij Idea 未在消息工具窗口中显示错误

[英]Intellij Idea not showing errors in Message Tool Window after Gradle build

Intellij Idea 14.1.2, Gradle 2.3 Intellij Idea 14.1.2,Gradle 2.3

I have a project with few java subprojects.我有一个包含几个 java 子项目的项目。 Gradle builds works as expected but Intellij Idea does not capture the output of it and does not show the Messages Tool Window where you can click on the error and go to the source file. Gradle 构建按预期工作,但 Intellij Idea 没有捕获它的输出,也没有显示消息工具窗口,您可以在其中单击错误并转到源文件。

Steps to reproduce:重现步骤:

  1. Create new gradle project创建新的 gradle 项目
  2. Create new class with one method用一种方法创建新类
  3. Introduce intentionally one error故意引入一个错误
  4. Build using Gradle tool window使用 Gradle 工具窗口构建

Expected result: Message Tool window will show up showing the error.预期结果:消息工具窗口将显示错误。

Actual result: Output is shown in the Run tool window, but the Message window is not shown (it's menu item is not even active in View -> Tool windows)实际结果:输出显示在“运行”工具窗口中,但未显示“消息”窗口(它的菜单项在“视图”->“工具”窗口中甚至未处于活动状态)

I've tryed to reimport the project, to create it from scratch, searched Idea's settings, manipulated manually values in *.iml but with no success and I am running out of ideas.我尝试重新导入该项目,从头开始创建它,搜索 Idea 的设置,手动操作 *.iml 中的值但没有成功,而且我的想法已经用完了。

Any idea where I can find a setting that tells the IDE to direct output to the Messages window?知道在哪里可以找到告诉 IDE 将输出定向到“消息”窗口的设置吗?

In Intelij 16.2 I had this problem as well.在 Intelij 16.2 中,我也遇到了这个问题。 In the top left corner of the "Run" window there is an odd looking button that when you mouse over is labeled "Toggle tasks executions/text mode."在“运行”窗口的左上角有一个看起来很奇怪的按钮,当您将鼠标悬停在该按钮上时,该按钮被标记为“切换任务执行/文本模式”。 Click it and it will show you the output from the Gradle build instead of the steps in the task execution.单击它,它将显示 Gradle 构建的输出,而不是任务执行中的步骤。

I had this problem on IntelliJ 2017.1, as well.我在 IntelliJ 2017.1 上也遇到了这个问题。 The answer posted by BrianC on Aug 4 '16 helped me--however I found the button on the opposite side --on the left side of the Run window, therefore I am posting an image with the exact button. BrianC 于 2016 年 8 月 4 日发布的答案对我有帮助——但是我在“运行”窗口的左侧找到了相反的按钮,因此我发布了带有确切按钮的图像。

When you hover over this button, it says 'Toggle tasks executions / text mode'.当您将鼠标悬停在此按钮上时,它会显示“切换任务执行/文本模式”。 The image shows the button when selected.图像显示选择时的按钮。

“切换任务执行”按钮

Finally found the solution:终于找到了解决办法:

For some reason when creating gradle project or module Idea does not add automatically the java-gradle facet.出于某种原因,在创建 gradle 项目或模块时,Idea 不会自动添加 java-gradle facet。

In order to get the errors in the Message Tool window you will have to add it to your module(s) like this:为了在消息工具窗口中获取错误,您必须将其添加到您的模块中,如下所示:

File -> Project structure -> Facets

Click on the plus sign, select Java-gradle, select module, OK.点击加号,选择Java-gradle,选择module,OK。

Please note that if you start the build from the Gradle tool window (the right side pane) errors will not be shown in the Message window.请注意,如果您从 Gradle 工具窗口(右侧窗格)开始构建,则消息窗口中不会显示错误。 You will have to use the "normal" build in the IDE, eg Build -> Compile module .您必须在 IDE 中使用“正常”构建,例如Build -> Compile module

I had a very similar issue in 2019.2.* where if I had previous results in the run tool window and then did a gradle build and had errors, it would switch me to the run tool window instead of the build window.我在2019.2.*中遇到了一个非常相似的问题,如果我在运行工具窗口中有以前的结果,然后进行了 gradle 构建并出现错误,它会将我切换到运行工具窗口而不是构建窗口。 This looks to be fixed in 2019.3.* .这似乎已在2019.3.*修复。

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

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