FINERACT-2181: Gradle task rework - Optimized weaving across all modules

This commit is contained in:
Adam Saghy
2025-06-22 22:41:34 +02:00
parent ee5290c92e
commit db28259b1a
36 changed files with 1310 additions and 943 deletions
+55 -61
View File
@@ -30,30 +30,19 @@ 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"
}
// Static weaving is now configured in gradle/static-weaving.gradle
// This ensures consistent configuration across all modules with JPA entities
// Add dependency on avro schemas
compileJava {
dependsOn ':fineract-avro-schemas:buildJavaSdk'
}
// 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 {
tasks.register('prepareInputYaml') {
outputs.file("${buildDir}/tmp/swagger/fineract-input.yaml")
doLast {
@@ -139,10 +128,6 @@ eclipse {
}
}
/* 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 {
@@ -176,57 +161,57 @@ 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)"
tasks.register('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" )
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)"
tasks.register('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`")
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)"
tasks.register('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" )
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)"
tasks.register('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")
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)"
tasks.register('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" )
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)"
tasks.register('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`")
def sql = Sql.newInstance('jdbc:mysql://localhost:3306/', mysqlUser, mysqlPassword, 'com.mysql.cj.jdbc.Driver')
sql.execute('DROP DATABASE ' + "`$dbName`")
}
}
task setBlankPassword {
tasks.register('setBlankPassword') {
doLast {
def sql = Sql.newInstance( 'jdbc:mariadb://localhost:3306/', mysqlUser, mysqlPassword, 'org.mariadb.jdbc.Driver' )
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;')
}
@@ -234,7 +219,7 @@ task setBlankPassword {
bootRun {
jvmArgs = [
"-Dspring.output.ansi.enabled=ALWAYS"
"-Dspring.output.ansi.enabled=ALWAYS"
]
dependencies {
@@ -290,6 +275,15 @@ jib {
user = 'nobody:nogroup'
}
extraDirectories {
paths {
path {
from = layout.buildDirectory.dir("resources/main").get().asFile
into = '/app/classes'
}
}
}
allowInsecureRegistries = true
dependencies {
@@ -311,12 +305,12 @@ jib {
}
}
task migrateDatabase {
tasks.register('migrateDatabase') {
doFirst {
println 'Executing liquibase database migration to version '+"$dbVersion"
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'
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 {
@@ -372,20 +366,20 @@ javadoc {
dependsOn resolve
}
task devRun(type: org.springframework.boot.gradle.tasks.run.BootRun) {
tasks.register('devRun', 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 ->
tasks.matching { task ->
task.name in ['checkstyle', 'checkstyleMain', 'checkstyleTest',
'spotlessCheck', 'spotlessApply',
'spotbugsMain', 'spotbugsTest',
'javadoc', 'javadocJar',
'modernizer',
'testClasses']
'spotlessCheck', 'spotlessApply',
'spotbugsMain', 'spotbugsTest',
'javadoc', 'javadocJar',
'modernizer',
'testClasses']
}.configureEach {
enabled = false
}
@@ -400,7 +394,7 @@ task devRun(type: org.springframework.boot.gradle.tasks.run.BootRun) {
classpath = bootRun.classpath
mainClass = bootRun.mainClass
jvmArgs = bootRun.jvmArgs
doFirst {
println "Running in development mode - quality checks are disabled"
}