Home > database >  Gradle exec commandline does not report mysql syntax error
Gradle exec commandline does not report mysql syntax error

Time:10-28

Gradle exec commandline does not report mysql syntax error.

task runSQL(type: Exec) {
    commandLine 'cmd', '/c', 'mysql -u root -p123456 db1 < /path/db1.sql'

}

gradle runSQL

The db1.sql has syntax error. But the build is successful without reporting any error.

CodePudding user response:

That is because mysql is returning as exit code -1, but cmd is not forwarding that. You can get around this by calling mysql directly:

commandLine 'mysql', '-u', 'root', '-p123456', 'db1', '<', '/path/db1.sql'

But mysql might be only in your cmd path. Then you would need to write the absolute path to the mysql binary.

  • Related