/** * 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. */ description = '''\ Run as: gradle clean bootRun''' project.ext.jerseyVersion = '1.19.4' ext["groovy.version"] = '3.0.3' buildscript { ext { jacocoVersion = '0.8.5' } repositories { jcenter() mavenCentral() maven { url "https://plugins.gradle.org/m2/" } } dependencies { classpath 'io.spring.gradle:dependency-management-plugin:1.0.9.RELEASE' classpath 'com.bmuschko:gradle-cargo-plugin:2.7.1', 'nl.javadude.gradle.plugins:license-gradle-plugin:0.11.0', 'org.zeroturnaround:gradle-jrebel-plugin:1.1.10', 'org.springframework.boot:spring-boot-gradle-plugin:2.2.7.RELEASE' // below classpath 'org.apache.openjpa:openjpa:3.1.1' // when upgrading, also change OpenJPA version repeated below in dependencyManagement! classpath 'com.radcortez.gradle:openjpa-gradle-plugin:3.1.0' classpath 'org.nosphere.apache:creadur-rat-gradle:0.7.0' classpath "gradle.plugin.com.github.spotbugs.snom:spotbugs-gradle-plugin:4.3.0" classpath "gradle.plugin.com.github.andygoossens:gradle-modernizer-plugin:1.3.0" classpath "gradle.plugin.com.gorylenko.gradle-git-properties:gradle-git-properties:2.2.2" classpath "net.ltgt.gradle:gradle-errorprone-plugin:1.2.1" classpath "com.diffplug.spotless:spotless-plugin-gradle:4.3.0" } } apply plugin: 'io.spring.dependency-management' apply plugin: "org.nosphere.apache.rat" apply plugin: 'rebel' apply plugin: 'license' apply plugin: 'war' apply plugin: 'org.springframework.boot' apply plugin: 'eclipse' apply plugin: 'idea' apply plugin: 'com.bmuschko.cargo' apply plugin: 'project-report' apply plugin: 'java-library' apply plugin: 'openjpa' apply plugin: "com.github.spotbugs" apply plugin: 'checkstyle' apply plugin: 'com.github.andygoossens.gradle-modernizer-plugin' apply plugin: 'jacoco' apply plugin: "com.gorylenko.gradle-git-properties" apply plugin: "net.ltgt.errorprone" apply plugin: "com.diffplug.gradle.spotless" // apply plugin: 'pmd' dependencyManagement { imports { mavenBom 'org.springframework:spring-framework-bom:5.2.6.RELEASE' } dependencies { // As much as possible, we avoid fixed versions, and prefer inheriting them from the Spring BOM, thus NOT listing versions here. // (The :+ seems to mean latest available version available on Maven Central, which we should also avoid, as it's not isolated?) dependency 'org.springframework.security.oauth:spring-security-oauth2:2.5.0.RELEASE' dependency "org.apache.openjpa:openjpa:3.1.1" // when upgrading, also change OpenJPA version repeated above in buildscript! dependency 'com.squareup.retrofit:retrofit:1.9.0' dependency 'com.squareup.okhttp:okhttp:2.7.5' dependency 'com.squareup.okhttp:okhttp-urlconnection:2.7.5' dependency 'com.google.code.gson:gson:2.8.6' dependency 'org.apache.commons:commons-email:1.5' dependency 'commons-io:commons-io:2.7' dependency 'org.drizzle.jdbc:drizzle-jdbc:1.4' dependency 'com.github.librepdf:openpdf:1.3.19' dependency 'org.mnode.ical4j:ical4j:3.0.19' dependency 'org.flywaydb:flyway-core:6.4.4' dependency 'org.quartz-scheduler:quartz:2.3.2' dependency 'com.amazonaws:aws-java-sdk-s3:1.11.802' dependency 'org.ehcache:ehcache:3.8.1' dependency 'com.github.spullara.mustache.java:compiler:0.9.6' dependency 'com.jayway.jsonpath:json-path:2.4.0' dependency 'org.apache.tika:tika-core:1.24.1' dependency 'org.apache.httpcomponents:httpclient:4.5.12' dependency 'io.swagger:swagger-jersey-jaxrs:1.6.1' dependency 'jakarta.management.j2ee:jakarta.management.j2ee-api:1.1.4' dependency 'jakarta.jms:jakarta.jms-api:2.0.3' dependency 'jakarta.xml.bind:jakarta.xml.bind-api:2.3.3' dependency 'org.apache.activemq:activemq-broker:5.15.13' dependency 'org.apache.bval:org.apache.bval.bundle:2.0.3' dependency 'org.mockito:mockito-core:3.3.3' dependency 'org.mockito:mockito-junit-jupiter:3.3.3' dependency 'io.github.classgraph:classgraph:4.8.86' dependency 'org.awaitility:awaitility:4.0.3' dependency 'com.github.spotbugs:spotbugs-annotations:4.0.4' dependency 'javax.cache:cache-api:1.1.1' dependency ('org.dom4j:dom4j:2.1.3') { exclude 'relaxngDatatype:relaxngDatatype' // already in com.sun.xml.bind:jaxb-osgi:2.3.0.1 // FINERACT-940 && FINERACT-966 https://github.com/spotbugs/spotbugs/issues/1128 exclude 'xpp3:xpp3' exclude 'pull-parser:pull-parser' } dependencySet(group: 'com.sun.jersey', version: jerseyVersion) { entry 'jersey-core' entry 'jersey-servlet' entry 'jersey-server' entry 'jersey-json' } dependencySet(group: 'com.sun.jersey.contribs', version: jerseyVersion) { entry 'jersey-spring' entry 'jersey-multipart' } dependencySet(group: 'org.apache.poi', version: '4.1.2') { entry 'poi' entry 'poi-ooxml' entry 'poi-ooxml-schemas' } dependencySet(group: 'io.rest-assured', version: '4.3.0') { entry 'rest-assured' entry 'json-path' entry 'xml-path' } } } /* define the valid syntax level for source files */ sourceCompatibility = JavaVersion.VERSION_11 /* define binary compatibility version */ targetCompatibility = JavaVersion.VERSION_11 project.ext.mysqlUser='root' project.ext.mysqlPassword='mysql' group = 'org.apache.fineract' buildDir = new File(rootProject.projectDir, "../build") repositories { jcenter() // mavenLocal() // useful for local dev using MariaDB4j SNAPSHOTs (not needed for real-world non-SNAPHOT builds) } // If we are running Gradle within Eclipse to enhance classes with OpenJPA, // set the classes directory to point to Eclipse's default build directory if (project.hasProperty('env') && project.getProperty('env') == 'eclipse') { sourceSets.main.java.outputDir = new File(rootProject.projectDir, "bin/main") } eclipse { project { buildCommand([ LaunchConfigHandle: "/.externalToolBuilders/OpenJPA Enhance Builder.launch" ], 'org.eclipse.ui.externaltools.ExternalToolBuilder') } } openjpa { includes = ['**/AbstractPersistableCustom.class', '**/domain/*.class'] enhance { enforcePropertyRestrictions true } } jacoco { toolVersion = jacocoVersion reportsDir = file("$buildDir/reports/jacoco") } jacocoTestReport{ reports{ html.enabled=true xml.enabled=true html.destination file("${buildDir}/code-coverage") } } spotless { format 'misc', { target '**/*.md', '**/*.properties', '**/*.gradle', '**/.gitignore', '**/*.yml', '**/*.xml', '**/**.json', '**/*.sql' targetExclude '**/build/**', '**/bin/**', '**/.settings/**' indentWithSpaces(4) endWithNewline() trimTrailingWhitespace() } java { importOrder() //sort imports alphabetically removeUnusedImports() eclipse().configFile '../config/fineractdev-formatter.xml' endWithNewline() trimTrailingWhitespace() } lineEndings 'UNIX' } rat { verbose = false reportDir = new File(buildDir,'reports/rat') excludes = [ '**/*.launch', '**/licenses/**', '**/*.md', '**/*.github/**', '**/MANIFEST.MF', '**/*.json', '**/*.txt', '**/*.log', '**/fineractdev-eclipse-preferences.epf', '**/template-expected.html', '**/template.mustache', '**/.classpath', '**/.project', '**/.idea/**', '**/*.ipr', '**/*.iws', '**/.settings/**', '**/bin/**', '**/.git/**', '**/.gitignore', '**/.gitkeep', '**/*.iml', //Notice files '**/NOTICE_RELEASE', '**/NOTICE_SOURCE', // Swagger License '**/src/main/resources/swagger-ui/**', // gradle '**/.gradle/**', '**/gradlew', '**/gradlew.bat', '**/gradle/wrapper/gradle-wrapper.properties', '**/caches/**', '**/daemon/**', '**/native/**', '**/wrapper/**', '**/build/**', //Api Docs '**/api-docs/*.*', '**/docs/system-architecture/.htaccess', '**/docs/system-architecture/404.html', '**/docs/system-architecture/index.html', '**/docs/system-architecture/**/*.xml', '**/bootstrap-3.0.0/assets/application.js', '**/system-architecture/js/plugins.js', //Apache License '**/bootstrap-3.0.0/assets/less.js', '**/css/bootstrap-3.0.0/**/*.*', //Public Domain See http://www.JSON.org/js.html '**/bootstrap-3.0.0/assets/json2.js.htm', // MIT License '**/modernizr-2.6.2.min.js', '**/css/normalize.css', '**/assets/filesaver.js', '**/css/fonts/glyphicons-halflings-regular.svg', '**/assets/jszip.js', '**/assets/jquery.js', '**/api-docs/jquery-1.7.min.js', '**/css/toc-0.1.2/**/*.*', '**/docs/system-architecture/css/main.css', '**/system-architecture/js/vendor/jquery-1.9.1.min.js', '**/system-architecture/js/vendor/toc-0.1.2/jquery.toc.min.js', '**/assets/respond.min.js', '**/assets/html5shiv.js', //BSD License '**/assets/uglify.js', //Ignore out folder '**/out/**', // Git build info "**/git.properties", ] } configurations { providedRuntime // needed for Spring Boot executable WAR providedCompile compile() { exclude module: 'hibernate-entitymanager' exclude module: 'hibernate-validator' exclude module: 'activation' exclude module: 'bcmail-jdk14' exclude module: 'bcprov-jdk14' exclude module: 'bctsp-jdk14' exclude module: 'c3p0' exclude module: 'stax-api' exclude module: 'jaxb-api' exclude module: 'jaxb-impl' exclude module: 'jboss-logging' exclude module: 'itext-rtf' exclude module: 'classworlds' } runtime all*.exclude module: 'jul-to-slf4j' // see FINERACT-700 re. ClassCircularityError: java/util/logging/LogRecord } tasks.withType(JavaCompile) { options.compilerArgs += ["-Xlint:unchecked","-Xlint:cast","-Xlint:auxiliaryclass","-Xlint:deprecation", "-Xlint:dep-ann","-Xlint:divzero","-Xlint:empty","-Xlint:exports","-Xlint:fallthrough", "-Xlint:finally","-Xlint:module","-Xlint:opens","-Xlint:options","-Xlint:overloads", "-Xlint:overrides","-Xlint:path","-Xlint:processing","-Xlint:removal", "-Xlint:requires-automatic","-Xlint:requires-transitive-automatic","-Xlint:try", "-Xlint:varargs","-Xlint:preview","-Xlint:static","-Werror"] // TODO FINERACT-959 (gradually) enable -Xlint:all (see "javac -help -X") options.deprecation = true options.errorprone { disableWarningsInGeneratedCode = true //Todo Remove necessary checks from this list disable( "UnusedVariable", "ClassCanBeStatic", "SameNameButDifferent", "StringSplitter", "ImmutableEnumChecker", "BadImport", "UnusedMethod", "ModifiedButNotUsed", "TypeParameterUnusedInFormals", "UnusedNestedClass", "UndefinedEquals", ) //TODO gradually enable these checks error( "DefaultCharset", "RemoveUnusedImports", "WaitNotInLoop", "ThreeLetterTimeZoneID", "VariableNameSameAsType", "UnnecessaryParentheses", "MultipleTopLevelClasses", "MixedMutabilityReturnType", "MultiVariableDeclaration", "AssertEqualsArgumentOrderChecker", "EmptySetMultibindingContributions", "BigDecimalEquals", "MixedArrayDimensions", "PackageLocation", "UseBinds", "IntLongMath", "FloatCast", "ReachabilityFenceUsage", "StreamResourceLeak", "TruthIncompatibleType", "ByteBufferBackingArray", "OrphanedFormatString", "CatchAndPrintStackTrace", "ObjectToString", "AssertThrowsMultipleStatements", "BoxedPrimitiveConstructor", "BoxedPrimitiveEquality", "SynchronizeOnNonFinalField", "WildcardImport", "FutureReturnValueIgnored", "PrivateConstructorForNoninstantiableModule", "ClassNewInstance", "UnsafeFinalization", "JodaPlusMinusLong", "MutableMethodReturnType", "SwitchDefault", "VarTypeName", "ArgumentSelectionDefectChecker", "CompareToZero", "ImmutableEnumChecker", "NarrowingCompoundAssignment", "MissingCasesInEnumSwitch", "ReferenceEquality", "OperatorPrecedence", "EqualsGetClass", "EqualsUnsafeCast", "JdkObsolete", "DoubleBraceInitialization", "InconsistentCapitalization", "MissingOverride", // "ReturnMissingNullable", // "InconsistentOverloads", // "MethodCanBeStatic", // "Var", // "ConstantField", // "UnnecessaryStaticImport", // "ConstructorInvokesOverridable", // "InjectOnConstructorOfAbstractClass", // "StringSplitter", // "UnnecessaryDefaultInEnumSwitch", // "FieldCanBeFinal" ) } options.compilerArgs +=["-Xmaxwarns",1500,"-Xmaxerrs",1500] } apply from: 'dependencies.gradle' /* TODO https://issues.apache.org/jira/browse/FINERACT-939 (dev-dependencies.gradle has been removed, as totally broken) // Pick up dependencies based on the environment, defaults to production if (project.hasProperty('env') && project.getProperty('env') == 'dev') { apply from: 'dev-dependencies.gradle' } else { apply from: 'dependencies.gradle' } */ /* Enable Oauth2 authentication based on environment, default to HTTP basic auth */ if (project.hasProperty('security') && project.getProperty('security') == 'oauth') { if(project.hasProperty('twofactor') && project.getProperty('twofactor') == 'enabled') { copy { from './properties/oauth/twofactor/' into 'src/main/resources/' include '*.properties' } } else { copy { from './properties/oauth/' into 'src/main/resources/' include '*.properties' } } } else { if(project.hasProperty('twofactor') && project.getProperty('twofactor') == 'enabled') { copy { from './properties/basicauth/twofactor/' into 'src/main/resources/' include '*.properties' } } else { copy { from './properties/basicauth/' into 'src/main/resources/' include '*.properties' } } } modernizer { includeTestClasses = true failOnViolations = true violationLogLevel="error" javaVersion = project.targetCompatibility ignorePackages = [] ignoreClassNamePatterns = [ '.*AbstractPersistableCustom', '.*EntityTables' ] ignoreGeneratedClasses = true exclusions = [] exclusionPatterns = [ // To be removed when https://issues.apache.org/jira/browse/FINERACT-826 is fixed 'org/joda/time/.*' ] } compileJava{ dependsOn rat dependsOn spotlessCheck } /* pmd { sourceSets = [sourceSets.main] } */ war { from('../licenses/binary/') { // notice the parens into "WEB-INF/licenses/binary/" // no leading slash } from('../LICENSE_RELEASE') { // notice the parens into "WEB-INF/" // no leading slash } from('../NOTICE_RELEASE') { // notice the parens into "WEB-INF/" // no leading slash } rename ('LICENSE_RELEASE', 'LICENSE') rename ('NOTICE_RELEASE', 'NOTICE') from('../DISCLAIMER') { // notice the parens into "WEB-INF/" // no leading slash } war.finalizedBy(bootWar) } license { header rootProject.file('../APACHE_LICENSETEXT.md') excludes([ "**/git.properties", "**/*.html", "**/*.mustache", "**/package-info.java", "**/keystore.jks", "**/swagger-ui/**", "**/api-docs/**", ]) strictCheck true } task licenseFormatBuildScripts (type:nl.javadude.gradle.plugins.license.License) { source = fileTree(dir: '../', includes: ['**/*.bat', '**/*.sh', '**/*.sql']) } licenseFormat.dependsOn licenseFormatBuildScripts configurations { tomcat } dependencies { tomcat "org.apache.tomcat:tomcat:9.0.36@zip" } dependencies { errorprone "com.google.errorprone:error_prone_core:2.3.4" } cargo { containerId "tomcat9x" local { installer { installConfiguration = configurations.tomcat downloadDir = file("$buildDir/download") extractDir = file("$buildDir/tomcat") } startStopTimeout = 240000 containerProperties { property 'cargo.tomcat.connector.keystoreFile', file('src/main/resources/keystore.jks') property 'cargo.tomcat.connector.keystorePass', 'openmf' property 'cargo.tomcat.httpSecure', true property 'cargo.tomcat.connector.sslProtocol', 'TLS' property 'cargo.tomcat.connector.clientAuth', false property 'cargo.protocol', 'https' property 'cargo.servlet.port', 8443 } } } cargoRunLocal.dependsOn bootWar cargoStartLocal.dependsOn bootWar cargoStartLocal.mustRunAfter "integrationTestClasses" cargoStartLocal.mustRunAfter "enhance" /* 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 /* Exclude maria db related files for non dev builds */ if (!(project.hasProperty('env') && project.getProperty('env') == 'dev')) { sourceSets { main { java { exclude '**/ServerWithMariaDB*' exclude '**/MariaDB4j*' } } test { java { exclude '**/core/boot/tests/**' } } } } sourceSets { integrationTest { compileClasspath += main.output + test.output runtimeClasspath += main.output + test.output } } configurations { integrationTestCompile.extendsFrom testImplementation 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 (and stops it after)." dependsOn cargoStartLocal finalizedBy cargoStopLocal testClassesDirs = project.sourceSets.integrationTest.output.classesDirs classpath = project.sourceSets.integrationTest.runtimeClasspath } integrationTest { useJUnitPlatform() testLogging { // FINERACT-927 events "skipped", "failed" showStandardStreams = false exceptionFormat "full" } } test { useJUnitPlatform() testLogging { // FINERACT-927 events "skipped", "failed" showStandardStreams = false exceptionFormat "full" } } import groovy.sql.Sql repositories { mavenCentral() } configurations { driver } dependencies { driver 'org.drizzle.jdbc:drizzle-jdbc:1.4' checkstyle 'com.puppycrawl.tools:checkstyle:8.33' checkstyle 'com.github.sevntu-checkstyle:sevntu-checks:1.37.1' } 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)" doLast { def sql = Sql.newInstance( 'jdbc:mysql:thin://localhost:3306/', mysqlUser, mysqlPassword, 'org.drizzle.jdbc.DrizzleDriver' ) sql.execute( 'create database '+"`$dbName`" ) } } task dropDB { description= "Drops the specified database. The database name has to be passed (like: -PdbName=someDBname)" doLast { def sql = Sql.newInstance( 'jdbc:mysql:thin://localhost:3306/', mysqlUser, mysqlPassword, 'org.drizzle.jdbc.DrizzleDriver' ) sql.execute( 'DROP DATABASE '+"`$dbName`") } } task setBlankPassword { doLast { def sql = Sql.newInstance( 'jdbc:mysql:thin://localhost:3306/', mysqlUser, mysqlPassword, 'org.drizzle.jdbc.DrizzleDriver' ) sql.execute('USE `fineract_tenants`') sql.execute('UPDATE fineract_tenants.tenants SET schema_server = \'localhost\', schema_server_port = \'3306\', schema_username = \'mifos\', schema_password = \'mysql\' WHERE id=1;') } } springBoot { mainClassName = 'org.apache.fineract.ServerApplication' } bootWar { mainClassName = 'org.apache.fineract.ServerApplication' duplicatesStrategy = DuplicatesStrategy.EXCLUDE } bootJar { duplicatesStrategy = DuplicatesStrategy.EXCLUDE } // To generate an HTML report instead of XML spotbugs { reportLevel = 'high' showProgress = true } // https://github.com/spotbugs/spotbugs-gradle-plugin/issues/242 spotbugsMain { reports { html { enabled = true stylesheet = 'fancy-hist.xsl' } } } spotbugsTest { reports { html { enabled = true stylesheet = 'fancy-hist.xsl' } } } spotbugsIntegrationTest { reports { html { enabled = true stylesheet = 'fancy-hist.xsl' } } } gitProperties { gitPropertiesResourceDir = "$buildDir/classes/java/main/resources" dateFormat = "yyyy-MM-dd'T'HH:mmZ" dateFormatTimeZone = "GMT" failOnNoGitDirectory = false } // make sure the generateGitProperties task always executes (even when git.properties is not changed) generateGitProperties.outputs.upToDateWhen { false }