Khushal/Gurpreet: Added task in gradle for creating and droping database- createDatabase and dropDatabase

This commit is contained in:
Khushal Oza
2013-04-01 16:00:25 +05:30
parent 56829c2036
commit 5c73a46f2a
+46 -2
View File
@@ -200,6 +200,7 @@ tomcatRun {
httpPort = 8080
httpsPort = 8443
stopPort = 8081
stopKey= 'stopKey'
enableSSL = true
configFile = file('src/test/resources/META-INF/context.xml')
}
@@ -208,6 +209,7 @@ tomcatRunWar {
httpPort = 8080
httpsPort = 8443
stopPort = 8081
stopKey= 'stopKey'
enableSSL = true
configFile = file('src/test/resources/META-INF/context.xml')
}
@@ -224,12 +226,53 @@ configurations {
}
task integrationTest(type:Test){
description = "Run integration tests (located in src/integrationTest/java). Requires server to be running."
description = "Run integration tests (located in src/integrationTest/java). Starts tomcat in daemon mode before executing the tests."
doFirst {
tomcatRunWar.daemon = true
tomcatRunWar.execute()
}
doLast {
tomcatStop.execute()
}
testClassesDir = project.sourceSets.integrationTest.output.classesDir
classpath = project.sourceSets.integrationTest.runtimeClasspath
}
import groovy.sql.Sql
repositories {
mavenCentral()
}
configurations {
driver
}
dependencies {
driver 'mysql:mysql-connector-java:5.1.16'
}
URLClassLoader loader = GroovyObject.class.classLoader
configurations.driver.each {File file ->
loader.addURL(file.toURL())
}
task createDatabase<<{
description= "Creates the Database mifosplatform-tenants and mifostenant-default"
sql = Sql.newInstance( 'jdbc:mysql://localhost:3306/', 'root', 'mysql', 'com.mysql.jdbc.Driver' )
sql.execute( 'create database `mifosplatform-tenants`' )
sql.execute( 'create database `mifostenant-default`' )
}
task dropDatabase<<{
description= "Drops the created Databases mifosplatform-tenants and mifostenant-default"
sql = Sql.newInstance( 'jdbc:mysql://localhost:3306/', 'root', 'mysql', 'com.mysql.jdbc.Driver' )
sql.execute( 'DROP DATABASE `mifosplatform-tenants`' )
sql.execute( 'DROP DATABASE `mifostenant-default`' )
}
apply plugin: 'flyway'
buildscript {
repositories {
@@ -272,4 +315,5 @@ def qualifyVersionIfNecessary(version) {
}
}
return version
}
}