Skip to content

Commit

Permalink
more general improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
kjozsa committed Nov 14, 2024
1 parent edb0f21 commit 30f369c
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 51 deletions.
57 changes: 51 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -323,21 +323,66 @@ configure(project.fineractJavaProjects) {
apply plugin: 'idea'
apply plugin: 'jacoco'
apply plugin: 'checkstyle'
apply plugin: 'net.ltgt.errorprone'
apply plugin: 'pmd'
apply plugin: 'spotbugs'
apply plugin: 'com.github.spotbugs'
apply plugin: 'com.github.andygoossens.modernizer'
apply from: "${rootDir}/buildSrc/src/main/groovy/org.apache.fineract.dependencies.gradle"
apply plugin: 'org.nosphere.apache.rat'
apply plugin: 'com.github.hierynomus.license'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'com.diffplug.spotless'
apply plugin: 'pmd-settings'
apply plugin: 'checkstyle-settings'
apply plugin: 'spotbugs-settings'
apply plugin: 'io.freefair.lombok'

sourceSets {
main {
output.resourcesDir = file("${buildDir}/resources/main")
}
test {
output.resourcesDir = file("${buildDir}/resources/test")
}
}

group = 'org.apache.fineract'
// Configuration for JPA enhancement
task enhanceJPA(type: JavaExec) {
description = 'Performs static weaving of entity classes'
group = 'build'

inputs.files(sourceSets.main.output.classesDirs)
outputs.dir(sourceSets.main.output.classesDirs)

doFirst {
def source = sourceSets.main.java.classesDirectory.get()
copy {
from file("src/main/resources/jpa/persistence.xml")
into "${source}/META-INF/"
}
}

main = 'org.eclipse.persistence.tools.weaving.jpa.StaticWeave'
def source = sourceSets.main.java.classesDirectory.get()
args = ['-persistenceinfo', source, source, source]
classpath = sourceSets.main.runtimeClasspath

doLast {
delete {
delete "${source}/META-INF/persistence.xml"
}
}
}

compileJava.finalizedBy enhanceJPA

/* define the valid syntax level for source files */
sourceCompatibility = JavaVersion.VERSION_17
/* define binary compatibility version */
targetCompatibility = JavaVersion.VERSION_17

/* 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
// sourceSets.main.output.resourcesDir = sourceSets.main.java.classesDirectory
// sourceSets.test.output.resourcesDir = sourceSets.test.java.classesDirectory

configurations.named('spotbugs').configure {
resolutionStrategy.eachDependency {
Expand Down
52 changes: 7 additions & 45 deletions fineract-accounting/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,28 +19,9 @@
description = 'Fineract Accounting'

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.freefair.lombok'

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
main 'org.eclipse.persistence.tools.weaving.jpa.StaticWeave'
args '-persistenceinfo', source, source, target
classpath sourceSets.main.runtimeClasspath
}
delete {
delete "${source}/META-INF/persistence.xml"
}
}

configurations {
providedRuntime // needed for Spring Boot executable WAR
providedCompile
Expand All @@ -65,7 +46,6 @@ configurations {
apply from: 'dependencies.gradle'

// Configuration for the modernizer plugin
// https://github.com/andygoossens/gradle-modernizer-plugin
modernizer {
ignoreClassNamePatterns = [
'.*AbstractPersistableCustom',
Expand All @@ -74,28 +54,10 @@ modernizer {
]
}

// 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-accounting/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/**'
}
}
}
tasks.withType(JavaCompile) {
options.compilerArgs += [
'-Amapstruct.suppressGeneratorTimestamp=true',
'-Amapstruct.suppressGeneratorVersionInfoComment=true',
'-Amapstruct.verbose=true'
]
}

0 comments on commit 30f369c

Please sign in to comment.