1

I have server application that I run using gradle bootRun.

I also have script runUpdate.sh that I need to run from command line of terminal after application is started.

I created gradle task that run this script:

task runUpdate(type: Exec) {
    commandLine './runUpdate.sh'
}

Now I want to run this script from bootRun automatically. With no need to execute additional step manually. How can I do it?

Jacob
  • 1,135
  • 5
  • 14
  • 29

2 Answers2

0

I'm using this the command shouldRunAfter to define that my task run before the bootRun

task runUpdate(type: Exec) {
    commandLine './runUpdate.sh'
}

// This will set te bootRun to wait your task run first
bootRun.configure {
    shouldRunAfter runUpdate
}
H.Cley
  • 1
-3

https://docs.gradle.org/current/userguide/more_about_tasks.html

you can use gradle dependsOn here is a sample code

bootRun{
  dependsOn runUpdate
}
task runUpdate(type: Exec) {
    commandLine './runUpdate.sh'
}
  • 1
    In this case runUpdate will run first. Right? I need it will run when server is up. Can I put dependsOn bootRun into runUpdate? – Jacob Nov 21 '17 at 04:20
  • 2
    Yes, `runUpdate` will run first. @Jacob, what you need is `finalizedBy`. – Opal Nov 21 '17 at 07:08