Gradle (in particular 4.x) and task progress

I have been trying out Gradle 4.0 with Grails… one thing that has historically confused users is that when you do gradle bootRun you get output like 85% EXECUTING. Even if the container is running. Gradle considers the build not complete until the bootRun task terminates. We have lived with it up until now but it is worse with Gradle 4.0 because now you get the seconds counter which is distracting

I was wondering if there was a way to feedback to Gradle that the build is complete instead of having this

<===========--> 85% EXECUTING [21m 18s]```

An API could be provided that allowed a task to mark progress as complete. This would avoid confusion for users of frameworks like Spring Boot and Grails. Thoughts?
1 Like

Thanks for this question @Graeme_Rocher1. The percentage and time are meant to be related to the build session in Gradle. The way we would typically solve this in the past is to detach the execution of the server running from the Gradle build session to let Gradle run to completion. I understand there is some drawback to this solution. For example, you won’t be able to simply Ctrl-C Gradle to exit the server. However, this would typically kill the daemon too which hurt your performance. What I would suggest is the following options:

Option #1: You have a task to start the server and another one to stop the server. The server is started in the background and Gradle has the knowledge to locate the server.

Option #2: Gradle opens a new prompt in the context of the server and detaches it from the build session. You can then close the server by closing the prompt.

I would be leaning toward option #1 as you can wire your tasks in such a way that it ensure the server is stopped when the build expect it and start it when required.

Feel free to ask more questions,


Thanks Graeme for the feedback.

I filed an issue for the very problem a couple weeks ago at — I also included a suggestion in there to show “WAITING” like we do for --continuous build.

What do you folks think of that?

I’ve opened, which I think is close to what Graeme is looking for. We want to be able to describe processes that Gradle can start, leave running and then optionally kill/wait for at the end of the build.

Thanks yes this looks like closest to my suggestion. It is very confusing for users when they see the EXECUTING message as they think the server hasn’t started. I think this would be a major improvement and impacts more than Grails (Play, Jetty plugin, Spring Boot, Tomcat plugin etc.)

We currently have this at the top of the backlog for Gradle 4.2.

Will reply when we’ve made progress.

One quick update for those following this. We don’t yet have a way to know which tasks are intended to execute indefinitely, so it seems that we’ll need to have task authors declare this information. We are considering a public API for this.

Just found this issue by updating to Grails 5. The annoying thing is not the 85% but the time that is being updated constantly in the terminal, so I can’t scroll up because the terminal goes down when that updates.

Unfortunately all linked and transitively linked issues are closed for staleness. :frowning:
Maybe try to get them reopened.
In the meantime, if really the progress indicator is your biggest concern, you could run with --console=plain or the according property. That will also kill colors in output, task output grouping, minimal output noise, but it will also kill the progress indicator completely.
If you still want to have the progress output during the build, you could build with rich console and then run with plain console, so that you have progress during build and then when you tell it to run, everything is up-to-date and only the running is done without progress and so on.

1 Like

yep, is just the time being updated forever in the terminal makes it scroll down on each update, basically for a dev session I have this in the terminal:

<===========–> 85% EXECUTING [4h 5m 36s]


the app was running for 4h while I was testing and the time updates each couple of seconds

Tried the console=plain but it seems the Grails CLI is not passing it to Gradle internally, I guess I’ll need to modify some Grails internal file to pass that to Gradle, maybe @Graeme_Rocher1 has an idea on how that works.

As a Grails user I only do: $ grails run-app

That builds and run the app, allowing code reloading when code gets modified.

Then either use the according Gradle property or system property, or don’t use the grails command but Gradle directly. According to Grails docs doing grails run-app is the same as executing the bootRun Gradle task and can be used interchangeably.

1 Like

@Vampire can you point me to the Grails docs you are referring to? In the run-app command docs I don’t see any reference to the bootRun task. Thanks!

Ref The Grails Framework 5.3.2

1 Like

This worked: ./gradlew bootRun --console=plain

The terminal is not updating anymore and I can scroll up to read the logs. thanks!

1 Like