apply plugin: 'distribution'

/**
 * concat task
 * Concatenate all the sql queries / files (except update.*.sql) and collect it into a single
 * SQL file.
 */
task concat() << {
  ext.destFile = 'build/sql/create-all-sql-' + version + '.sql';
  ant.concat(destfile: destFile, fixlastline: 'yes') {
    logger.info('Concating create scripts to ' + destFile)
    fileset(dir: 'src/sql') {
      exclude(name: 'update.*.sql')
      exclude(name: 'database.properties')
    }
  }
}

installDist.dependsOn concat
distTar.dependsOn concat
distZip.dependsOn concat

distributions {
  main {
    contents {
      from('src/sql')
      from("$buildDir/sql")
    }
  }
}
