Gradle/SQL - Building Stuck at 0%


I have the following code which the purpose is to find any sql script within the same folder and sub-folder of the build.gradle. So my code is as follows:

import groovy.sql.Sql
  def getSqlFile() {
 def lst = []
 def dir = new File('/')
 dir.eachFileRecurse(FileType.FILES) {file ->
  fileName = file.toString()
  if(fileName.substring(fileName.length()-3, fileName.length()) == 'sql')
   lst << file
 return lst
  def update() {
        def sql = Sql.newInstance("jdbc:mysql://localhost:3306/dummy", "root", "password", "com.mysql.jdbc.Driver")
    getSqlFile().each {sqlSyntax ->
  repositories {
  configurations {
  dependencies {
    driver group: 'mysql', name: 'mysql-connector-java', version: '5.1.18'
  URLClassLoader loader = GroovyObject.class.classLoader
configurations.driver.each {File file ->
  task updateDB << {

When I run it, the build keeps at 0%. Is there any issue with it?

Can you run any SQL statement? Do you have long-running SQL statements? How many SQL files are you parsing? Should you use the text of the SQL file instead of the when executing the SQL command?

I’d also check the return value of Sql.execute to see if the SQL execution was actually successful. I’d generally abstract that logic into a custom task. That’ll make it more readable and maintainable.

Scanning the whole filesystem will take a long time, too.