modernize locale instantiations (fixes an error found by the modernizer plugin) - use Locale.of() instead of new Locale() use recommended gradle toolchain syntax to specify Java class file format version see https://docs.gradle.org/current/userguide/java_plugin.html#toolchain_and_compatibility mark html5 for later fix (it's the default) use dummy byte arrays to work around mockito exception ``` org.mockito.exceptions.base.MockitoException: Mockito cannot mock this class: class java.nio.ByteBuffer. If you're not sure why you're getting this error, please open an issue on GitHub. Java : 21 JVM vendor name : Ubuntu JVM vendor version : 21.0.6+7-Ubuntu-122.04.1 JVM name : OpenJDK 64-Bit Server VM JVM version : 21.0.6+7-Ubuntu-122.04.1 JVM info : mixed mode, sharing OS name : Linux OS version : 5.15.0-136-generic You are seeing this disclaimer because Mockito is configured to create inlined mocks. You can learn about inline mocks and their limitations under item #39 of the Mockito class javadoc. Underlying exception : org.mockito.exceptions.base.MockitoException: Unsupported settings with this type 'java.nio.ByteBuffer' at app//org.apache.fineract.infrastructure.event.external.jobs.SendAsynchronousEventsTaskletTest.givenBatchSize2WhenEventSendFailsThenExecutionStops(SendAsynchronousEventsTaskletTest.java:170) at java.base@21.0.6/java.lang.reflect.Method.invoke(Method.java:580) at java.base@21.0.6/java.util.ArrayList.forEach(ArrayList.java:1596) at java.base@21.0.6/java.util.ArrayList.forEach(ArrayList.java:1596) Caused by: org.mockito.exceptions.base.MockitoException: Unsupported settings with this type 'java.nio.ByteBuffer' at app//net.bytebuddy.TypeCache.findOrInsert(TypeCache.java:168) at app//net.bytebuddy.TypeCache$WithInlineExpunction.findOrInsert(TypeCache.java:399) at app//net.bytebuddy.TypeCache.findOrInsert(TypeCache.java:190) at app//net.bytebuddy.TypeCache$WithInlineExpunction.findOrInsert(TypeCache.java:410) ... 4 more ``` see also: https://stackoverflow.com/questions/47046996/java-lang-unsupportedoperationexception-when-mocking-java-nio-bytebuffer-class wrap byte arrays with ByteBuffer fix: ``` /home/adamm/git/apache/fineract/fineract-provider/src/test/java/org/apache/fineract/infrastructure/event/external/jobs/SendAsynchronousEventsTaskletTest.java:148: error: incompatible types: byte[] cannot be converted to ByteBuffer "anidempotencyKey", "aSchema", "dummy".getBytes()); ^ /home/adamm/git/apache/fineract/fineract-provider/src/test/java/org/apache/fineract/infrastructure/event/external/jobs/SendAsynchronousEventsTaskletTest.java:170: error: incompatible types: byte[] cannot be converted to ByteBuffer "anidempotencyKey", "aSchema", "dummy".getBytes()); ^ /home/adamm/git/apache/fineract/fineract-provider/src/test/java/org/apache/fineract/infrastructure/event/external/jobs/SendAsynchronousEventsTaskletTest.java:189: error: incompatible types: byte[] cannot be converted to ByteBuffer "anidempotencyKey", "aSchema", "dummy".getBytes()); ^ /home/adamm/git/apache/fineract/fineract-provider/src/test/java/org/apache/fineract/infrastructure/event/external/jobs/SendAsynchronousEventsTaskletTest.java:210: error: incompatible types: byte[] cannot be converted to ByteBuffer "anidempotencyKey", "aSchema", "dummy".getBytes()); ``` ...and use StandardCharsets with getBytes
408 lines
13 KiB
Groovy
408 lines
13 KiB
Groovy
/**
|
|
* 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 = 'Fineract Provider'
|
|
|
|
apply plugin: 'org.zeroturnaround.gradle.jrebel'
|
|
apply plugin: 'java'
|
|
apply plugin: 'eclipse'
|
|
apply plugin: 'org.springframework.boot'
|
|
apply plugin: 'com.gorylenko.gradle-git-properties'
|
|
apply plugin: 'io.swagger.core.v3.swagger-gradle-plugin'
|
|
apply plugin: 'com.google.cloud.tools.jib'
|
|
apply plugin: 'org.springframework.boot'
|
|
apply plugin: 'se.thinkcode.cucumber-runner'
|
|
|
|
check.dependsOn('cucumber')
|
|
|
|
compileJava.doLast {
|
|
def mainSS = sourceSets.main
|
|
def source = mainSS.java.classesDirectory.get()
|
|
copy {
|
|
from file("src/main/resources/jpa/persistence.xml")
|
|
into "${source}/META-INF/"
|
|
}
|
|
javaexec {
|
|
description = 'Performs EclipseLink static weaving of entity classes'
|
|
def target = source
|
|
main 'org.eclipse.persistence.tools.weaving.jpa.StaticWeave'
|
|
args '-persistenceinfo', source, source, target
|
|
classpath sourceSets.main.runtimeClasspath
|
|
}
|
|
delete {
|
|
delete "${source}/META-INF/persistence.xml"
|
|
}
|
|
}
|
|
|
|
// Configuration for Swagger documentation generation task
|
|
// https://github.com/swagger-api/swagger-core/tree/master/modules/swagger-gradle-plugin
|
|
import org.apache.tools.ant.filters.ReplaceTokens
|
|
|
|
task prepareInputYaml {
|
|
outputs.file("${buildDir}/tmp/swagger/fineract-input.yaml")
|
|
|
|
doLast {
|
|
copy {
|
|
from file("${projectDir}/config/swagger/fineract-input.yaml.template")
|
|
into file("${buildDir}/tmp/swagger")
|
|
rename { String filename -> return 'fineract-input.yaml' }
|
|
filter(ReplaceTokens, tokens: [VERSION: "${project.version}".toString()])
|
|
}
|
|
}
|
|
}
|
|
|
|
resolve {
|
|
logging.captureStandardOutput LogLevel.INFO
|
|
outputFileName = 'fineract'
|
|
outputFormat = 'JSONANDYAML'
|
|
prettyPrint = false
|
|
classpath = sourceSets.main.runtimeClasspath
|
|
buildClasspath = classpath
|
|
outputDir = file("${buildDir}/classes/java/main/static")
|
|
openApiFile = file("${buildDir}/tmp/swagger/fineract-input.yaml")
|
|
sortOutput = true
|
|
dependsOn(prepareInputYaml)
|
|
}
|
|
|
|
configurations {
|
|
providedRuntime // needed for Spring Boot executable WAR
|
|
providedCompile
|
|
implementation
|
|
testImplementation
|
|
cucumberRuntime {
|
|
extendsFrom testImplementation
|
|
}
|
|
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
|
|
}
|
|
|
|
dependencies {
|
|
implementation project(':fineract-core')
|
|
implementation 'org.springframework.boot:spring-boot-starter-test'
|
|
implementation 'org.mockito:mockito-core'
|
|
implementation 'org.mockito:mockito-junit-jupiter'
|
|
implementation 'org.junit.jupiter:junit-jupiter-api'
|
|
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
|
|
implementation 'org.liquibase:liquibase-core'
|
|
}
|
|
|
|
apply from: 'dependencies.gradle'
|
|
|
|
// Configuration for the modernizer plugin
|
|
// https://github.com/andygoossens/gradle-modernizer-plugin
|
|
modernizer {
|
|
ignoreClassNamePatterns = [
|
|
'.*AbstractPersistableCustom',
|
|
'.*EntityTables',
|
|
'.*domain.*'
|
|
]
|
|
}
|
|
|
|
// 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, "fineract-provider/bin/main")
|
|
}
|
|
|
|
eclipse {
|
|
project {
|
|
buildCommand([ LaunchConfigHandle: "<project>/.externalToolBuilders/OpenJPA Enhance Builder.launch" ], 'org.eclipse.ui.externaltools.ExternalToolBuilder')
|
|
}
|
|
}
|
|
|
|
/* http://stackoverflow.com/questions/19653311/jpa-repository-works-in-idea-and-production-but-not-in-gradle */
|
|
sourceSets.main.output.resourcesDir = sourceSets.main.java.classesDirectory
|
|
sourceSets.test.output.resourcesDir = sourceSets.test.java.classesDirectory
|
|
|
|
if (!(project.hasProperty('env') && project.getProperty('env') == 'dev')) {
|
|
sourceSets {
|
|
test {
|
|
java {
|
|
exclude '**/core/boot/tests/**'
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// Configuration for SQL tasks
|
|
// https://docs.groovy-lang.org/latest/html/api/groovy/sql/Sql.html
|
|
import groovy.sql.Sql
|
|
|
|
project.ext.mysqlUser='root'
|
|
project.ext.mysqlPassword='mysql'
|
|
project.ext.pgUser='root'
|
|
project.ext.pgPassword='postgres'
|
|
|
|
configurations {
|
|
driver
|
|
}
|
|
dependencies {
|
|
driver 'org.mariadb.jdbc:mariadb-java-client'
|
|
driver 'org.postgresql:postgresql'
|
|
driver 'mysql:mysql-connector-java:8.0.33'
|
|
}
|
|
|
|
URLClassLoader loader = GroovyObject.class.classLoader
|
|
configurations.driver.each {File file ->
|
|
loader.addURL(file.toURL())
|
|
}
|
|
|
|
task createDB {
|
|
description= "Creates the MariaDB Database. Needs database name to be passed (like: -PdbName=someDBname)"
|
|
doLast {
|
|
def sql = Sql.newInstance( 'jdbc:mariadb://localhost:3306/', mysqlUser, mysqlPassword, 'org.mariadb.jdbc.Driver' )
|
|
sql.execute( 'CREATE DATABASE '+"`$dbName` CHARACTER SET utf8mb4" )
|
|
}
|
|
}
|
|
|
|
task dropDB {
|
|
description= "Drops the specified MariaDB database. The database name has to be passed (like: -PdbName=someDBname)"
|
|
doLast {
|
|
def sql = Sql.newInstance( 'jdbc:mariadb://localhost:3306/', mysqlUser, mysqlPassword, 'org.mariadb.jdbc.Driver' )
|
|
sql.execute( 'DROP DATABASE '+"`$dbName`")
|
|
}
|
|
}
|
|
|
|
task createPGDB {
|
|
description= "Creates the PostgreSQL Database. Needs database name to be passed (like: -PdbName=someDBname)"
|
|
doLast {
|
|
def sql = Sql.newInstance( 'jdbc:postgresql://localhost:5432/', pgUser, pgPassword, 'org.postgresql.Driver' )
|
|
sql.execute( 'create database '+"$dbName" )
|
|
}
|
|
}
|
|
|
|
task dropPGDB {
|
|
description= "Drops the specified PostgreSQL database. The database name has to be passed (like: -PdbName=someDBname)"
|
|
doLast {
|
|
def sql = Sql.newInstance( 'jdbc:postgresql://localhost:5432/', pgUser, pgPassword, 'org.postgresql.Driver' )
|
|
sql.execute( 'DROP DATABASE '+ "$dbName")
|
|
}
|
|
}
|
|
|
|
task createMySQLDB {
|
|
description= "Creates the MySQL Database. Needs database name to be passed (like: -PdbName=someDBname)"
|
|
doLast {
|
|
def sql = Sql.newInstance( 'jdbc:mysql://localhost:3306/', mysqlUser, mysqlPassword, 'com.mysql.cj.jdbc.Driver' )
|
|
sql.execute( 'CREATE DATABASE '+"`$dbName` CHARACTER SET utf8mb4" )
|
|
}
|
|
}
|
|
|
|
task dropMySQLDB {
|
|
description= "Drops the specified MySQL database. The database name has to be passed (like: -PdbName=someDBname)"
|
|
doLast {
|
|
def sql = Sql.newInstance( 'jdbc:mysql://localhost:3306/', mysqlUser, mysqlPassword, 'com.mysql.cj.jdbc.Driver' )
|
|
sql.execute( 'DROP DATABASE '+"`$dbName`")
|
|
}
|
|
}
|
|
|
|
task setBlankPassword {
|
|
doLast {
|
|
def sql = Sql.newInstance( 'jdbc:mariadb://localhost:3306/', mysqlUser, mysqlPassword, 'org.mariadb.jdbc.Driver' )
|
|
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;')
|
|
}
|
|
}
|
|
|
|
bootRun {
|
|
jvmArgs = [
|
|
"-Dspring.output.ansi.enabled=ALWAYS"
|
|
]
|
|
|
|
dependencies {
|
|
implementation 'org.mariadb.jdbc:mariadb-java-client'
|
|
implementation 'org.postgresql:postgresql'
|
|
}
|
|
}
|
|
|
|
springBoot {
|
|
mainClass = 'org.apache.fineract.ServerApplication'
|
|
}
|
|
|
|
bootJar {
|
|
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
|
manifest {
|
|
attributes('Main-Class': 'org.springframework.boot.loader.launch.PropertiesLauncher', 'Implementation-Title': 'Apache Fineract', 'Implementation-Version': project.version)
|
|
}
|
|
archiveClassifier = ''
|
|
dependsOn resolve
|
|
}
|
|
|
|
jib {
|
|
from {
|
|
image = 'azul/zulu-openjdk-alpine:21'
|
|
platforms {
|
|
platform {
|
|
architecture = System.getProperty("os.arch").equals("aarch64")?"arm64":"amd64"
|
|
os = 'linux'
|
|
}
|
|
}
|
|
}
|
|
|
|
to {
|
|
image = 'fineract'
|
|
tags = [
|
|
"${project.version}",
|
|
'latest'
|
|
]
|
|
}
|
|
|
|
container {
|
|
creationTime = 'USE_CURRENT_TIMESTAMP'
|
|
mainClass = 'org.apache.fineract.ServerApplication'
|
|
extraClasspath = ['/app/plugins/*']
|
|
args = [
|
|
'-Duser.home=/tmp',
|
|
'-Dfile.encoding=UTF-8',
|
|
'-Duser.timezone=UTC',
|
|
'-Djava.security.egd=file:/dev/./urandom'
|
|
]
|
|
ports = ['8080/tcp', '8443/tcp']
|
|
labels = [maintainer: 'Aleksandar Vidakovic <aleks@apache.org>']
|
|
user = 'nobody:nogroup'
|
|
}
|
|
|
|
allowInsecureRegistries = true
|
|
|
|
dependencies {
|
|
implementation 'org.mariadb.jdbc:mariadb-java-client'
|
|
implementation 'org.postgresql:postgresql'
|
|
}
|
|
|
|
pluginExtensions {
|
|
pluginExtension {
|
|
implementation = 'com.google.cloud.tools.jib.gradle.extension.layerfilter.JibLayerFilterExtension'
|
|
configuration {
|
|
filters {
|
|
filter {
|
|
glob = '/app/resources/**'
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
task migrateDatabase {
|
|
doFirst {
|
|
println 'Executing liquibase database migration to version '+"$dbVersion"
|
|
|
|
def dbUrl='jdbc:'+"$dbType"+'://'+"$dbHost"+':'+"$dbPort"+'/'+"$dbName"
|
|
def changeLogFilePath='fineract-provider/src/main/resources/db/changelog/tenant/upgrades/0000_upgrade_to_'+"$dbVersion"+'.xml'
|
|
|
|
liquibase {
|
|
activities {
|
|
main {
|
|
changeLogFile changeLogFilePath
|
|
url dbUrl
|
|
username project.ext.mysqlUser
|
|
password project.ext.mysqlPassword
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
cucumber {
|
|
tags = 'not @ignore'
|
|
main = 'io.cucumber.core.cli.Main'
|
|
shorten = 'argfile'
|
|
plugin = [
|
|
'pretty',
|
|
'html:build/reports/cucumber/report.html',
|
|
'json:build/reports/cucumber/report.json',
|
|
'junit:build/reports/cucumber/report.xml'
|
|
]
|
|
}
|
|
|
|
tasks.jibDockerBuild.dependsOn(bootJar)
|
|
|
|
// Configuration for git properties gradle plugin
|
|
// https://github.com/n0mer/gradle-git-properties
|
|
gitProperties {
|
|
gitPropertiesResourceDir = file("$buildDir/classes/java/main")
|
|
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 }
|
|
|
|
// NOTE: Gradle suggested these dependencies
|
|
jar.dependsOn resolve
|
|
test.dependsOn resolve
|
|
checkstyleMain.dependsOn resolve
|
|
checkstyleTest.dependsOn resolve
|
|
rat.dependsOn prepareInputYaml
|
|
spotbugsTest.dependsOn resolve
|
|
compileTestJava.dependsOn ':fineract-client:processResources', ':fineract-avro-schemas:processResources'
|
|
resolveMainClassName.dependsOn resolve
|
|
processResources.dependsOn compileJava
|
|
|
|
javadoc {
|
|
dependsOn resolve
|
|
}
|
|
|
|
task devRun(type: org.springframework.boot.gradle.tasks.run.BootRun) {
|
|
description = 'Runs the application quickly for development by skipping quality checks'
|
|
group = 'Application'
|
|
|
|
// Configure the build to skip quality checks
|
|
gradle.taskGraph.whenReady { graph ->
|
|
if (graph.hasTask(devRun)) {
|
|
tasks.matching { task ->
|
|
task.name in ['checkstyle', 'checkstyleMain', 'checkstyleTest',
|
|
'spotlessCheck', 'spotlessApply',
|
|
'spotbugsMain', 'spotbugsTest',
|
|
'javadoc', 'javadocJar',
|
|
'modernizer',
|
|
'testClasses']
|
|
}.configureEach {
|
|
enabled = false
|
|
}
|
|
// Also disable error prone compilation flags
|
|
tasks.withType(JavaCompile).configureEach {
|
|
options.errorprone.enabled = false
|
|
}
|
|
}
|
|
}
|
|
|
|
// Inherit all bootRun settings
|
|
classpath = bootRun.classpath
|
|
mainClass = bootRun.mainClass
|
|
jvmArgs = bootRun.jvmArgs
|
|
|
|
doFirst {
|
|
println "Running in development mode - quality checks are disabled"
|
|
}
|
|
}
|