MIFOSX-1552 Spring Boot + MariaDB4j, read

http://blog2.vorburger.ch/2014/09/mifos-executable-war-with-mariadb4j.html

Signed-off-by: Michael Vorburger <mike@vorburger.ch>
This commit is contained in:
Michael Vorburger
2014-09-22 04:04:15 +02:00
parent 0d8bd285dc
commit 4b0658a685
248 changed files with 1830 additions and 969 deletions
+52 -54
View File
@@ -11,13 +11,15 @@ buildscript {
dependencies {
classpath 'org.gradle.api.plugins:gradle-tomcat-plugin:1.0',
'nl.javadude.gradle.plugins:license-gradle-plugin:0.11.0',
'org.zeroturnaround:gradle-jrebel-plugin:1.1.2'
'org.zeroturnaround:gradle-jrebel-plugin:1.1.2',
'org.springframework.boot:spring-boot-gradle-plugin:1.1.6.RELEASE' // also change springDataJpaVersion below
}
}
apply plugin: 'rebel'
apply plugin: 'license'
apply plugin: 'war'
apply plugin: 'spring-boot'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'tomcat'
@@ -25,14 +27,13 @@ apply plugin: 'project-report'
/* define the valid syntax level for source files */
sourceCompatibility = JavaVersion.VERSION_1_7
/* define binary compatiblity version */
/* define binary compatibility version */
targetCompatibility = JavaVersion.VERSION_1_7
project.ext.springVersion = '4.0.4.RELEASE'
project.ext.springSecurityVersion = '3.2.3.RELEASE'
project.ext.hibernateCoreVersion = '4.1.9.Final'
project.ext.springBootVersion = '1.1.6.RELEASE'
project.ext.springVersion = '4.0.7.RELEASE'
project.ext.jerseyVersion = '1.17'
project.ext.springDataJpaVersion = '1.4.1.RELEASE'
project.ext.springDataJpaVersion = '1.7.0.RELEASE' // also change spring-boot-gradle-plugin version above
project.ext.mysqlUser='root'
project.ext.mysqlPassword='mysql'
@@ -43,11 +44,13 @@ group = 'org.mifosplatform'
repositories {
jcenter()
maven {
url "http://repository.pentaho.org/artifactory/pentaho/"
url "http://repository.pentaho.org/artifactory/pentaho/"
}
// mavenLocal() // useful for local dev using MariaDB4j SNAPSHOTs (not needed for real-world non-SNAPHOT builds)
}
configurations {
providedRuntime // needed for Spring Boot executable WAR
providedCompile
compile
runtime
@@ -55,32 +58,28 @@ configurations {
}
dependencies {
def tomcatVersion = '7.0.47'
def tomcatVersion = '7.0.54'
tomcat "org.apache.tomcat.embed:tomcat-embed-core:${tomcatVersion}",
"org.apache.tomcat.embed:tomcat-embed-logging-juli:${tomcatVersion}"
"org.apache.tomcat.embed:tomcat-embed-logging-log4j:${tomcatVersion}" // NOT tomcat-embed-logging-juli (http://stackoverflow.com/questions/23963049/classcircularityerror-java-util-logging-logrecord-running-gradle-webapp-with-ja)
tomcat("org.apache.tomcat.embed:tomcat-embed-jasper:${tomcatVersion}") {
exclude group: 'org.eclipse.jdt.core.compiler', module: 'ecj'
}
tomcat "org.apache.tomcat:tomcat-dbcp:${tomcatVersion}"
providedRuntime("org.springframework.boot:spring-boot-starter-tomcat")
providedCompile(
[group: 'javax.servlet', name: 'servlet-api', version: '2.5'],
// [group: 'javax.servlet', name: 'servlet-api', version: '2.5'],
)
compile(
[group: 'org.springframework', name: 'spring-core', version: springVersion],
[group: 'org.springframework', name: 'spring-context-support', version: springVersion],
[group: 'org.springframework', name: 'spring-aspects', version: springVersion],
[group: 'org.springframework', name: 'spring-web', version: springVersion],
[group: 'org.springframework', name: 'spring-test', version: springVersion],
[group: 'org.springframework.security', name: 'spring-security-core', version: springSecurityVersion],
[group: 'org.springframework.security', name: 'spring-security-web', version: springSecurityVersion],
[group: 'org.springframework.security', name: 'spring-security-config', version: springSecurityVersion],
[group: 'org.aspectj', name: 'aspectjrt', version: '1.7.0.RELEASE'],
[group: 'ch.vorburger.mariaDB4j', name: 'mariaDB4j', version: '2.1.0'],
[group: 'org.hibernate', name: 'hibernate-core', version: hibernateCoreVersion],
[group: 'org.hibernate', name: 'hibernate-entitymanager', version: hibernateCoreVersion],
[group: 'org.hibernate.javax.persistence', name: 'hibernate-jpa-2.0-api', version: '1.0.1.Final'],
[group: 'org.springframework.boot', name: 'spring-boot-starter-web', version: springBootVersion],
[group: 'org.springframework.boot', name: 'spring-boot-starter-data-jpa', version: springBootVersion],
[group: 'org.springframework.boot', name: 'spring-boot-starter-security', version: springBootVersion],
[group: 'org.springframework', name: 'spring-context-support', version: springVersion],
[group: 'javax.ws.rs', name: 'jsr311-api', version: '1.1.1'],
[group: 'com.sun.jersey', name: 'jersey-core', version: jerseyVersion],
@@ -98,21 +97,15 @@ dependencies {
[group: 'com.google.code.gson', name: 'gson', version: '2.2.4'],
[group: 'com.google.guava', name: 'guava', version: '15.0'],
[group: 'org.springframework.data', name: 'spring-data-jpa', version: springDataJpaVersion],
[group: 'joda-time', name: 'joda-time', version: '2.3'],
[group: 'joda-time', name: 'joda-time', version: '2.4'],
[group: 'net.sourceforge.javacsv', name: 'javacsv', version: '2.0'],
[group: 'org.apache.commons', name: 'commons-email', version: '1.3.1'],
[group: 'org.apache.commons', name: 'commons-lang3', version: '3.1'],
[group: 'org.apache.commons', name: 'commons-email', version: '1.3.3'],
[group: 'org.apache.commons', name: 'commons-lang3', version: '3.3.2'],
[group: 'org.slf4j', name: 'slf4j-api', version: '1.7.5'],
[group: 'org.slf4j', name: 'jcl-over-slf4j', version: '1.7.5'],
[group: 'ch.qos.logback', name: 'logback-core', version: '1.0.13'],
[group: 'ch.qos.logback', name: 'logback-classic', version: '1.0.13'],
// no slf4j & logback here (anymore), as spring-boot-starter-logging already brings this now, better assembled (log4j-over-slf4j was originally forgotten here)
[group: 'mysql', name: 'mysql-connector-java', version: '5.1.27'],
[group: 'org.apache.tomcat', name: 'tomcat-jdbc', version: '7.0.47'],
[group: 'org.apache.tomcat', name: 'tomcat-jdbc', version: tomcatVersion],
[group: 'pentaho-reporting-engine', name: 'pentaho-reporting-engine-classic-core', version: '3.9.1.1'],
[group: 'pentaho-reporting-engine', name: 'pentaho-reporting-engine-classic-extensions', version: '3.9.1-GA'],
@@ -138,17 +131,22 @@ dependencies {
[group: 'com.lowagie', name: 'itext', version: '2.1.7'],
[group: 'com.lowagie', name: 'itext-rtf', version: '2.1.7'],
[group: 'org.mnode.ical4j', name: 'ical4j', version: '1.0.4'],
[group: 'com.googlecode.flyway', name: 'flyway-maven-plugin', version: '2.1.1'],
[group: 'com.googlecode.flyway', name: 'flyway-core', version: '2.1.1'],
[group: 'org.quartz-scheduler', name: 'quartz', version: '2.1.7'],
[group: 'com.amazonaws', name: 'aws-java-sdk', version: '1.2.1'],
[group: 'net.sf.ehcache', name: 'ehcache', version: '2.7.2'],
[group: 'com.github.spullara.mustache.java', name: 'compiler', version: '0.8.12'],
[group: 'com.jayway.jsonpath', name: 'json-path', version: '0.9.1'])
[group: 'com.jayway.jsonpath', name: 'json-path', version: '0.9.1'],
testCompile 'junit:junit:4.11',
'junit:junit-dep:4.11',
'org.mockito:mockito-all:1.9.5',
'com.jayway.restassured:rest-assured:1.7.2'
// Although Mifos (at the time of writing) doesn't have any compile time dep. on this,
// it's useful to have this for the Spring Boot TestRestTemplate http://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/#boot-features-rest-templates-test-utility
[group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.2.3']
)
testCompile 'junit:junit:4.11',
'junit:junit-dep:4.11',
'org.mockito:mockito-core:1.9.5',
'com.jayway.restassured:rest-assured:1.7.2',
[group: 'org.springframework.boot', name: 'spring-boot-starter-test', version: springBootVersion]
}
@@ -179,7 +177,7 @@ task dist(type:Zip){
include '*.sql'
into('database')
}
from('../mifosng-db/migrations') {
from('src/main/resources/sql/migrations') {
fileMode = 0755
include '**/*'
into('database/migrations')
@@ -203,14 +201,11 @@ task deployPentahoReports() {
war {
it.dependsOn deployPentahoReports
from ('../mifosng-db/migrations/core_db') {
into "WEB-INF/classes/sql"
}
}
license {
header rootProject.file('../LICENSE.md')
excludes(["**/*.mustache"])
excludes(["**/*.mustache", "**/*.sql", "**/package-info.java", "**/keystore.jks"])
strictCheck true
}
@@ -229,7 +224,7 @@ tomcatRunWar {
stopPort = 8081
stopKey= 'stopKey'
enableSSL = true
keystoreFile = file('../keystore.jks')
keystoreFile = file('src/main/resources/keystore.jks')
keystorePass = 'openmf'
configFile = file('src/test/resources/META-INF/context.xml')
}
@@ -306,7 +301,7 @@ buildscript {
}
dependencies {
classpath 'com.github.ben-manes:gradle-flyway-plugin:0.2'
classpath "org.flywaydb:flyway-gradle-plugin:3.0" // version upgraded during Spring Boot & MariaDB4j work, as prev. used v0.2 didn't work well after *.sql moved from mifosng-db to mifosng-provider/src/main/resources (new version also has clearer errors, e.g. in case of missing DB)
classpath 'mysql:mysql-connector-java:5.1.22'
}
}
@@ -316,15 +311,12 @@ flyway {
url = "jdbc:mysql://localhost:3306/mifostenant-default"
user = mysqlUser
password = mysqlPassword
def filePath = "filesystem:$projectDir" + System.properties['file.separator'] + '..' + System.properties['file.separator'] + 'mifosng-db' + System.properties['file.separator'] + 'migrations'
locations = [filePath]
}
task migrateTenantDB<<{
description="Migrates a Tenant DB. Optionally can pass dbName. Defaults to 'mifostenant-default' (Example: -PdbName=someTenantDBname)"
def filePath = "filesystem:$projectDir" + System.properties['file.separator'] + '..' + System.properties['file.separator'] + 'mifosng-db' + System.properties['file.separator'] + 'migrations/core_db'
def filePath = "filesystem:$projectDir" + '/src/main/resources/sql/migrations/core_db'
def tenantDbName = 'mifostenant-default';
if (rootProject.hasProperty("dbName")) {
tenantDbName = rootProject.getProperty("dbName")
@@ -339,7 +331,7 @@ task migrateTenantDB<<{
task showTenantDBInfo<<{
description="Shows the migration info for a Tenant DB. Optionally can pass dbName. Defaults to 'mifostenant-default' (Example: -PdbName=someTenantDBname)"
def filePath = "filesystem:$projectDir" + System.properties['file.separator'] + '..' + System.properties['file.separator'] + 'mifosng-db' + System.properties['file.separator'] + 'migrations/core_db'
def filePath = "filesystem:$projectDir" + '/src/main/resources/sql/migrations/core_db'
def tenantDbName = 'mifostenant-default';
if (rootProject.hasProperty("dbName")) {
tenantDbName = rootProject.getProperty("dbName")
@@ -354,7 +346,7 @@ task showTenantDBInfo<<{
task migrateTenantListDB<<{
description="Migrates a Tenant List DB. Optionally can pass dbName. Defaults to 'mifosplatform-tenants' (Example: -PdbName=someDBname)"
def filePath = "filesystem:$projectDir" + System.properties['file.separator'] + '..' + System.properties['file.separator'] + 'mifosng-db' + System.properties['file.separator'] + 'migrations/list_db'
def filePath = "filesystem:$projectDir" + '/src/main/resources/sql/migrations/list_db'
def tenantsDbName = 'mifosplatform-tenants';
if (rootProject.hasProperty("dbName")) {
tenantsDbName = rootProject.getProperty("dbName")
@@ -369,7 +361,7 @@ task migrateTenantListDB<<{
task showTenantListDBInfo<<{
description="Shows the migration info for a List DB. Optionally can pass dbName. Defaults to 'mifosplatform-tenants' (Example: -PdbName=someDBname)"
def filePath = "filesystem:$projectDir" + System.properties['file.separator'] + '..' + System.properties['file.separator'] + 'mifosng-db' + System.properties['file.separator'] + 'migrations/list_db'
def filePath = "filesystem:$projectDir" + '/src/main/resources/sql/migrations/list_db'
def tenantsDbName = 'mifosplatform-tenants';
if (rootProject.hasProperty("dbName")) {
tenantsDbName = rootProject.getProperty("dbName")
@@ -383,7 +375,7 @@ task showTenantListDBInfo<<{
task repairTenantDB<<{
description="repair migrate"
def filePath = "filesystem:$projectDir" + System.properties['file.separator'] + '..' + System.properties['file.separator'] + 'mifosng-db' + System.properties['file.separator'] + 'migrations/list_db'
def filePath = "filesystem:$projectDir" + '/src/main/resources/sql/migrations/list_db'
def tenantsDbName = 'mifosplatform-tenants';
if (rootProject.hasProperty("dbName")) {
tenantsDbName = rootProject.getProperty("dbName")
@@ -412,3 +404,9 @@ def qualifyVersionIfNecessary(version) {
return version
}
springBoot {
mainClass = 'org.mifosplatform.ServerWithMariaDB4jApplication'
}
bootRepackage {
mainClass = 'org.mifosplatform.ServerWithMariaDB4jApplication'
}