Skip to content

Commit

Permalink
remove jrebel, eclipse, fix provider caching
Browse files Browse the repository at this point in the history
  • Loading branch information
kjozsa committed Nov 14, 2024
1 parent 6286d1f commit e4dfbba
Show file tree
Hide file tree
Showing 5 changed files with 92 additions and 147 deletions.
45 changes: 8 additions & 37 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ plugins {
id 'org.nosphere.apache.rat' version '0.8.1' apply false
id 'com.github.hierynomus.license' version '0.16.1' apply false
id 'com.github.jk1.dependency-license-report' version '2.9' apply false
id 'org.zeroturnaround.gradle.jrebel' version '1.2.0' apply false
id 'org.springframework.boot' version '3.3.5' apply false
id 'net.ltgt.errorprone' version '3.1.0' apply false
id 'io.swagger.core.v3.swagger-gradle-plugin' version '2.2.23' apply false
Expand Down Expand Up @@ -321,9 +320,8 @@ configure(project.fineractJavaProjects) {

apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'eclipse'
apply plugin: 'checkstyle'
apply plugin: 'jacoco'
apply plugin: 'checkstyle'
apply plugin: 'net.ltgt.errorprone'
apply plugin: 'com.github.spotbugs'
apply plugin: 'com.github.andygoossens.modernizer'
Expand Down Expand Up @@ -403,43 +401,16 @@ configure(project.fineractJavaProjects) {
// https://github.com/diffplug/spotless/tree/main/plugin-gradle
spotless {
java {
targetExclude '**/build/**', '**/bin/**', '**/out/**'
importOrder() //sort imports alphabetically
targetExclude "**/build/**"
importOrder()
removeUnusedImports()
eclipse().configFile "$rootDir/config/fineractdev-formatter.xml"
endWithNewline()
indentWithSpaces(4)
trimTrailingWhitespace()

// Enforce style modifier order
custom 'Modifier ordering', {
def modifierRanking = [
public : 1,
protected : 2,
private : 3,
abstract : 4,
default : 5,
static : 6,
final : 7,
transient : 8,
volatile : 9,
synchronized: 10,
native : 11,
strictfp : 12]
// Find any instance of multiple modifiers. Lead with a non-word character to avoid
// accidental matching against for instance, "an alternative default value"
it.replaceAll(/\W(?:public |protected |private |abstract |default |static |final |transient |volatile |synchronized |native |strictfp ){2,}/, {
// Do not replace the leading non-word character. Identify the modifiers
it.replaceAll(/(?:public |protected |private |abstract |default |static |final |transient |volatile |synchronized |native |strictfp ){2,}/, {
// Sort the modifiers according to the ranking above
it.split().sort({ modifierRanking[it] }).join(' ') + ' '
}
)
}
)
}
endWithNewline()
formatAnnotations()
licenseHeader '/**\n * Licensed to the Apache Software Foundation (ASF) under one\n * or more contributor license agreements. See the NOTICE file\n * distributed with this work for additional information\n * regarding copyright ownership. The ASF licenses this file\n * to you under the Apache License, Version 2.0 (the\n * "License"); you may not use this file except in compliance\n * with the License. You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing,\n * software distributed under the License is distributed on an\n * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n * KIND, either express or implied. See the License for the\n * specific language governing permissions and limitations\n * under the License.\n */'
configFile "$rootDir/config/fineractdev-formatter.xml"
}

lineEndings 'UNIX'
}

// If we are running Gradle within Eclipse to enhance classes,
Expand Down
105 changes: 55 additions & 50 deletions fineract-provider/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@
*/
description = 'Fineract Provider'

apply plugin: 'org.zeroturnaround.gradle.jrebel'
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
apply plugin: 'com.gorylenko.gradle-git-properties'
apply plugin: 'io.swagger.core.v3.swagger-gradle-plugin'
Expand All @@ -30,36 +28,50 @@ 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
// Properly declare task 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/"
}
}
delete {
delete "${source}/META-INF/persistence.xml"

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"
}
}
}

