FINERACT-2181: Some tweaks in the gradle build to ensure correct task processing

This commit is contained in:
Adam Saghy
2025-05-25 22:12:22 +02:00
parent 25ef93a30b
commit 6cb60f48fc
36 changed files with 522 additions and 393 deletions
+72 -60
View File
@@ -30,30 +30,46 @@ 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"
}
tasks.register('staticWeaveJpa', JavaExec) {
group = "build"
description = "Performs EclipseLink static weaving of entity classes"
dependsOn classes
def classesDir = file("$buildDir/classes/java/main")
mainClass.set('org.eclipse.persistence.tools.weaving.jpa.StaticWeave')
classpath = sourceSets.main.runtimeClasspath
args '-persistenceinfo', classesDir.absolutePath, classesDir.absolutePath, classesDir.absolutePath
}
staticWeaveJpa.doLast {
delete "${sourceSets.main.output.classesDirs.asPath}/META-INF/persistence.xml"
}
tasks.named('classes') {
finalizedBy staticWeaveJpa
}
tasks.named('processResources') {
from('src/main/resources')
into sourceSets.main.java.classesDirectory
outputs.upToDateWhen { false }
}
tasks.named('staticWeaveJpa') {
mustRunAfter tasks.named('resolve')
}
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 +155,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 +188,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;')
}
@@ -311,12 +323,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 +384,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 +412,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"
}
@@ -433,7 +433,7 @@ springdoc.pathsToMatch=/api/**
springdoc.use-management-port=${SPRINGDOC_USE_MANAGEMENT_PORT:false}
springdoc.show-actuator=${SPRINGDOC_SHOW_ACTUATOR:false}
spring.web.resources.static-locations=classpath:/static/
spring.web.resources.static-locations=classpath:/static/, /swagger/
spring.main.allow-bean-definition-overriding=true
spring.task.scheduling.pool.size=4