Files
cbsnexora-backend/mifosng-provider/build.gradle
T
Michael Vorburger 0b501d1dcd MIFOSX-1552 war { ... war.finalizedBy(bootRepackage) } makes gradlew war
produce an executable WAR, just like standard gradlew build does (this
resolves the problem mentioned in the PS on
http://blog2.vorburger.ch/2014/09/mifos-executable-war-with-mariadb4j.html)

Signed-off-by: Michael Vorburger <mike@vorburger.ch>
2014-09-30 01:01:17 +02:00

413 lines
15 KiB
Groovy

description = '''\
Run as:
gradle clean tomcatrunwar
'''
buildscript {
repositories {
jcenter()
}
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.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'
apply plugin: 'project-report'
/* define the valid syntax level for source files */
sourceCompatibility = JavaVersion.VERSION_1_7
/* define binary compatibility version */
targetCompatibility = JavaVersion.VERSION_1_7
project.ext.springBootVersion = '1.1.6.RELEASE'
project.ext.springVersion = '4.0.7.RELEASE'
project.ext.jerseyVersion = '1.17'
project.ext.springDataJpaVersion = '1.7.0.RELEASE' // also change spring-boot-gradle-plugin version above
project.ext.mysqlUser='root'
project.ext.mysqlPassword='mysql'
group = 'org.mifosplatform'
repositories {
jcenter()
maven {
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
all*.exclude group: 'commons-logging'
}
dependencies {
def tomcatVersion = '7.0.54'
tomcat "org.apache.tomcat.embed:tomcat-embed-core:${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'],
)
compile(
[group: 'ch.vorburger.mariaDB4j', name: 'mariaDB4j', version: '2.1.0'],
[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],
[group: 'com.sun.jersey', name: 'jersey-servlet', version: jerseyVersion],
[group: 'com.sun.jersey', name: 'jersey-server', version: jerseyVersion],
[group: 'com.sun.jersey', name: 'jersey-json', version: jerseyVersion],
[group: 'com.sun.jersey.contribs', name: 'jersey-spring', version: jerseyVersion],
[group: 'com.sun.jersey.contribs', name: 'jersey-multipart', version: jerseyVersion],
[group: 'com.squareup.retrofit', name: 'retrofit', version: '1.6.1'],
[group: 'com.squareup.okhttp', name: 'okhttp', version: '2.0.0'],
[group: 'com.squareup.okhttp', name: 'okhttp-urlconnection', version: '2.0.0'],
[group: 'com.google.code.gson', name: 'gson', version: '2.2.4'],
[group: 'com.google.guava', name: 'guava', version: '15.0'],
[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.3'],
[group: 'org.apache.commons', name: 'commons-lang3', version: '3.3.2'],
// 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: 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'],
[group: 'pentaho-reporting-engine', name: 'pentaho-reporting-engine-classic-extensions-scripting', version: '3.9.1-GA'],
[group: 'pentaho-reporting-engine', name: 'pentaho-reporting-engine-wizard-core', version: '3.9.1-GA'],
[group: 'pentaho-report-designer', name: 'pentaho-reporting-engine-wizard-xul', version: '3.9.1-GA'],
[group: 'pentaho-library', name: 'libbase', version: '1.2.8'],
[group: 'pentaho-library',name: 'libdocbundle', version: '1.2.8'],
[group: 'pentaho-library',name: 'libfonts', version: '1.2.8'],
[group: 'pentaho-library',name: 'libformat', version: '1.2.8'],
[group: 'pentaho-library',name: 'libformula', version: '1.2.8'],
[group: 'pentaho-library',name: 'libloader', version: '1.2.8'],
[group: 'pentaho-library',name: 'librepository', version: '1.2.8'],
[group: 'pentaho-library',name: 'libserializer', version: '1.2.8'],
[group: 'pentaho-library',name: 'libsparkline', version: '1.2.8'],
[group: 'pentaho-library',name: 'libxml', version: '1.2.8'],
[group: 'org.apache.poi',name: 'poi', version: '3.9'],
[group: 'org.apache.poi',name: 'poi-ooxml', version: '3.9'],
[group: 'org.apache.poi',name: 'poi-ooxml-schemas', version: '3.9'],
[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-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'],
// 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.3.5']
)
testCompile 'junit:junit:4.11',
'junit:junit-dep:4.11',
'org.mockito:mockito-core:1.9.5',
'com.jayway.restassured:rest-assured:2.3.3',
[group: 'org.springframework.boot', name: 'spring-boot-starter-test', version: springBootVersion]
}
task dist(type:Zip){
baseName= 'mifosplatform'
version = qualifyVersionIfNecessary(releaseVersion)
from('../') {
fileMode = 0755
include '*.md'
}
from('../apps') {
fileMode = 0755
include '*.md'
into('apps')
}
from('src/main/pentahoReports/') {
fileMode = 0755
include '*'
into('pentahoReports')
}
from('../api-docs/') {
fileMode = 0755
include '*'
into('api-docs')
}
from('../mifosng-db/') {
fileMode = 0755
include '*.sql'
into('database')
}
from('src/main/resources/sql/migrations') {
fileMode = 0755
include '**/*'
into('database/migrations')
}
from war.outputs.files
into(baseName + '-' + version)
}
task deployPentahoReports() {
def pentahoReportDir = System.properties['user.home'] + System.properties['file.separator'] + '.mifosx' + System.properties['file.separator'] + 'pentahoReports'
copy {
from "src/main/pentahoReports"
into pentahoReportDir
}
doLast {
println ':deployPentahoReports - moving pentaho reports under: ' + pentahoReportDir
}
}
war {
it.dependsOn deployPentahoReports
war.finalizedBy(bootRepackage)
}
license {
header rootProject.file('../LICENSE.md')
excludes(["**/*.mustache", "**/*.sql", "**/package-info.java", "**/keystore.jks"])
strictCheck true
}
tomcatRun {
httpPort = 8080
httpsPort = 8443
stopPort = 8081
stopKey= 'stopKey'
enableSSL = true
configFile = file('src/test/resources/META-INF/context.xml')
}
tomcatRunWar {
httpPort = 8080
httpsPort = 8443
stopPort = 8081
stopKey= 'stopKey'
enableSSL = true
keystoreFile = file('src/main/resources/keystore.jks')
keystorePass = 'openmf'
configFile = file('src/test/resources/META-INF/context.xml')
}
/* http://stackoverflow.com/questions/19653311/jpa-repository-works-in-idea-and-production-but-not-in-gradle */
sourceSets.main.output.resourcesDir = sourceSets.main.output.classesDir
sourceSets.test.output.resourcesDir = sourceSets.test.output.classesDir
sourceSets {
integrationTest {
compileClasspath += main.output + test.output
runtimeClasspath += main.output + test.output
}
}
configurations {
integrationTestCompile.extendsFrom testCompile
integrationTestRuntime.extendsFrom testRuntime
}
task integrationTest(type:Test){
description = "Run integration tests (located in src/integrationTest/java). Starts tomcat in daemon mode before executing the tests."
it.dependsOn war
doFirst {
tomcatRunWar.daemon = true
tomcatRunWar.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 createDB<<{
description= "Creates the Database. Needs database name to be passed (like: -PdbName=someDBname)"
sql = Sql.newInstance( 'jdbc:mysql://localhost:3306/', mysqlUser, mysqlPassword, 'com.mysql.jdbc.Driver' )
sql.execute( 'create database '+"`$dbName`" )
}
task dropDB<<{
description= "Drops the specified database. The database name has to be passed (like: -PdbName=someDBname)"
sql = Sql.newInstance( 'jdbc:mysql://localhost:3306/', mysqlUser, mysqlPassword, 'com.mysql.jdbc.Driver' )
sql.execute( 'DROP DATABASE '+"`$dbName`")
}
task setBlankPassword<<{
sql = Sql.newInstance( 'jdbc:mysql://localhost:3306/', mysqlUser, mysqlPassword, 'com.mysql.jdbc.Driver' )
sql.execute('USE `mifosplatform-tenants`')
sql.execute('UPDATE mifosplatform-tenants.tenants SET schema_server = \'localhost\', schema_server_port = \'3306\', schema_username = \'mifos\', schema_password = \'mysql\' WHERE id=1;')
}
apply plugin: 'flyway'
buildscript {
repositories {
mavenCentral()
}
dependencies {
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'
}
}
flyway {
url = "jdbc:mysql://localhost:3306/mifostenant-default"
user = mysqlUser
password = mysqlPassword
}
task migrateTenantDB<<{
description="Migrates a Tenant DB. Optionally can pass dbName. Defaults to 'mifostenant-default' (Example: -PdbName=someTenantDBname)"
def filePath = "filesystem:$projectDir" + '/src/main/resources/sql/migrations/core_db'
def tenantDbName = 'mifostenant-default';
if (rootProject.hasProperty("dbName")) {
tenantDbName = rootProject.getProperty("dbName")
}
flyway.url= "jdbc:mysql://localhost:3306/$tenantDbName"
flyway.locations= [filePath]
flywayMigrate.execute()
}
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" + '/src/main/resources/sql/migrations/core_db'
def tenantDbName = 'mifostenant-default';
if (rootProject.hasProperty("dbName")) {
tenantDbName = rootProject.getProperty("dbName")
}
flyway.url= "jdbc:mysql://localhost:3306/$tenantDbName"
flyway.locations= [filePath]
flywayInfo.execute()
}
task migrateTenantListDB<<{
description="Migrates a Tenant List DB. Optionally can pass dbName. Defaults to 'mifosplatform-tenants' (Example: -PdbName=someDBname)"
def filePath = "filesystem:$projectDir" + '/src/main/resources/sql/migrations/list_db'
def tenantsDbName = 'mifosplatform-tenants';
if (rootProject.hasProperty("dbName")) {
tenantsDbName = rootProject.getProperty("dbName")
}
flyway.url= "jdbc:mysql://localhost:3306/$tenantsDbName"
flyway.locations= [filePath]
flywayMigrate.execute()
}
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" + '/src/main/resources/sql/migrations/list_db'
def tenantsDbName = 'mifosplatform-tenants';
if (rootProject.hasProperty("dbName")) {
tenantsDbName = rootProject.getProperty("dbName")
}
flyway.url= "jdbc:mysql://localhost:3306/$tenantsDbName"
flyway.locations= [filePath]
flywayInfo.execute()
}
task repairTenantDB<<{
description="repair migrate"
def filePath = "filesystem:$projectDir" + '/src/main/resources/sql/migrations/list_db'
def tenantsDbName = 'mifosplatform-tenants';
if (rootProject.hasProperty("dbName")) {
tenantsDbName = rootProject.getProperty("dbName")
}
flyway.url= "jdbc:mysql://localhost:3306/$tenantsDbName"
flyway.locations= [filePath]
flywayRepair.execute()
}
/*
* Support publication of artifacts versioned by topic branch.
* CI builds supply `-P BRANCH_NAME=<TOPIC>` to gradle at build time.
* If <TOPIC> starts with 'MIFOSX-', change version
* from BUILD-SNAPSHOT => <TOPIC>-SNAPSHOT
* e.g. 1.1.0.BUILD-SNAPSHOT => 1.0.0.MIFOSX-1234-SNAPSHOT
*/
def qualifyVersionIfNecessary(version) {
if (rootProject.hasProperty("BRANCH_NAME")) {
def qualifier = rootProject.getProperty("BRANCH_NAME")
if (qualifier.startsWith("MIFOSX-")) {
return version.replace('BUILD', qualifier)
}
}
return version
}
springBoot {
mainClass = 'org.mifosplatform.ServerWithMariaDB4jApplication'
}
bootRepackage {
mainClass = 'org.mifosplatform.ServerWithMariaDB4jApplication'
}