From da12288024004d8466f20d59e5b7f7adb10011a1 Mon Sep 17 00:00:00 2001 From: Keith Woodlock Date: Thu, 4 Apr 2013 12:30:48 +0100 Subject: [PATCH] add sensible defaults to db wrapper tasks. --- mifosng-provider/build.gradle | 50 ++++++++++++++++++++++++----------- 1 file changed, 34 insertions(+), 16 deletions(-) diff --git a/mifosng-provider/build.gradle b/mifosng-provider/build.gradle index cceb4d356..898713a37 100644 --- a/mifosng-provider/build.gradle +++ b/mifosng-provider/build.gradle @@ -308,21 +308,31 @@ flyway { } - task migrateTenantDB<<{ - description="Migrates a Tenant DB. Have to pass dbName. (Example: -PdbName=someTenantDBname). " + description="Migrates a Tenant DB. Optionally can pass dbName. Defaults to 'mifostenant-default' (Example: -PdbName=someTenantDBname)" - flyway.url= "jdbc:mysql://localhost:3306/$dbName" + def tenantDbName = 'mifostenant-default'; + if (rootProject.hasProperty("dbName")) { + tenantDbName = rootProject.getProperty("dbName") + } + + flyway.url= "jdbc:mysql://localhost:3306/$tenantDbName" flyway.locations= [ - "filesystem:../mifosng-db/migrations/core_db", + "filesystem:../mifosng-db/migrations/core_db", ] flywayMigrate.execute() } task showTenantDBInfo<<{ - description="Shows the migration info for a Tenant DB. Have to pass dbName. (Example: -PdbName=someTenantDBname)" - flyway.url= "jdbc:mysql://localhost:3306/$dbName" + description="Shows the migration info for a Tenant DB. Optionally can pass dbName. Defaults to 'mifostenant-default' (Example: -PdbName=someTenantDBname)" + + def tenantDbName = 'mifostenant-default'; + if (rootProject.hasProperty("dbName")) { + tenantDbName = rootProject.getProperty("dbName") + } + + flyway.url= "jdbc:mysql://localhost:3306/$tenantDbName" flyway.locations= [ "filesystem:../mifosng-db/migrations/core_db", ] @@ -331,9 +341,14 @@ task showTenantDBInfo<<{ task migrateTenantListDB<<{ - description="Migrates a Tenant List DB. Have to pass dbName. (Example: -PdbName=someDBname)" + description="Migrates a Tenant List DB. Optionally can pass dbName. Defaults to 'mifosplatform-tenants' (Example: -PdbName=someDBname)" - flyway.url= "jdbc:mysql://localhost:3306/$dbName" + def tenantsDbName = 'mifosplatform-tenants'; + if (rootProject.hasProperty("dbName")) { + tenantsDbName = rootProject.getProperty("dbName") + } + + flyway.url= "jdbc:mysql://localhost:3306/$tenantsDbName" flyway.locations= [ "filesystem:../mifosng-db/migrations/list_db", ] @@ -341,17 +356,21 @@ task migrateTenantListDB<<{ flywayMigrate.execute() } -task showTenentListDBInfo<<{ - description="Shows the migration info for a List DB. Have to pass dbName. (Example: -PdbName=someDBname)" - flyway.url= "jdbc:mysql://localhost:3306/$dbName" +task showTenantListDBInfo<<{ + description="Shows the migration info for a List DB. Optionally can pass dbName. Defaults to 'mifosplatform-tenants' (Example: -PdbName=someDBname)" + + def tenantsDbName = 'mifosplatform-tenants'; + if (rootProject.hasProperty("dbName")) { + tenantsDbName = rootProject.getProperty("dbName") + } + + flyway.url= "jdbc:mysql://localhost:3306/$tenantsDbName" flyway.locations= [ - "filesystem:../mifosng-db/migrations/list_db", + "filesystem:../mifosng-db/migrations/list_db", ] flywayInfo.execute() } - - /* * Support publication of artifacts versioned by topic branch. * CI builds supply `-P BRANCH_NAME=` to gradle at build time. @@ -368,5 +387,4 @@ def qualifyVersionIfNecessary(version) { } } return version -} - +} \ No newline at end of file