I need to execute an SQL script on a remote database in Gradle (Version 4.2.1). So I tried it with the Exec task. The task works, when the database is on my local machine. With a remote host the task is not starting.
These are the tasks (the first one works perfectly).
task psqlLocalExec(type: Exec) {
commandLine 'cmd', '/c', 'psql -f myscript.sql'
}
task psqlRemoteExec(type: Exec) {
commandLine 'cmd', '/c', 'psql -h my.remote.host -f myscript.sql' // not working
}
The command line output (I cancelled it after some minutes):
C:\myproject>gradlew :proj:psqlRemoteExec --stacktrace
<-------------> 0% EXECUTING [3m 43s]
> :proj:psqlRemoteExec
On cmd (without Gradle) the command works.