From 84d57dbe5b491073f15199102667b8d7eb173633 Mon Sep 17 00:00:00 2001 From: Michael Vorburger Date: Wed, 13 Feb 2019 23:25:57 +0100 Subject: [PATCH 1/8] upgrade Gradle version, and deal with impacts (FINERACT-700) https://discuss.gradle.org/t/could-not-get-unknown-property-classesdir-for-main-classes-of-type-org-gradle-api-internal-tasks-defaultsourcesetoutput/30570 https://discuss.gradle.org/t/gradle-4-replacing-deprecated-test-testclassesdir/22822/2 https://discuss.gradle.org/t/could-not-find-method-leftshift-for-arguments-on-task-of-type-org-gradle-api-defaulttask/30614 --- fineract-provider/build.gradle | 37 +++++++++++-------- fineract-provider/dependencies.gradle | 6 +-- .../gradle/wrapper/gradle-wrapper.properties | 4 +- 3 files changed, 24 insertions(+), 23 deletions(-) diff --git a/fineract-provider/build.gradle b/fineract-provider/build.gradle index e17ecefc8..0a1d2d31f 100644 --- a/fineract-provider/build.gradle +++ b/fineract-provider/build.gradle @@ -77,11 +77,10 @@ repositories { // mavenLocal() // useful for local dev using MariaDB4j SNAPSHOTs (not needed for real-world non-SNAPHOT builds) } openjpa { - files = fileTree(sourceSets.main.output.classesDir).matching { + files = fileTree(sourceSets.main.output.classesDirs.filter { include '**/AbstractPersistableCustom.class' include '**/domain/*.class' - - } + }) enforcePropertyRestrictions = true } @@ -335,8 +334,8 @@ tomcatRunWar { } /* 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.main.output.resourcesDir = sourceSets.main.java.outputDir +sourceSets.test.output.resourcesDir = sourceSets.test.java.outputDir /* Exclude maria db and embedded tomcat related files for non dev builds */ if (!(project.hasProperty('env') && project.getProperty('env') == 'dev')) { @@ -375,7 +374,7 @@ task integrationTest(type:Test){ tomcatRunWar.daemon = true tomcatRunWar.execute() } - testClassesDir = project.sourceSets.integrationTest.output.classesDir + testClassesDirs = project.sourceSets.integrationTest.output.classesDirs classpath = project.sourceSets.integrationTest.runtimeClasspath } @@ -397,21 +396,27 @@ configurations.driver.each {File file -> loader.addURL(file.toURL()) } -task createDB<<{ +task createDB { description= "Creates the Database. Needs database name to be passed (like: -PdbName=someDBname)" - def sql = Sql.newInstance( 'jdbc:mysql:thin://localhost:3306/', mysqlUser, mysqlPassword, 'org.drizzle.jdbc.DrizzleDriver' ) - sql.execute( 'create database '+"`$dbName`" ) + doLast { + sql = Sql.newInstance( 'jdbc:mysql:thin://localhost:3306/', mysqlUser, mysqlPassword, 'org.drizzle.jdbc.DrizzleDriver' ) + sql.execute( 'create database '+"`$dbName`" ) + } } -task dropDB<<{ +task dropDB { description= "Drops the specified database. The database name has to be passed (like: -PdbName=someDBname)" - def sql = Sql.newInstance( 'jdbc:mysql:thin://localhost:3306/', mysqlUser, mysqlPassword, 'org.drizzle.jdbc.DrizzleDriver' ) - sql.execute( 'DROP DATABASE '+"`$dbName`") + doLast { + sql = Sql.newInstance( 'jdbc:mysql:thin://localhost:3306/', mysqlUser, mysqlPassword, 'org.drizzle.jdbc.DrizzleDriver' ) + sql.execute( 'DROP DATABASE '+"`$dbName`") + } } -task setBlankPassword<<{ - def sql = Sql.newInstance( 'jdbc:mysql:thin://localhost:3306/', mysqlUser, mysqlPassword, 'org.drizzle.jdbc.DrizzleDriver' ) - 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;') +task setBlankPassword { + doLast { + sql = Sql.newInstance( 'jdbc:mysql:thin://localhost:3306/', mysqlUser, mysqlPassword, 'org.drizzle.jdbc.DrizzleDriver' ) + 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;') + } } diff --git a/fineract-provider/dependencies.gradle b/fineract-provider/dependencies.gradle index 571786b0a..82b170c76 100644 --- a/fineract-provider/dependencies.gradle +++ b/fineract-provider/dependencies.gradle @@ -27,10 +27,6 @@ dependencies { providedRuntime("org.springframework.boot:spring-boot-starter-tomcat:${springBootVersion}") - providedCompile( -// [group: 'javax.servlet', name: 'servlet-api', version: '2.5'], - ) - compile( // [group: 'ch.vorburger.mariaDB4j', name: 'mariaDB4j', version: '2.1.3'], @@ -39,7 +35,7 @@ dependencies { [group: 'org.springframework.boot', name: 'spring-boot-starter-security', version: springBootVersion], //[group: 'org.eclipse.persistence', name: 'javax.persistence', version: '2.0.0'], [group: 'org.springframework', name: 'spring-context-support', version: springVersion], - + [group: 'org.springframework.security.oauth', name: 'spring-security-oauth2', version: springOauthVersion], [group: 'org.apache.openjpa', name:'openjpa-all', version: openJPAVersion], diff --git a/fineract-provider/gradle/wrapper/gradle-wrapper.properties b/fineract-provider/gradle/wrapper/gradle-wrapper.properties index 44cca1e1c..6ceb14dd3 100644 --- a/fineract-provider/gradle/wrapper/gradle-wrapper.properties +++ b/fineract-provider/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Fri Jan 29 13:04:36 IST 2016 +#Wed Feb 13 23:18:32 CET 2019 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-5.2.1-bin.zip From 1ee141bb87321e24c4ef5308d45399aa561200aa Mon Sep 17 00:00:00 2001 From: Michael Vorburger Date: Sun, 17 Feb 2019 23:04:20 +0100 Subject: [PATCH 2/8] upgrade spring-boot-gradle-plugin, and deal with impacts (FINERACT-700) because the old one previously used caused an UnsupportedOperationException with the new Gradle, see https://issues.apache.org/jira/browse/FINERACT-700 The spring-jms and activemq-broker versions are set to what they were on before. --- fineract-provider/build.gradle | 12 ++++++------ fineract-provider/dependencies.gradle | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/fineract-provider/build.gradle b/fineract-provider/build.gradle index 0a1d2d31f..77d40d71e 100644 --- a/fineract-provider/build.gradle +++ b/fineract-provider/build.gradle @@ -41,7 +41,7 @@ buildscript { 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 above + 'org.springframework.boot:spring-boot-gradle-plugin:2.1.3.RELEASE' // also change springDataJpaVersion below classpath "org.apache.openjpa:openjpa-all:$openJPAVersion" classpath 'at.schmutterer.oss.gradle:gradle-openjpa:0.2.0' classpath 'gradle.plugin.org.nosphere.apache:creadur-rat-gradle:0.2.2' @@ -52,7 +52,7 @@ apply plugin: "org.nosphere.apache.rat" apply plugin: 'rebel' apply plugin: 'license' apply plugin: 'war' -apply plugin: 'spring-boot' +apply plugin: 'org.springframework.boot' apply plugin: 'eclipse' apply plugin: 'idea' apply plugin: 'tomcat' @@ -299,7 +299,7 @@ war { from('../DISCLAIMER') { // notice the parens into "WEB-INF/" // no leading slash } - war.finalizedBy(bootRepackage) + war.finalizedBy(bootWar) } license { @@ -439,8 +439,8 @@ def qualifyVersionIfNecessary(version) { } springBoot { - mainClass = 'org.apache.fineract.ServerWithMariaDB4jApplication' + mainClassName = 'org.apache.fineract.ServerWithMariaDB4jApplication' } -bootRepackage { - mainClass = 'org.apache.fineract.ServerWithMariaDB4jApplication' +bootWar { + mainClassName = 'org.apache.fineract.ServerWithMariaDB4jApplication' } diff --git a/fineract-provider/dependencies.gradle b/fineract-provider/dependencies.gradle index 82b170c76..d6ed5d0f0 100644 --- a/fineract-provider/dependencies.gradle +++ b/fineract-provider/dependencies.gradle @@ -88,8 +88,8 @@ dependencies { //[group: 'com.google.code.findbugs', name: 'jsr305', version: '3.0.0'] [group: 'io.swagger', name: 'swagger-jersey-jaxrs', version: '1.5.15'], - [group: 'org.springframework', name:'spring-jms'], - [group: 'org.apache.activemq', name: 'activemq-broker'], + [group: 'org.springframework', name:'spring-jms', version: '4.0.7.RELEASE'], + [group: 'org.apache.activemq', name: 'activemq-broker', version: '5.9.1'], [group: 'javax.validation', name: 'validation-api', version: '2.0.0.Final'] ) From fd74931390199f6b6b8c8ca246d018c23c298698 Mon Sep 17 00:00:00 2001 From: Michael Vorburger Date: Mon, 18 Feb 2019 00:25:05 +0100 Subject: [PATCH 3/8] upgrade (switch) OpenJPA Gradle plugin (FINERACT-700) from at.schmutterer.oss.gradle:gradle-openjpa to com.radcortez.gradle:openjpa-gradle-plugin due to https://github.com/schmutterer/gradle-openjpa/issues/8 --- fineract-provider/build.gradle | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/fineract-provider/build.gradle b/fineract-provider/build.gradle index 77d40d71e..00979ab41 100644 --- a/fineract-provider/build.gradle +++ b/fineract-provider/build.gradle @@ -43,7 +43,7 @@ buildscript { 'org.zeroturnaround:gradle-jrebel-plugin:1.1.2', 'org.springframework.boot:spring-boot-gradle-plugin:2.1.3.RELEASE' // also change springDataJpaVersion below classpath "org.apache.openjpa:openjpa-all:$openJPAVersion" - classpath 'at.schmutterer.oss.gradle:gradle-openjpa:0.2.0' + classpath 'com.radcortez.gradle:openjpa-gradle-plugin:3.0.0' classpath 'gradle.plugin.org.nosphere.apache:creadur-rat-gradle:0.2.2' } } @@ -76,12 +76,12 @@ repositories { jcenter() // mavenLocal() // useful for local dev using MariaDB4j SNAPSHOTs (not needed for real-world non-SNAPHOT builds) } + openjpa { - files = fileTree(sourceSets.main.output.classesDirs.filter { - include '**/AbstractPersistableCustom.class' - include '**/domain/*.class' - }) - enforcePropertyRestrictions = true + includes = ['**/AbstractPersistableCustom.class', '**/domain/*.class'] + enhance { + enforcePropertyRestrictions true + } } rat { From 6f58b30fd84f6ae35ff641fd2c45f95a049fd2f9 Mon Sep 17 00:00:00 2001 From: "Michael Vorburger.ch" Date: Tue, 2 Jul 2019 09:19:57 +0200 Subject: [PATCH 4/8] gradle.properties with -Xmx4g and disabling daemon because the (new, upgraded) Tomcat Gradle plugin needs more memory (and this seems to make the build a bit faster, may be less is fine), and it does not work with the Gradle daemon; this fixes: > Task :tomcatRunWar Failed to initialize end point associated with ProtocolHandler ["http-bio-8080"] Failed to initialize connector [Connector[HTTP/1.1-8080]] Failed to initialize end point associated with ProtocolHandler ["ajp-bio-8009"] Failed to initialize connector [Connector[AJP/1.3-8009]] Failed to initialize end point associated with ProtocolHandler ["http-bio-8443"] Failed to initialize connector [Connector[HTTP/1.1-8443]] which appears on the 2nd (only!) run of `./gradlew tomcatRunWAR` (because the Tomcat embedded in the previous daemon-ized Gradle did not stop). --- gradle.properties | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 gradle.properties diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 000000000..b65231028 --- /dev/null +++ b/gradle.properties @@ -0,0 +1,24 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +# Increased memory and disabled daemon are required by gradle-tomcat-plugin +# The daemon is more pain than gain, because the Tomcat in the Gradle process does not shut down cleanly. +# TODO remove this after https://issues.apache.org/jira/browse/FINERACT-764 +org.gradle.jvmargs=-Xmx4g +org.gradle.daemon=false From b54a11da9bd5a70ec13cebfd82b5b483fe10677e Mon Sep 17 00:00:00 2001 From: "Michael Vorburger.ch" Date: Thu, 4 Jul 2019 10:26:31 +0200 Subject: [PATCH 5/8] fix gradle createDB/dropDB/setBlankPassword which broke during the Gradle upgrade in FINERACT-700 do not fix Flyway related migrateTenantDB & Co, as those are proposed to be removed in FINERACT-765 anyway. (If really needed, some of my other WIP branches have the required changes to make the Flyway related tasks work.) --- fineract-provider/build.gradle | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fineract-provider/build.gradle b/fineract-provider/build.gradle index 00979ab41..2c580b1f0 100644 --- a/fineract-provider/build.gradle +++ b/fineract-provider/build.gradle @@ -399,7 +399,7 @@ configurations.driver.each {File file -> task createDB { description= "Creates the Database. Needs database name to be passed (like: -PdbName=someDBname)" doLast { - sql = Sql.newInstance( 'jdbc:mysql:thin://localhost:3306/', mysqlUser, mysqlPassword, 'org.drizzle.jdbc.DrizzleDriver' ) + def sql = Sql.newInstance( 'jdbc:mysql:thin://localhost:3306/', mysqlUser, mysqlPassword, 'org.drizzle.jdbc.DrizzleDriver' ) sql.execute( 'create database '+"`$dbName`" ) } } @@ -407,13 +407,13 @@ task createDB { task dropDB { description= "Drops the specified database. The database name has to be passed (like: -PdbName=someDBname)" doLast { - sql = Sql.newInstance( 'jdbc:mysql:thin://localhost:3306/', mysqlUser, mysqlPassword, 'org.drizzle.jdbc.DrizzleDriver' ) + def sql = Sql.newInstance( 'jdbc:mysql:thin://localhost:3306/', mysqlUser, mysqlPassword, 'org.drizzle.jdbc.DrizzleDriver' ) sql.execute( 'DROP DATABASE '+"`$dbName`") } } task setBlankPassword { doLast { - sql = Sql.newInstance( 'jdbc:mysql:thin://localhost:3306/', mysqlUser, mysqlPassword, 'org.drizzle.jdbc.DrizzleDriver' ) + def sql = Sql.newInstance( 'jdbc:mysql:thin://localhost:3306/', mysqlUser, mysqlPassword, 'org.drizzle.jdbc.DrizzleDriver' ) 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;') } From 9a4cb83bd5d65314b6a1c897999c4fb0898e4368 Mon Sep 17 00:00:00 2001 From: "Michael Vorburger.ch" Date: Fri, 14 Jun 2019 00:25:13 +0200 Subject: [PATCH 6/8] upgrade gradle-tomcat-plugin from 1.0 to 2.5 (NOK) --- fineract-provider/build.gradle | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/fineract-provider/build.gradle b/fineract-provider/build.gradle index 2c580b1f0..9c495ba10 100644 --- a/fineract-provider/build.gradle +++ b/fineract-provider/build.gradle @@ -38,7 +38,7 @@ buildscript { } dependencies { - classpath 'org.gradle.api.plugins:gradle-tomcat-plugin:1.0', + classpath 'com.bmuschko:gradle-tomcat-plugin:2.5', '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:2.1.3.RELEASE' // also change springDataJpaVersion below @@ -55,7 +55,7 @@ apply plugin: 'war' apply plugin: 'org.springframework.boot' apply plugin: 'eclipse' apply plugin: 'idea' -apply plugin: 'tomcat' +apply plugin: 'com.bmuschko.tomcat' apply plugin: 'project-report' apply plugin: 'java' apply plugin: 'openjpa' @@ -367,12 +367,11 @@ configurations { integrationTestRuntime.extendsFrom testRuntime } -task integrationTest(type:Test){ +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() } testClassesDirs = project.sourceSets.integrationTest.output.classesDirs classpath = project.sourceSets.integrationTest.runtimeClasspath From e2b2e66610c2f9e0328fdbd48e6d1e760ec6bdd3 Mon Sep 17 00:00:00 2001 From: "Michael Vorburger.ch" Date: Tue, 9 Jul 2019 22:09:11 +0200 Subject: [PATCH 7/8] fix integrationTest (=> runWar) which broke in Gradle upgrade inspired by (but not exactly like) the respective section on https://github.com/bmuschko/gradle-tomcat-plugin#faq --- fineract-provider/build.gradle | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/fineract-provider/build.gradle b/fineract-provider/build.gradle index 9c495ba10..7094e4cdd 100644 --- a/fineract-provider/build.gradle +++ b/fineract-provider/build.gradle @@ -333,6 +333,23 @@ tomcatRunWar { configFile = file('src/test/resources/META-INF/context.xml') } +task tomcatRunWarAsDaemonForIntegrationTest(type: com.bmuschko.gradle.tomcat.tasks.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') + daemon = true +} + +task tomcatStopAfterIntegrationTest(type: com.bmuschko.gradle.tomcat.tasks.TomcatStop) { + stopPort = 8081 + stopKey = 'stopKey' +} + /* http://stackoverflow.com/questions/19653311/jpa-repository-works-in-idea-and-production-but-not-in-gradle */ sourceSets.main.output.resourcesDir = sourceSets.main.java.outputDir sourceSets.test.output.resourcesDir = sourceSets.test.java.outputDir @@ -368,11 +385,12 @@ configurations { } 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 - } + description = "Run integration tests (located in src/integrationTest/java). Starts Tomcat in daemon mode before executing the tests (and stops it after)." + dependsOn war + dependsOn tomcatRunWarAsDaemonForIntegrationTest + tasks.findByName('tomcatRunWarAsDaemonForIntegrationTest').mustRunAfter 'war' + finalizedBy tomcatStopAfterIntegrationTest + testClassesDirs = project.sourceSets.integrationTest.output.classesDirs classpath = project.sourceSets.integrationTest.runtimeClasspath } From 2fc98df21cc62f7641881b24a17556954df82dbf Mon Sep 17 00:00:00 2001 From: "Michael Vorburger.ch" Date: Wed, 10 Jul 2019 23:47:51 +0200 Subject: [PATCH 8/8] fix ClassCircularityError: java/util/logging/LogRecord (see FINERACT-700 for details) --- fineract-provider/build.gradle | 1 + 1 file changed, 1 insertion(+) diff --git a/fineract-provider/build.gradle b/fineract-provider/build.gradle index 347cc2155..49ccb8b51 100644 --- a/fineract-provider/build.gradle +++ b/fineract-provider/build.gradle @@ -187,6 +187,7 @@ configurations { } runtime all*.exclude group: 'commons-logging' + all*.exclude module: 'jul-to-slf4j' // see FINERACT-700 re. ClassCircularityError: java/util/logging/LogRecord } /* Pick up dependencies based on the environemnt, defaults to production */ if (project.hasProperty('env') && project.getProperty('env') == 'dev') {