Wait for "launch before" task
Answered
We do build a web application using gradle as build tool and wildfly as application server.
I've configured my Run-Configuration to deploy the war-file to the given Wildfly server. This is done by declaring an external source.
In the "Before launch"-section I've added a link to my war-gradle task.
What happens is, that the deployment and the before launch task start in parallel. This means that the deployment does never deploy the war file just build. it deploys the old one which hangs around in the build output directory...
How can I configure my build configuration to wait for the "Before-launch"-Tasks to be finished?
Please sign in to leave a comment.
It should wait for the task completion unless the deployment is performed in a forked VM.
It does wait when using "Restart" instead of "Redeploy" in the "Update Wildfly"-Dialog...
Before launch tasks are not performed before redeploy.
They are performed, but in parallel to the deployment!
You are right, there is even an open bug: https://youtrack.jetbrains.com/issue/IDEA-95968.
Ou wow, a bug from 2012... guess it will not be fixed soon :-/
Ok, then the question, what is the proposed solution for this? I do want to build my app with my gradle build script. Do I always have to perform a complete server restart?
I'm still waiting for somebody to fix this bug :)
As I understand war-gradle process finishes just after it start some 'forked' process so we cannot detect actual 'task completion' moment. It shouldn't fork to work correctly in 'before run' queue.
Does that mean, that building a war in before-launch is not possible at the moment?
No. You should be able to use gradle task which builds the war-file w/o 'forked' process. Just checked the case using built-in War task, see details at https://docs.gradle.org/current/userguide/war_plugin.html#sec:war_default_settings
If you use your own custom task which creates the war file, please, make sure it correctly reports the process exit status code and does not delegate the actual work to another process.
No, it definitely doesn't. I've just checked a simple case with default war task and it works perfectly (Run Configurations won't start until gradle finished and doesn't start at all if some exceptions are occured in gradle task).
This is just not the case in my environment.. here my gradle:
The testConfig waits just an amount of time to make sure you can see, that the deployment starts before the build finished.
My Current Build-COnfiguration has just one "Before launch" Task and this is a Reference onto the Gradle war-task.
Case Redeploy:
- Click the Debug Button
- Choose Redeploy
- OK
=> Deployment starts immediately / Build finishes after deployment => NOT OK
Case Restart Server:
- Click the Debug Button
- Choose Restart Server
- OK
=> Gradle war task is executed, as soon as it finished, the Server starts with the newly build war file. => OK