From 6cb60f48fcd4bb5f2ae419c48fef7bf5b4eb233e Mon Sep 17 00:00:00 2001 From: Adam Saghy Date: Sun, 25 May 2025 19:38:45 +0200 Subject: [PATCH] FINERACT-2181: Some tweaks in the gradle build to ensure correct task processing --- build.gradle | 100 ++++++------- fineract-accounting/build.gradle | 50 ++++--- .../accounting => META-INF}/persistence.xml | 0 .../accounting/module-changelog-master.xml | 0 fineract-avro-schemas/build.gradle | 16 ++- fineract-branch/build.gradle | 50 ++++--- .../{jpa/branch => META-INF}/persistence.xml | 0 fineract-charge/build.gradle | 50 ++++--- .../{jpa/charge => META-INF}/persistence.xml | 0 .../module/charge/module-changelog-master.xml | 0 fineract-client/build.gradle | 58 ++++---- fineract-command/build.gradle | 2 +- fineract-core/build.gradle | 44 +++--- .../{jpa/core => META-INF}/persistence.xml | 0 fineract-doc/build.gradle | 6 +- fineract-document/build.gradle | 46 +++--- .../document => META-INF}/persistence.xml | 0 fineract-investor/build.gradle | 50 ++++--- .../investor => META-INF}/persistence.xml | 0 fineract-loan/build.gradle | 53 ++++--- .../{jpa/loan => META-INF}/persistence.xml | 0 fineract-progressive-loan/build.gradle | 50 ++++--- .../persistence.xml | 0 fineract-provider/build.gradle | 132 ++++++++++-------- .../{jpa => META-INF}/persistence.xml | 0 .../src/main/resources/application.properties | 2 +- fineract-rates/build.gradle | 50 ++++--- .../{jpa/rates => META-INF}/persistence.xml | 0 .../module/rates/module-changelog-master.xml | 0 fineract-report/build.gradle | 50 ++++--- .../{jpa/report => META-INF}/persistence.xml | 0 fineract-savings/build.gradle | 50 ++++--- .../{jpa/savings => META-INF}/persistence.xml | 0 fineract-tax/build.gradle | 50 ++++--- .../{jpa/taxes => META-INF}/persistence.xml | 0 fineract-war/build.gradle | 6 +- 36 files changed, 522 insertions(+), 393 deletions(-) rename fineract-accounting/src/main/resources/{jpa/accounting => META-INF}/persistence.xml (100%) rename fineract-accounting/src/main/resources/{jpa/accounting => }/db/changelog/tenant/module/accounting/module-changelog-master.xml (100%) rename fineract-branch/src/main/resources/{jpa/branch => META-INF}/persistence.xml (100%) rename fineract-charge/src/main/resources/{jpa/charge => META-INF}/persistence.xml (100%) rename fineract-charge/src/main/resources/{jpa/charge => }/db/changelog/tenant/module/charge/module-changelog-master.xml (100%) rename fineract-core/src/main/resources/{jpa/core => META-INF}/persistence.xml (100%) rename fineract-document/src/main/resources/{jpa/document => META-INF}/persistence.xml (100%) rename fineract-investor/src/main/resources/{jpa/investor => META-INF}/persistence.xml (100%) rename fineract-loan/src/main/resources/{jpa/loan => META-INF}/persistence.xml (100%) rename fineract-progressive-loan/src/main/resources/{jpa/progressiveloan => META-INF}/persistence.xml (100%) rename fineract-provider/src/main/resources/{jpa => META-INF}/persistence.xml (100%) rename fineract-rates/src/main/resources/{jpa/rates => META-INF}/persistence.xml (100%) rename fineract-rates/src/main/resources/{jpa/rates => }/db/changelog/tenant/module/rates/module-changelog-master.xml (100%) rename fineract-report/src/main/resources/{jpa/report => META-INF}/persistence.xml (100%) rename fineract-savings/src/main/resources/{jpa/savings => META-INF}/persistence.xml (100%) rename fineract-tax/src/main/resources/{jpa/taxes => META-INF}/persistence.xml (100%) diff --git a/build.gradle b/build.gradle index 821b09e76..9ff21e728 100644 --- a/build.gradle +++ b/build.gradle @@ -365,12 +365,12 @@ configure(project.fineractJavaProjects) { withJavadocJar() } - tasks.withType(ProcessResources) { + tasks.withType(ProcessResources).configureEach { destinationDir = layout.buildDirectory.dir('classes/java/main').get().asFile } // Add performance optimizations - configurations.all { + configurations.configureEach { resolutionStrategy { cacheChangingModulesFor 0, 'seconds' cacheDynamicVersionsFor 0, 'seconds' @@ -422,40 +422,40 @@ configure(project.fineractJavaProjects) { configurations { api.setCanBeResolved(true) } - tasks.withType(Copy) { + tasks.withType(Copy).configureEach { duplicatesStrategy = DuplicatesStrategy.EXCLUDE } - tasks.withType(JavaCompile) { + tasks.withType(JavaCompile).configureEach { options.compilerArgs += [ - "-Xlint:cast", - "-Xlint:auxiliaryclass", - "-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 needs to be disabled because EclipseLink's static weaving doesn't generate warning-free code - // and during an IntelliJ recompilation, it fails - //"-Werror", - "-Xmaxwarns", - "1500", - "-Xmaxerrs", - "1500" + "-Xlint:cast", + "-Xlint:auxiliaryclass", + "-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 needs to be disabled because EclipseLink's static weaving doesn't generate warning-free code + // and during an IntelliJ recompilation, it fails + //"-Werror", + "-Xmaxwarns", + "1500", + "-Xmaxerrs", + "1500" ] // TODO FINERACT-959 (gradually) enable -Xlint:all (see "javac -help -X") @@ -738,11 +738,13 @@ configure(project.fineractJavaProjects) { ] } - tasks.withType(Javadoc) { - options.addStringOption('Xdoclint:none', '-quiet') - options.encoding = 'UTF-8' - // Ignore any errors during javadoc generation - failOnError = false + tasks.withType(Javadoc).tap { + configureEach { + options.addStringOption('Xdoclint:none', '-quiet') + options.encoding = 'UTF-8' + // Ignore any errors during javadoc generation + failOnError = false + } } } @@ -868,17 +870,17 @@ configure(project.fineractPublishProjects) { } } -task printSourceSetInformation() { - doLast{ - sourceSets.each { srcSet -> - println "["+srcSet.name+"]" - print "-->Source directories: "+srcSet.allJava.srcDirs+"\n" - print "-->Output directories: "+srcSet.output.classesDirs.files+"\n" - print "-->Compile classpath:\n" - srcSet.compileClasspath.files.each { - print " "+it.path+"\n" + tasks.register('printSourceSetInformation') { + doLast { + sourceSets.each { srcSet -> + println "[" + srcSet.name + "]" + print "-->Source directories: " + srcSet.allJava.srcDirs + "\n" + print "-->Output directories: " + srcSet.output.classesDirs.files + "\n" + print "-->Compile classpath:\n" + srcSet.compileClasspath.files.each { + print " " + it.path + "\n" + } + println "" } - println "" } } -} diff --git a/fineract-accounting/build.gradle b/fineract-accounting/build.gradle index 916069b1f..ceb6895f8 100644 --- a/fineract-accounting/build.gradle +++ b/fineract-accounting/build.gradle @@ -21,23 +21,35 @@ description = 'Fineract Accounting' apply plugin: 'java' apply plugin: 'eclipse' -compileJava.doLast { - def mainSS = sourceSets.main - def source = mainSS.java.classesDirectory.get() - copy { - from file("src/main/resources/jpa/accounting/persistence.xml") - into "${source}/META-INF/" - } - javaexec { - description = 'Performs EclipseLink static weaving of entity classes' - def target = source - mainClass = '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 } +} + +compileJava { + dependsOn ':fineract-avro-schemas:buildJavaSdk' } configurations { @@ -85,10 +97,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 { diff --git a/fineract-accounting/src/main/resources/jpa/accounting/persistence.xml b/fineract-accounting/src/main/resources/META-INF/persistence.xml similarity index 100% rename from fineract-accounting/src/main/resources/jpa/accounting/persistence.xml rename to fineract-accounting/src/main/resources/META-INF/persistence.xml diff --git a/fineract-accounting/src/main/resources/jpa/accounting/db/changelog/tenant/module/accounting/module-changelog-master.xml b/fineract-accounting/src/main/resources/db/changelog/tenant/module/accounting/module-changelog-master.xml similarity index 100% rename from fineract-accounting/src/main/resources/jpa/accounting/db/changelog/tenant/module/accounting/module-changelog-master.xml rename to fineract-accounting/src/main/resources/db/changelog/tenant/module/accounting/module-changelog-master.xml diff --git a/fineract-avro-schemas/build.gradle b/fineract-avro-schemas/build.gradle index 5afaaec48..e94a01d94 100644 --- a/fineract-avro-schemas/build.gradle +++ b/fineract-avro-schemas/build.gradle @@ -57,9 +57,11 @@ tasks.register('preprocessAvroSchemas', PreprocessAvroSchemasTask) { inputDir = file("$projectDir/src/main/avro") bigDecimalTemplate = file("$projectDir/src/main/resources/avro-templates/bigdecimal.avsc") outputDir = file("$buildDir/generated/avro/src/main/avro") + finalizedBy buildJavaSdk } -task buildJavaSdk(type: GenerateAvroJavaTask) { +tasks.register('buildJavaSdk', GenerateAvroJavaTask) { + dependsOn preprocessAvroSchemas, spotlessJsonApply source("$buildDir/generated/avro/src/main/avro") outputDir = file("$buildDir/generated/java/src/main/java") templateDirectory = "$projectDir/src/main/resources/avro-generator-templates/" @@ -73,12 +75,10 @@ spotless { } } -buildJavaSdk.dependsOn(preprocessAvroSchemas, spotlessJsonApply) - sourceSets { main { java { - srcDir file("$buildDir/generated/java/src/main/java") + srcDirs += "$buildDir/generated/java/src/main/java" } resources { srcDir file("$projectDir/src/main/resources") @@ -97,7 +97,7 @@ jar { } compileJava { - dependsOn buildJavaSdk + dependsOn buildJavaSdk, processResources source = sourceSets.main.java.srcDirs options.compilerArgs += ['-parameters'] } @@ -131,3 +131,9 @@ tasks.named('sourcesJar') { dependsOn tasks.named('buildJavaSdk') duplicatesStrategy = DuplicatesStrategy.EXCLUDE } + +tasks.named('processResources') { + from('src/main/resources') + into sourceSets.main.java.classesDirectory + outputs.upToDateWhen { false } +} diff --git a/fineract-branch/build.gradle b/fineract-branch/build.gradle index 04a3b10e4..505273c14 100644 --- a/fineract-branch/build.gradle +++ b/fineract-branch/build.gradle @@ -21,23 +21,35 @@ description = 'Fineract Branch' apply plugin: 'java' apply plugin: 'eclipse' -compileJava.doLast { - def mainSS = sourceSets.main - def source = mainSS.java.classesDirectory.get() - copy { - from file("src/main/resources/jpa/branch/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 } +} + +compileJava { + dependsOn ':fineract-avro-schemas:buildJavaSdk' } // Configuration for Swagger documentation generation task @@ -91,10 +103,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 { diff --git a/fineract-branch/src/main/resources/jpa/branch/persistence.xml b/fineract-branch/src/main/resources/META-INF/persistence.xml similarity index 100% rename from fineract-branch/src/main/resources/jpa/branch/persistence.xml rename to fineract-branch/src/main/resources/META-INF/persistence.xml diff --git a/fineract-charge/build.gradle b/fineract-charge/build.gradle index 636fc048a..58b90df78 100644 --- a/fineract-charge/build.gradle +++ b/fineract-charge/build.gradle @@ -21,23 +21,35 @@ description = 'Fineract Charge' apply plugin: 'java' apply plugin: 'eclipse' -compileJava.doLast { - def mainSS = sourceSets.main - def source = mainSS.java.classesDirectory.get() - copy { - from file("src/main/resources/jpa/charge/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 } +} + +compileJava { + dependsOn ':fineract-avro-schemas:buildJavaSdk' } // Configuration for Swagger documentation generation task @@ -91,10 +103,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 { diff --git a/fineract-charge/src/main/resources/jpa/charge/persistence.xml b/fineract-charge/src/main/resources/META-INF/persistence.xml similarity index 100% rename from fineract-charge/src/main/resources/jpa/charge/persistence.xml rename to fineract-charge/src/main/resources/META-INF/persistence.xml diff --git a/fineract-charge/src/main/resources/jpa/charge/db/changelog/tenant/module/charge/module-changelog-master.xml b/fineract-charge/src/main/resources/db/changelog/tenant/module/charge/module-changelog-master.xml similarity index 100% rename from fineract-charge/src/main/resources/jpa/charge/db/changelog/tenant/module/charge/module-changelog-master.xml rename to fineract-charge/src/main/resources/db/changelog/tenant/module/charge/module-changelog-master.xml diff --git a/fineract-client/build.gradle b/fineract-client/build.gradle index a079f0a08..e80b16c03 100644 --- a/fineract-client/build.gradle +++ b/fineract-client/build.gradle @@ -1,3 +1,5 @@ +import org.openapitools.generator.gradle.plugin.tasks.GenerateTask + /** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -35,7 +37,7 @@ openApiValidate { recommend = true } -task buildJavaSdk(type: org.openapitools.generator.gradle.plugin.tasks.GenerateTask) { +tasks.register('buildJavaSdk', GenerateTask) { generatorName = 'java' verbose = false validateSpec = false @@ -48,11 +50,11 @@ task buildJavaSdk(type: org.openapitools.generator.gradle.plugin.tasks.GenerateT invokerPackage = 'org.apache.fineract.client' modelPackage = 'org.apache.fineract.client.models' configOptions = [ - dateLibrary: 'java8', - useRxJava2: 'false', - library: 'retrofit2', - hideGenerationTimestamp: 'true', - containerDefaultToNull: 'true' + dateLibrary : 'java8', + useRxJava2 : 'false', + library : 'retrofit2', + hideGenerationTimestamp: 'true', + containerDefaultToNull : 'true' ] generateModelTests = false generateApiTests = false @@ -60,7 +62,7 @@ task buildJavaSdk(type: org.openapitools.generator.gradle.plugin.tasks.GenerateT dependsOn(':fineract-provider:resolve') } -task buildTypescriptAngularSdk(type: org.openapitools.generator.gradle.plugin.tasks.GenerateTask){ +tasks.register('buildTypescriptAngularSdk', GenerateTask) { generatorName = 'typescript-angular' verbose = false validateSpec = false @@ -71,16 +73,16 @@ task buildTypescriptAngularSdk(type: org.openapitools.generator.gradle.plugin.ta invokerPackage = 'apache-fineract-client/invoker' modelPackage = 'apache-fineract-client/models' configOptions = [ - apiModulePrefix: 'apacheFineractClient', - configurationPrefix: 'apacheFineractClient', - ngVersion: '12.0.0', - npmName: '@apache/fineract-client', - npmRepository: "${npmRepository}" + apiModulePrefix : 'apacheFineractClient', + configurationPrefix: 'apacheFineractClient', + ngVersion : '12.0.0', + npmName : '@apache/fineract-client', + npmRepository : "${npmRepository}" ] dependsOn(':fineract-provider:resolve') } -task buildAsciidoc(type: org.openapitools.generator.gradle.plugin.tasks.GenerateTask){ +tasks.register('buildAsciidoc', GenerateTask) { generatorName = 'asciidoc' verbose = false validateSpec = false @@ -91,18 +93,18 @@ task buildAsciidoc(type: org.openapitools.generator.gradle.plugin.tasks.Generate invokerPackage = 'org.apache.fineract.client' modelPackage = 'org.apache.fineract.client.models' configOptions = [ - appName: 'Apache Fineract REST API', - appDescription: '''Apache Fineract is a secure, multi-tenanted microfinance platform. + appName : 'Apache Fineract REST API', + appDescription : '''Apache Fineract is a secure, multi-tenanted microfinance platform. The goal of the Apache Fineract API is to empower developers to build apps on top of the Apache Fineract Platform. The https://cui.fineract.dev[reference app] (username: mifos, password: password) works on the same demo tenant as the interactive links in this documentation. Until we complete the new REST API documentation you still have the legacy documentation available https://fineract.apache.org/legacy-docs/apiLive.htm[here]. Please check https://fineract.apache.org/docs/current[the Fineract documentation] for more information.''', - headerAttributes: 'false', - infoEmail: 'dev@fineract.apache.org', - infoUrl: 'https://fineract.apache.org', - licenseInfo: 'Apache 2.0', - licenseUrl: 'http://www.apache.org/licenses/LICENSE-2.0.html', - useMethodAndPath: 'true' + headerAttributes: 'false', + infoEmail : 'dev@fineract.apache.org', + infoUrl : 'https://fineract.apache.org', + licenseInfo : 'Apache 2.0', + licenseUrl : 'http://www.apache.org/licenses/LICENSE-2.0.html', + useMethodAndPath: 'true' ] dependsOn(':fineract-provider:resolve') } @@ -131,23 +133,23 @@ tasks.withType(Jar).configureEach { } // Improve the cleanup task to track inputs and outputs -task cleanupGeneratedJavaFiles() { +tasks.register('cleanupGeneratedJavaFiles') { def tempDir = file("$buildDir/generated/temp-java") def targetDir = file("$buildDir/generated/java") - + inputs.dir(tempDir) outputs.dir(targetDir) - + doLast { copy { from tempDir into targetDir filter { line -> line - .replaceAll("import org\\.joda\\.time\\.\\*;", "") - .replaceAll(", \\)", ")") - .replaceAll(", , @HeaderMap", ", @HeaderMap") - .replaceAll("\\(, ", "(") + .replaceAll("import org\\.joda\\.time\\.\\*;", "") + .replaceAll(", \\)", ")") + .replaceAll(", , @HeaderMap", ", @HeaderMap") + .replaceAll("\\(, ", "(") } // Also set duplicates strategy for the copy task duplicatesStrategy = DuplicatesStrategy.EXCLUDE diff --git a/fineract-command/build.gradle b/fineract-command/build.gradle index ac754bcab..023b5b635 100644 --- a/fineract-command/build.gradle +++ b/fineract-command/build.gradle @@ -79,4 +79,4 @@ jmh { fork = 1 // Number of forks timeOnIteration = '2s' // Time per iteration benchmarkMode = ['thrpt'] // Default benchmark mode -} \ No newline at end of file +} diff --git a/fineract-core/build.gradle b/fineract-core/build.gradle index c05ff7288..1d0a8dc66 100644 --- a/fineract-core/build.gradle +++ b/fineract-core/build.gradle @@ -21,23 +21,31 @@ description = 'Fineract Core' apply plugin: 'java' apply plugin: 'eclipse' -compileJava.doLast { - def mainSS = sourceSets.main - def source = mainSS.java.classesDirectory.get() - copy { - from file("src/main/resources/jpa/core/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, processResources + + def classesDir = file(sourceSets.main.output.classesDirs.asPath) + + mainClass.set('org.eclipse.persistence.tools.weaving.jpa.StaticWeave') + classpath = sourceSets.main.runtimeClasspath + args '-persistenceinfo', classesDir, classesDir, classesDir +} + +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 } } configurations { @@ -64,7 +72,7 @@ configurations { apply from: 'dependencies.gradle' compileJava { - dependsOn ':fineract-avro-schemas:jar' + dependsOn ':fineract-avro-schemas:compileJava', processResources options.compilerArgs += ['-parameters'] } diff --git a/fineract-core/src/main/resources/jpa/core/persistence.xml b/fineract-core/src/main/resources/META-INF/persistence.xml similarity index 100% rename from fineract-core/src/main/resources/jpa/core/persistence.xml rename to fineract-core/src/main/resources/META-INF/persistence.xml diff --git a/fineract-doc/build.gradle b/fineract-doc/build.gradle index 67ce8887d..eaa9a202d 100644 --- a/fineract-doc/build.gradle +++ b/fineract-doc/build.gradle @@ -60,12 +60,12 @@ asciidoctor { dependsOn(':fineract-client:clean', ':fineract-client:buildAsciidoc') } -task copyImages(type: Copy) { +tasks.register('copyImages', Copy) { from "${projectDir}/src/docs/en/images" into "${buildDir}/generated/images" } -task copyDiagrams(type: Copy) { +tasks.register('copyDiagrams', Copy) { from "${projectDir}/src/docs/en/diagrams" into "${buildDir}/generated/diagrams" } @@ -95,7 +95,7 @@ asciidoctorPdf { dependsOn(':fineract-client:clean', ':fineract-client:buildAsciidoc') } -task doc(type: Zip) { +tasks.register('doc', Zip) { dependsOn(asciidoctor, asciidoctorPdf) into("fineract-${project.version}/html") { diff --git a/fineract-document/build.gradle b/fineract-document/build.gradle index 6eeb13ada..8410fbff3 100644 --- a/fineract-document/build.gradle +++ b/fineract-document/build.gradle @@ -21,23 +21,35 @@ description = 'Fineract Document' apply plugin: 'java' apply plugin: 'eclipse' -compileJava.doLast { - def mainSS = sourceSets.main - def source = mainSS.java.classesDirectory.get() - copy { - from file("src/main/resources/jpa/document/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, '-classpath', sourceSets.main.runtimeClasspath, 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 } +} + +compileJava { + dependsOn ':fineract-avro-schemas:buildJavaSdk' } configurations { diff --git a/fineract-document/src/main/resources/jpa/document/persistence.xml b/fineract-document/src/main/resources/META-INF/persistence.xml similarity index 100% rename from fineract-document/src/main/resources/jpa/document/persistence.xml rename to fineract-document/src/main/resources/META-INF/persistence.xml diff --git a/fineract-investor/build.gradle b/fineract-investor/build.gradle index 22187772f..5fdbf51e3 100644 --- a/fineract-investor/build.gradle +++ b/fineract-investor/build.gradle @@ -21,23 +21,35 @@ description = 'Fineract Investor' apply plugin: 'java' apply plugin: 'eclipse' -compileJava.doLast { - def mainSS = sourceSets.main - def source = mainSS.java.classesDirectory.get() - copy { - from file("src/main/resources/jpa/investor/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 } +} + +compileJava { + dependsOn ':fineract-avro-schemas:buildJavaSdk' } configurations { @@ -85,10 +97,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 { diff --git a/fineract-investor/src/main/resources/jpa/investor/persistence.xml b/fineract-investor/src/main/resources/META-INF/persistence.xml similarity index 100% rename from fineract-investor/src/main/resources/jpa/investor/persistence.xml rename to fineract-investor/src/main/resources/META-INF/persistence.xml diff --git a/fineract-loan/build.gradle b/fineract-loan/build.gradle index 33b087faf..5d333cbad 100644 --- a/fineract-loan/build.gradle +++ b/fineract-loan/build.gradle @@ -21,23 +21,36 @@ description = 'Fineract Loan' apply plugin: 'java' apply plugin: 'eclipse' -compileJava.doLast { - def mainSS = sourceSets.main - def source = mainSS.java.classesDirectory.get() +tasks.register('staticWeaveJpa', JavaExec) { + group = "build" + description = "Performs EclipseLink static weaving of entity classes" + + dependsOn classes + + def classesDir = file("$buildDir/classes/java/main") + def metaInf = new File(classesDir, "META-INF") + metaInf.mkdirs() + copy { - from file("src/main/resources/jpa/loan/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" + from "src/main/resources/jpa/loan/persistence.xml" + into "$buildDir/classes/java/main/META-INF" } + + 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 +} + +compileJava { + dependsOn ':fineract-avro-schemas:buildJavaSdk' } // Configuration for Swagger documentation generation task @@ -91,10 +104,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 { @@ -104,3 +113,9 @@ if (!(project.hasProperty('env') && project.getProperty('env') == 'dev')) { } } } + +tasks.named('processResources') { + from('src/main/resources') + into sourceSets.main.java.classesDirectory + outputs.upToDateWhen { false } +} diff --git a/fineract-loan/src/main/resources/jpa/loan/persistence.xml b/fineract-loan/src/main/resources/META-INF/persistence.xml similarity index 100% rename from fineract-loan/src/main/resources/jpa/loan/persistence.xml rename to fineract-loan/src/main/resources/META-INF/persistence.xml diff --git a/fineract-progressive-loan/build.gradle b/fineract-progressive-loan/build.gradle index 20e9f20b4..9017f54b4 100644 --- a/fineract-progressive-loan/build.gradle +++ b/fineract-progressive-loan/build.gradle @@ -21,23 +21,35 @@ description = 'Fineract Progressive Loan' apply plugin: 'java' apply plugin: 'eclipse' -compileJava.doLast { - def mainSS = sourceSets.main - def source = mainSS.java.classesDirectory.get() - copy { - from file("src/main/resources/jpa/progressiveloan/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 } +} + +compileJava { + dependsOn ':fineract-avro-schemas:buildJavaSdk' } configurations { @@ -85,10 +97,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 { diff --git a/fineract-progressive-loan/src/main/resources/jpa/progressiveloan/persistence.xml b/fineract-progressive-loan/src/main/resources/META-INF/persistence.xml similarity index 100% rename from fineract-progressive-loan/src/main/resources/jpa/progressiveloan/persistence.xml rename to fineract-progressive-loan/src/main/resources/META-INF/persistence.xml diff --git a/fineract-provider/build.gradle b/fineract-provider/build.gradle index 9606ce545..8c7bfe536 100644 --- a/fineract-provider/build.gradle +++ b/fineract-provider/build.gradle @@ -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" } diff --git a/fineract-provider/src/main/resources/jpa/persistence.xml b/fineract-provider/src/main/resources/META-INF/persistence.xml similarity index 100% rename from fineract-provider/src/main/resources/jpa/persistence.xml rename to fineract-provider/src/main/resources/META-INF/persistence.xml diff --git a/fineract-provider/src/main/resources/application.properties b/fineract-provider/src/main/resources/application.properties index 3dd6a5a66..b88120939 100644 --- a/fineract-provider/src/main/resources/application.properties +++ b/fineract-provider/src/main/resources/application.properties @@ -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 diff --git a/fineract-rates/build.gradle b/fineract-rates/build.gradle index 279cd9d99..36e88f449 100644 --- a/fineract-rates/build.gradle +++ b/fineract-rates/build.gradle @@ -21,23 +21,35 @@ description = 'Fineract Rates' apply plugin: 'java' apply plugin: 'eclipse' -compileJava.doLast { - def mainSS = sourceSets.main - def source = mainSS.java.classesDirectory.get() - copy { - from file("src/main/resources/jpa/rates/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 } +} + +compileJava { + dependsOn ':fineract-avro-schemas:buildJavaSdk' } // Configuration for Swagger documentation generation task @@ -91,10 +103,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 { diff --git a/fineract-rates/src/main/resources/jpa/rates/persistence.xml b/fineract-rates/src/main/resources/META-INF/persistence.xml similarity index 100% rename from fineract-rates/src/main/resources/jpa/rates/persistence.xml rename to fineract-rates/src/main/resources/META-INF/persistence.xml diff --git a/fineract-rates/src/main/resources/jpa/rates/db/changelog/tenant/module/rates/module-changelog-master.xml b/fineract-rates/src/main/resources/db/changelog/tenant/module/rates/module-changelog-master.xml similarity index 100% rename from fineract-rates/src/main/resources/jpa/rates/db/changelog/tenant/module/rates/module-changelog-master.xml rename to fineract-rates/src/main/resources/db/changelog/tenant/module/rates/module-changelog-master.xml diff --git a/fineract-report/build.gradle b/fineract-report/build.gradle index f7239ebd4..16e958dfe 100644 --- a/fineract-report/build.gradle +++ b/fineract-report/build.gradle @@ -21,23 +21,35 @@ description = 'Fineract Report' apply plugin: 'java' apply plugin: 'eclipse' -compileJava.doLast { - def mainSS = sourceSets.main - def source = mainSS.java.classesDirectory.get() - copy { - from file("src/main/resources/jpa/report/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 } +} + +compileJava { + dependsOn ':fineract-avro-schemas:buildJavaSdk' } // Configuration for Swagger documentation generation task @@ -91,10 +103,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 { diff --git a/fineract-report/src/main/resources/jpa/report/persistence.xml b/fineract-report/src/main/resources/META-INF/persistence.xml similarity index 100% rename from fineract-report/src/main/resources/jpa/report/persistence.xml rename to fineract-report/src/main/resources/META-INF/persistence.xml diff --git a/fineract-savings/build.gradle b/fineract-savings/build.gradle index df6fa6f3a..7e6b6eb97 100644 --- a/fineract-savings/build.gradle +++ b/fineract-savings/build.gradle @@ -21,23 +21,35 @@ description = 'Fineract Savings' apply plugin: 'java' apply plugin: 'eclipse' -compileJava.doLast { - def mainSS = sourceSets.main - def source = mainSS.java.classesDirectory.get() - copy { - from file("src/main/resources/jpa/savings/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 } +} + +compileJava { + dependsOn ':fineract-avro-schemas:buildJavaSdk' } // Configuration for Swagger documentation generation task @@ -91,10 +103,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 { diff --git a/fineract-savings/src/main/resources/jpa/savings/persistence.xml b/fineract-savings/src/main/resources/META-INF/persistence.xml similarity index 100% rename from fineract-savings/src/main/resources/jpa/savings/persistence.xml rename to fineract-savings/src/main/resources/META-INF/persistence.xml diff --git a/fineract-tax/build.gradle b/fineract-tax/build.gradle index 1d0844df6..a03a02887 100644 --- a/fineract-tax/build.gradle +++ b/fineract-tax/build.gradle @@ -21,23 +21,35 @@ description = 'Fineract Taxes' apply plugin: 'java' apply plugin: 'eclipse' -compileJava.doLast { - def mainSS = sourceSets.main - def source = mainSS.java.classesDirectory.get() - copy { - from file("src/main/resources/jpa/taxes/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 } +} + +compileJava { + dependsOn ':fineract-avro-schemas:buildJavaSdk' } // Configuration for Swagger documentation generation task @@ -91,10 +103,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 { diff --git a/fineract-tax/src/main/resources/jpa/taxes/persistence.xml b/fineract-tax/src/main/resources/META-INF/persistence.xml similarity index 100% rename from fineract-tax/src/main/resources/jpa/taxes/persistence.xml rename to fineract-tax/src/main/resources/META-INF/persistence.xml diff --git a/fineract-war/build.gradle b/fineract-war/build.gradle index 93b12e422..0f41b44f8 100644 --- a/fineract-war/build.gradle +++ b/fineract-war/build.gradle @@ -91,13 +91,13 @@ dependencies { implementation project(':fineract-provider') } -tasks.withType(Tar) { +tasks.withType(Tar).configureEach { compression Compression.GZIP archiveExtension = 'tar.gz' - + // Enable caching for all tar tasks outputs.cacheIf { true } - + // Ensure reproducible output preserveFileTimestamps = false reproducibleFileOrder = true