Port spring-integration-jdbc db schema generation to Gradle
Before (Maven): http://pastie.org/1253428 After (Gradle): http://pastie.org/1253435 This new task: - may be run independently with `gradle generateSql` - is tied to the build lifecycle and will execute prior to 'compileJava' - writes output to build/generated-resources - is set up for incremental build -- will not run if the above dir exists - may be selectively cleaned with `gradle cleanGenerateSql`
This commit is contained in:
46
spring-integration-jdbc/build.gradle
Normal file
46
spring-integration-jdbc/build.gradle
Normal file
@@ -0,0 +1,46 @@
|
||||
/**
|
||||
* 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
|
||||
Reference in New Issue
Block a user