// 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
compileJava.finalizedBy enhanceJPA

// Configuration for Swagger documentation generation task
task prepareInputYaml {
outputs.file("${buildDir}/tmp/swagger/fineract-input.yaml")

def inputFile = file("${projectDir}/config/swagger/fineract-input.yaml.template")
def outputFile = file("${buildDir}/tmp/swagger/fineract-input.yaml")

inputs.file(inputFile)
inputs.property("version", project.version)
outputs.file(outputFile)

doLast {
outputFile.parentFile.mkdirs()
copy {
from file("${projectDir}/config/swagger/fineract-input.yaml.template")
into file("${buildDir}/tmp/swagger")
from inputFile
into outputFile.parentFile
rename { String filename -> return 'fineract-input.yaml' }
filter(ReplaceTokens, tokens: [VERSION: "${project.version}".toString()])
}
Expand All @@ -77,6 +89,25 @@ resolve {
openApiFile = file("${buildDir}/tmp/swagger/fineract-input.yaml")
sortOutput = true
dependsOn(prepareInputYaml)

inputs.files(sourceSets.main.runtimeClasspath)
inputs.file(openApiFile)
outputs.dir(outputDir)
}

// Use separate directories for resources to improve caching
sourceSets {
main {
output.resourcesDir = file("${buildDir}/resources/main")
}
test {
output.resourcesDir = file("${buildDir}/resources/test")
java {
if (!(project.hasProperty('env') && project.getProperty('env') == 'dev')) {
exclude '**/core/boot/tests/**'
}
}
}
}

configurations {
Expand Down Expand Up @@ -112,32 +143,6 @@ 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-provider/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/**'
}
}
}
}

// Configuration for SQL tasks
// https://docs.groovy-lang.org/latest/html/api/groovy/sql/Sql.html
import groovy.sql.Sql
Expand Down
27 changes: 9 additions & 18 deletions fineract-report/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
description = 'Fineract Report'

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'

compileJava.doLast {
def mainSS = sourceSets.main
Expand All @@ -44,7 +44,14 @@ compileJava.doLast {
// https://github.com/swagger-api/swagger-core/tree/master/modules/swagger-gradle-plugin
import org.apache.tools.ant.filters.ReplaceTokens


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

configurations {
providedRuntime // needed for Spring Boot executable WAR
Expand Down Expand Up @@ -79,22 +86,6 @@ 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-report/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 {
Expand Down
27 changes: 9 additions & 18 deletions fineract-savings/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
description = 'Fineract Savings'

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'

compileJava.doLast {
def mainSS = sourceSets.main
Expand All @@ -44,7 +44,14 @@ compileJava.doLast {
// https://github.com/swagger-api/swagger-core/tree/master/modules/swagger-gradle-plugin
import org.apache.tools.ant.filters.ReplaceTokens


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

configurations {
providedRuntime // needed for Spring Boot executable WAR
Expand Down Expand Up @@ -79,22 +86,6 @@ 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-savings/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 {
Expand Down
35 changes: 11 additions & 24 deletions fineract-tax/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
* specific language governing permissions and limitations
* under the License.
*/
description = 'Fineract Taxes'
description = 'Fineract Tax'

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'

compileJava.doLast {
def mainSS = sourceSets.main
Expand All @@ -29,7 +29,7 @@ compileJava.doLast {
into "${source}/META-INF/"
}
javaexec {
description = 'Performs EclipseLink static weaving of entity classes'
description = 'Performs static weaving of entity classes'
def target = source
main 'org.eclipse.persistence.tools.weaving.jpa.StaticWeave'
args '-persistenceinfo', source, source, target
Expand All @@ -40,11 +40,14 @@ compileJava.doLast {
}
}

// 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


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

configurations {
providedRuntime // needed for Spring Boot executable WAR
Expand Down Expand Up @@ -79,22 +82,6 @@ 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-tax/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 {
Expand Down

0 comments on commit e4dfbba

Please sign in to comment.