49 lines
1.7 KiB
Groovy
49 lines
1.7 KiB
Groovy
//apply plugin: 'java'
|
|
|
|
/**
|
|
* Generate schema creation and drop scripts for various databases
|
|
* supported by the Spring Integration JDBC adapter.
|
|
*
|
|
* @author David Syer (original Ant/Maven work)
|
|
* @author Chris Beams (port to Gradle)
|
|
*/
|
|
task generateSql {
|
|
group = "Build"
|
|
description = "Generates schema creation and drop scripts for supported databases."
|
|
|
|
repositories { mavenRepo urls: 'http://objectstyle.org/maven2/' }
|
|
configurations { vpp }
|
|
dependencies { vpp 'foundrylogic.vpp:vpp:2.2.1' }
|
|
|
|
def generatedResourcesDir = new File(buildDir, 'generated-resources')
|
|
|
|
outputs.dir generatedResourcesDir
|
|
|
|
ant.typedef(resource: 'foundrylogic/vpp/typedef.properties',
|
|
classpath: configurations.vpp.asPath)
|
|
ant.taskdef(resource: 'foundrylogic/vpp/taskdef.properties',
|
|
classpath: configurations.vpp.asPath)
|
|
|
|
doLast {
|
|
['hsqldb', 'h2', 'db2', 'derby', 'mysql',
|
|
'oracle10g', 'postgresql', 'sqlserver', 'sybase'].each { dbType ->
|
|
ant.vppcopy(todir: generatedResourcesDir, overwrite: 'true') {
|
|
config {
|
|
context {
|
|
property key: 'includes', value: 'src/main/sql'
|
|
property file: "src/main/sql/${dbType}.properties"
|
|
}
|
|
engine {
|
|
property key: 'velocimacro.library', value: "src/main/sql/${dbType}.vpp"
|
|
}
|
|
}
|
|
fileset dir: 'src/main/sql', includes: 'schema*.sql.vpp'
|
|
mapper type: 'glob', from: '*.sql.vpp', to: "*-${dbType}.sql"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// tie schema generation to the build lifecycle
|
|
compileJava.dependsOn generateSql
|