How to get console logs for Gradle projects?

Answered

Hello,

Hope you are doing well and healthy.

I wrote a plugin which reads the logs from the console. Currently, it works very well for the Maven projects. Unfortunately, I cannot say the same thing for Gradle. Logging part is simple and can be found here.

When the plugin tries to catch a log from a Gradle project, the plugin throws an error;

Exception in thread "DisconnectableInputStream source reader" org.gradle.api.UncheckedIOException: java.nio.channels.AsynchronousCloseException
    at org.gradle.internal.UncheckedException.throwAsUncheckedException(UncheckedException.java:62)
    at org.gradle.internal.UncheckedException.throwAsUncheckedException(UncheckedException.java:41)
    at org.gradle.util.internal.DisconnectableInputStream$1.run(DisconnectableInputStream.java:127)
    at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: java.nio.channels.AsynchronousCloseException
    at java.base/java.nio.channels.spi.AbstractInterruptibleChannel.end(AbstractInterruptibleChannel.java:202)
    at java.base/sun.nio.ch.SourceChannelImpl.endRead(SourceChannelImpl.java:241)
    at java.base/sun.nio.ch.SourceChannelImpl.read(SourceChannelImpl.java:259)
    at java.base/sun.nio.ch.ChannelInputStream.read(ChannelInputStream.java:59)
    at java.base/sun.nio.ch.ChannelInputStream.read(ChannelInputStream.java:107)
    at java.base/sun.nio.ch.ChannelInputStream.read(ChannelInputStream.java:101)
    at java.base/java.io.BufferedInputStream.read1(BufferedInputStream.java:290)
    at java.base/java.io.BufferedInputStream.read(BufferedInputStream.java:351)
    at org.gradle.util.internal.DisconnectableInputStream$1.run(DisconnectableInputStream.java:98)
    ... 1 more

Thanks in advance and have a great day.

Greetings 👋🏼

0
6 comments

Hi Yusuf,

Could you please provide more details?

It would be perfect if you can provide the minimal project this issue occurs in and instructions on how to reproduce it.

0

Hi Karol 👋🏼

Thanks for your answer. 

To reproduce that, please follow the below steps;

  1. Download a simple Gradle project from https://start.spring.io
  2. Run the plugin on IntelliJ
  3. Open the simple Gradle project on the IntelliJ instance, which is run via the plugin
  4. Check the plugin logs, and you will see the exact error message

If you download a simple Maven project from https://start.spring.io, it works like a charm without any errors.

I am looking forward to hearing your opinion.

Greetings 👋🏼

0

Hi Yusuf,

I cannot reproduce it locally and found this issue which contains exactly the same stacktrace as you pasted:
https://youtrack.jetbrains.com/issue/IDEA-285690

Could you please check it with the 2021.3.1 or newer?

0

Hi Karol,

Thanks again for the reply.

That is really strange that you can't reproduce. One of my plugin user reported that to me, and after that I confirmed that is not working for Gradle projects.

I use IntelliJ 2021.3.2 and also updated the plugin `platformVersion` to 2021.3.2. In both platforms I still have the same issue. BTW. I forgot to say you should run the simple Gradle project. So correct order would be;

  1. Download a simple Gradle project from https://start.spring.io
  2. Run the plugin on IntelliJ
  3. Open the simple Gradle project on the IntelliJ instance, which is run via the plugin
  4. Run the simple Gradle project
  5. Check the plugin logs, and you will see the exact error message

How can you support me? Can we make a video call?

Have a nice weekend in advance.

Greetings 👋🏼

0

Hi Yusuf,

I run the "bootRun" Gradle task - is it fine?

I still don't have any errors related to Gradle logs. I'm running it on macOS, maybe this affects other OS?

Your plugin code seems fine. I suggest opening an issue in https://youtrack.jetbrains.com/issues/IDEA as it seems to be a product issue.

0

Thanks Karol, it is reported here.

0

Please sign in to leave a comment.