This topic How to set up the SQL statement when calling ant sql task? helps me to build solution.
I need to recreate Spring Batch tables from Gradle task (as a part of bootstrapping process).
buildscript {
dependencies {
classpath 'com.oracle:ojdbc6:11.2.0.3'
}
}
configurations {
batch
}
dependencies {
batch 'org.springframework.batch:spring-batch-core:3.0.8.RELEASE'
}
def extractBatchSql(path) {
def zipFile = configurations.batch.find { it =~ /spring-batch-core/ }
def zip = new java.util.zip.ZipFile(zipFile)
def entry = zip.getEntry(path)
return zip.getInputStream(entry).text
}
task tmp() {
dependsOn configurations.batch
doLast {
def delSql = extractBatchSql("org/springframework/batch/core/schema-drop-oracle10g.sql")
ant.sql(classpath: buildscript.configurations.classpath.asPath, driver: "oracle.jdbc.OracleDriver",
url: "${dbConn}", userid: "${dbUser}", password: "${dbPass}", delSql)
def createSql = extractBatchSql("org/springframework/batch/core/schema-oracle10g.sql")
ant.sql(classpath: buildscript.configurations.classpath.asPath, driver: "oracle.jdbc.OracleDriver",
url: "${dbConn}", userid: "${dbUser}", password: "${dbPass}", createSql)
}
}