* remove `overwrite: 'true'` from `generateSql` task * add `cleanSql` task JIRA: https://jira.springsource.org/browse/INT-3074
52 lines
1.8 KiB
Groovy
52 lines
1.8 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."
|
|
|
|
configurations { vpp }
|
|
dependencies { vpp 'foundrylogic.vpp:vpp:2.2.1' }
|
|
|
|
def generatedResourcesDir = new File('src/main/resources/org/springframework/integration/jdbc')
|
|
|
|
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', 'mysql-5_6_4',
|
|
'oracle10g', 'postgresql', 'sqlserver', 'sybase'].each { dbType ->
|
|
ant.vppcopy(todir: generatedResourcesDir) {
|
|
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
|
|
|
|
task cleanSql (type: Delete) {
|
|
delete fileTree(dir: 'src/main/resources/org/springframework/integration/jdbc').include('*.sql').exclude('config', 'store/channel')
|
|
}
|