FINERACT-1198: Fixing incremental build for Gradle

This commit is contained in:
Petri Tuomola
2022-01-02 13:00:27 +01:00
committed by Aleksandar Vidakovic
parent 6e052e536b
commit 46ff275d07
5 changed files with 83 additions and 34 deletions
+71 -19
View File
@@ -22,25 +22,76 @@ apply plugin: 'org.zeroturnaround.gradle.jrebel'
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
apply plugin: 'openjpa'
apply plugin: 'com.gorylenko.gradle-git-properties'
apply plugin: 'io.swagger.core.v3.swagger-gradle-plugin'
apply plugin: 'distribution'
apply plugin: 'signing'
apply plugin: 'com.google.cloud.tools.jib'
// Configuration for the OpenJPA enhance task
// https://github.com/radcortez/openjpa-gradle-plugin
System.setProperty("openjpa.Log", "commons")
openjpa {
includes = [
// Custom OpenJPA enhancement
compileJava.doLast {
def enhanceIncludes = [
'**/AbstractPersistableCustom.class',
'**/domain/*.class'
]
enhance {
enforcePropertyRestrictions true
def classesToEnhance = project.sourceSets.main.output.classesDirs.collectMany { classesDir ->
project.fileTree(classesDir).matching {
enhanceIncludes.forEach { include it }
}.files
}
String persistenceXml = "META-INF/persistence.xml"
def persistenceXmlFile
// Check if persistence.xml is in the resource dirs.
project.sourceSets.main.resources.srcDirs.collect { resourceDir ->
def persistenceXmlFileCandidate = project.fileTree(resourceDir).matching {
include persistenceXml
}
if (!persistenceXmlFileCandidate.isEmpty()) {
if (persistenceXmlFile == null) {
persistenceXmlFile = persistenceXmlFileCandidate.singleFile
} else {
throw new InvalidUserDataException("Multiple persistence.xml files found in path: " +
persistenceXmlFile + ", " + persistenceXmlFileCandidate)
}
}
// Nothing found. Fallback to plain file.
if (persistenceXmlFile == null) {
persistenceXmlFile = project.file(persistenceXml)
if (!persistenceXmlFile.exists()) {
throw new InvalidUserDataException(
"Could not find valid persistence.xml in path " + this.persistenceXml)
}
}
}
org.apache.openjpa.lib.util.Options options = new org.apache.openjpa.lib.util.Options([
"addDefaultConstructor" : true,
"enforcePropertyRestrictions": true,
"tmpClassLoader" : false,
"propertiesFile" : persistenceXmlFile
])
def classes = project.sourceSets.main.output.classesDirs.collect { it.toURI().toURL() }
def compileJars = project.configurations.compileClasspath.files.collect { jar ->
jar.toURI().toURL()
}
def resources = project.sourceSets.main.resources.srcDirs.collect { resource ->
resource.toURI().toURL()
}
def urls = (classes + compileJars + resources)
ClassLoader currentClassLoader = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(new URLClassLoader((URL[])urls, currentClassLoader));
org.apache.openjpa.enhance.PCEnhancer.run((String []) classesToEnhance, options);
Thread.currentThread().setContextClassLoader(currentClassLoader);
}
// Configuration for Swagger documentation generation task
@@ -48,6 +99,8 @@ openjpa {
import org.apache.tools.ant.filters.ReplaceTokens
task prepareInputYaml(dependsOn: 'generateGitProperties') {
outputs.file('config/swagger/fineract-input.yaml')
doLast {
def versionForSwagger
@@ -65,6 +118,7 @@ task prepareInputYaml(dependsOn: 'generateGitProperties') {
}
}
rat.dependsOn prepareInputYaml
resolve {
logging.captureStandardOutput LogLevel.INFO
@@ -72,7 +126,7 @@ resolve {
outputFormat = 'YAML'
prettyPrint = 'TRUE'
classpath = sourceSets.main.runtimeClasspath
outputDir = file("${buildDir}/classes/java/main/static/swagger-ui")
outputDir = file("${buildDir}/generated/swagger-ui")
openApiFile = file("config/swagger/fineract-input.yaml")
}
@@ -100,14 +154,6 @@ configurations {
}
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') {
@@ -245,6 +291,10 @@ bootJar {
}
dependsOn resolve
classifier = ''
from('build/generated/swagger-ui') {
into 'BOOT-INF/classes/static/swagger-ui'
}
}
jib {
@@ -340,6 +390,7 @@ distributions {
tasks.binaryDistZip.enabled false
tasks.srcDistZip.enabled false
tasks.binaryDistTar.dependsOn bootJar
tasks.srcDistTar.dependsOn prepareInputYaml
// create signatures and checksums only if project parameter "fineract.release" is provided on the command line
if( project.hasProperty("fineract.release") ) {
@@ -384,11 +435,12 @@ gitProperties {
extProperty = 'gitProps'
}
processResources.dependsOn generateGitProperties
// make sure the generateGitProperties task always executes (even when git.properties is not changed)
generateGitProperties.outputs.upToDateWhen { false }
// Gradle 7.x asks for explicit dependencies between tasks
processResources.dependsOn generateGitProperties
checkstyleMain.dependsOn resolve
checkstyleTest.dependsOn resolve
licenseMain.dependsOn processResources, generateGitProperties
@@ -19,7 +19,6 @@
package org.apache.fineract.infrastructure.bulkimport.importhandler;
import com.google.common.base.Splitter;
import com.google.common.collect.Iterables;
import java.time.LocalDate;
import java.util.List;
import org.apache.fineract.infrastructure.bulkimport.constants.TemplatePopulateImportConstants;
@@ -134,7 +133,7 @@ public final class ImportHandlerUtils {
public static String trimEmptyDecimalPortion(String result) {
if (result != null && result.endsWith(".0")) {
return Iterables.get(Splitter.on("\\.").split(result), 0);
return Splitter.on("\\.").split(result).iterator().next();
} else {
return result;
}
@@ -18,7 +18,6 @@
*/
package org.apache.fineract.portfolio.transfer.service;
import com.google.common.collect.Iterables;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import java.time.LocalDate;
@@ -381,7 +380,6 @@ public class TransferWritePlatformServiceJpaRepositoryImpl implements TransferWr
private void handleClientTransferLifecycleEvent(final Client client, final Office destinationOffice,
final TransferEventType transferEventType, final JsonCommand jsonCommand) {
final Date todaysDate = DateUtils.getDateOfTenant();
/** Get destination loan officer if exists **/
Staff staff = null;
Group destinationGroup = null;
@@ -459,7 +457,7 @@ public class TransferWritePlatformServiceJpaRepositoryImpl implements TransferWr
} else if (!destinationGroup.isActive()) {
throw new GroupNotActiveException(destinationGroup.getId());
}
transferClientBetweenGroups(Iterables.get(client.getGroups(), 0), client, destinationGroup, true, staff);
transferClientBetweenGroups(client.getGroups().stream().findFirst().get(), client, destinationGroup, true, staff);
} else if (client.getGroups().size() == 0 && destinationGroup != null) {
client.getGroups().add(destinationGroup);
client.updateStaff(destinationGroup.getStaff());