Skip to content

Commit

Permalink
FINERACT-2122: Add devRun gradle task, optimize build caching, fix de…
Browse files Browse the repository at this point in the history
…precations
  • Loading branch information
kjozsa authored and adamsaghy committed Jan 22, 2025
1 parent ddc8b1a commit 384a52b
Show file tree
Hide file tree
Showing 33 changed files with 552 additions and 171 deletions.
6 changes: 2 additions & 4 deletions .github/workflows/build-docker-mariadb.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,9 @@ jobs:
run: ./gradlew --no-daemon --console=plain :fineract-provider:clean :fineract-provider:build :fineract-provider:jibDockerBuild -x test -x cucumber
- name: Start the stack
run: docker compose up -d
- name: Wait for stack to come up
run: sleep 500
- name: Check the stack
run: docker ps
- name: Check health
run: curl -f -k --retry 10 --retry-connrefused --connect-timeout 30 --retry-delay 30 https://localhost:8443/fineract-provider/actuator/health
run: curl -f -k --retry 60 --retry-all-errors --connect-timeout 30 --retry-delay 30 https://localhost:8443/fineract-provider/actuator/health
- name: Check info
run: (( $(curl -f -k --retry 5 --retry-connrefused --connect-timeout 30 --retry-delay 30 https://localhost:8443/fineract-provider/actuator/info | wc --chars) > 100 ))
run: (( $(curl -f -k --retry 5 --retry-all-errors --connect-timeout 30 --retry-delay 30 https://localhost:8443/fineract-provider/actuator/info | wc --chars) > 100 ))
6 changes: 2 additions & 4 deletions .github/workflows/build-docker-postgresql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,9 @@ jobs:
run: ./gradlew --no-daemon --console=plain :fineract-provider:clean :fineract-provider:build :fineract-provider:jibDockerBuild -x test -x cucumber
- name: Start the Standalone Stack
run: docker compose -f docker-compose-postgresql.yml up -d
- name: Wait for stack to come up
run: sleep 500
- name: Check the stack
run: docker ps
- name: Check health
run: curl -f -k --retry 10 --retry-connrefused --connect-timeout 30 --retry-delay 30 https://localhost:8443/fineract-provider/actuator/health
run: curl -f -k --retry 60 --retry-all-errors --connect-timeout 30 --retry-delay 30 https://localhost:8443/fineract-provider/actuator/health
- name: Check info
run: (( $(curl -f -k --retry 5 --retry-connrefused --connect-timeout 30 --retry-delay 30 https://localhost:8443/fineract-provider/actuator/info | wc --chars) > 100 ))
run: (( $(curl -f -k --retry 5 --retry-all-errors --connect-timeout 30 --retry-delay 30 https://localhost:8443/fineract-provider/actuator/info | wc --chars) > 100 ))
8 changes: 3 additions & 5 deletions .github/workflows/build-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,13 @@ jobs:
- name: Setup Gradle
uses: gradle/actions/setup-gradle@0bdd871935719febd78681f197cd39af5b6e16a6 # v4.2.2
- name: Build the image
run: ./gradlew --no-daemon --console=plain :fineract-provider:clean :fineract-provider:build :fineract-provider:jibDockerBuild -x test -x cucumber
run: ./gradlew --no-daemon --console=plain :fineract-provider:clean :fineract-provider:build :fineract-provider:jibDockerBuild -x test -x cucumber -x :integration-tests:test
- name: Start the Fineract stack
run: docker compose -f docker-compose-postgresql-test-activemq.yml up -d
- name: Wait for stack to come up
run: sleep 400
- name: Check the stack
run: docker ps
- name: Check health Manager
run: curl -f -k --retry 10 --retry-connrefused --connect-timeout 30 --retry-delay 30 https://localhost:8443/fineract-provider/actuator/health
run: curl -f -k --retry 60 --retry-all-errors --connect-timeout 30 --retry-delay 30 https://localhost:8443/fineract-provider/actuator/health
- name: Execute tests
env:
BASE_URL: https://localhost:8443
Expand All @@ -43,4 +41,4 @@ jobs:
EVENT_VERIFICATION_ENABLED: true
ACTIVEMQ_BROKER_URL: tcp://localhost:61616
ACTIVEMQ_TOPIC_NAME: events
run: ./gradlew --no-daemon --console=plain fineract-e2e-tests-runner:cucumber --tags 'not @Skip' allureReport
run: ./gradlew --no-daemon --console=plain -x test -x :integration-tests:test fineract-e2e-tests-runner:cucumber --tags 'not @Skip' allureReport
10 changes: 4 additions & 6 deletions .github/workflows/smoke-activemq.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,15 @@ jobs:
run: ./gradlew --no-daemon --console=plain :fineract-provider:clean :fineract-provider:build :fineract-provider:jibDockerBuild -x test -x cucumber
- name: Start the ActiveMQ Stack
run: docker compose -f docker-compose-postgresql-activemq.yml up --scale fineract-worker=1 -d
- name: Wait for stack to come up
run: sleep 500
- name: Check the stack
run: docker ps
- name: Check health Manager
run: curl -f -k --retry 10 --retry-connrefused --connect-timeout 30 --retry-delay 30 https://localhost:8443/fineract-provider/actuator/health
run: curl -f -k --retry 60 --retry-all-errors --connect-timeout 30 --retry-delay 30 https://localhost:8443/fineract-provider/actuator/health
- name: Check health Worker1
run: curl -f -k --retry 10 --retry-connrefused --connect-timeout 30 --retry-delay 30 https://localhost:8444/fineract-provider/actuator/health
run: curl -f -k --retry 60 --retry-all-errors --connect-timeout 30 --retry-delay 30 https://localhost:8444/fineract-provider/actuator/health
- name: Check info Manager
run: (( $(curl -f -k --retry 5 --retry-connrefused --connect-timeout 30 --retry-delay 30 https://localhost:8443/fineract-provider/actuator/info | wc --chars) > 100 ))
run: (( $(curl -f -k --retry 5 --retry-all-errors --connect-timeout 30 --retry-delay 30 https://localhost:8443/fineract-provider/actuator/info | wc --chars) > 100 ))
- name: Check info Worker1
run: (( $(curl -f -k --retry 5 --retry-connrefused --connect-timeout 30 --retry-delay 30 https://localhost:8444/fineract-provider/actuator/info | wc --chars) > 100 ))
run: (( $(curl -f -k --retry 5 --retry-all-errors --connect-timeout 30 --retry-delay 30 https://localhost:8444/fineract-provider/actuator/info | wc --chars) > 100 ))
- name: Run Smoke Test with Remote COB
run: ./gradlew --no-daemon --console=plain :integration-tests:cleanTest :integration-tests:test --tests "org.apache.fineract.integrationtests.investor.externalassetowner.InitiateExternalAssetOwnerTransferTest.saleActiveLoanToExternalAssetOwnerAndBuybackADayLater" -PcargoDisabled
10 changes: 4 additions & 6 deletions .github/workflows/smoke-kafka.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,15 @@ jobs:
run: ./gradlew --no-daemon --console=plain :fineract-provider:clean :fineract-provider:build :fineract-provider:jibDockerBuild -x test -x cucumber
- name: Start the Kafka Stack
run: docker compose -f docker-compose-postgresql-kafka.yml up --scale fineract-worker=1 -d
- name: Wait for stack to come up
run: sleep 500
- name: Check the stack
run: docker ps
- name: Check health Manager
run: curl -f -k --retry 10 --retry-connrefused --connect-timeout 30 --retry-delay 30 https://localhost:8443/fineract-provider/actuator/health
run: curl -f -k --retry 60 --retry-all-errors --connect-timeout 30 --retry-delay 30 https://localhost:8443/fineract-provider/actuator/health
- name: Check health Worker1
run: curl -f -k --retry 10 --retry-connrefused --connect-timeout 30 --retry-delay 30 https://localhost:8444/fineract-provider/actuator/health
run: curl -f -k --retry 60 --retry-all-errors --connect-timeout 30 --retry-delay 30 https://localhost:8444/fineract-provider/actuator/health
- name: Check info Manager
run: (( $(curl -f -k --retry 5 --retry-connrefused --connect-timeout 30 --retry-delay 30 https://localhost:8443/fineract-provider/actuator/info | wc --chars) > 100 ))
run: (( $(curl -f -k --retry 5 --retry-all-errors --connect-timeout 30 --retry-delay 30 https://localhost:8443/fineract-provider/actuator/info | wc --chars) > 100 ))
- name: Check info Worker1
run: (( $(curl -f -k --retry 5 --retry-connrefused --connect-timeout 30 --retry-delay 30 https://localhost:8444/fineract-provider/actuator/info | wc --chars) > 100 ))
run: (( $(curl -f -k --retry 5 --retry-all-errors --connect-timeout 30 --retry-delay 30 https://localhost:8444/fineract-provider/actuator/info | wc --chars) > 100 ))
- name: Run Smoke Test with Remote COB
run: ./gradlew --no-daemon --console=plain :integration-tests:cleanTest :integration-tests:test --tests "org.apache.fineract.integrationtests.investor.externalassetowner.InitiateExternalAssetOwnerTransferTest.saleActiveLoanToExternalAssetOwnerAndBuybackADayLater" -PcargoDisabled
106 changes: 94 additions & 12 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,39 @@ allprojects {
mavenCentral()
}

configurations {
api {
canBeResolved = true
}
}

apply plugin: 'com.adarshr.test-logger'
apply plugin: 'com.diffplug.spotless'
apply plugin: 'com.github.hierynomus.license'
apply plugin: 'net.ltgt.errorprone'

tasks.withType(JavaCompile).configureEach {
options.errorprone {
disableWarningsInGeneratedCode = true
disable(
"CanIgnoreReturnValueSuggester",
"SameNameButDifferent", // Until errorprone recognizes Lombok
"MultiVariableDeclaration", // Until errorprone recognizes Lombok
"UnnecessaryDefaultInEnumSwitch", // FINERACT-1911
"AssertEqualsArgumentOrderChecker",
"RemoveUnusedImports" // For generated code
)
error(
"DefaultCharset",
"StringSplitter",
"MutablePublicArray",
"EqualsGetClass",
"FutureReturnValueIgnored"
)
}
}

apply plugin: 'org.nosphere.apache.rat'
apply plugin: 'project-report'
apply plugin: 'com.github.jk1.dependency-license-report'

// Configuration for the sonarqube plugin is now in GitHub Actions
Expand Down Expand Up @@ -324,20 +352,59 @@ configure(project.fineractJavaProjects) {

apply plugin: 'java'
apply plugin: 'idea'

java {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
withSourcesJar()
withJavadocJar()
}

tasks.withType(ProcessResources) {
destinationDir = layout.buildDirectory.dir('classes/java/main').get().asFile
}

// Add performance optimizations
configurations.all {
resolutionStrategy {
cacheChangingModulesFor 0, 'seconds'
cacheDynamicVersionsFor 0, 'seconds'
}
}

tasks.withType(JavaCompile).configureEach {
options.incremental = true
options.fork = true
outputs.cacheIf { true }
options.compilerArgs << '-parameters'
options.encoding = 'UTF-8'
options.compilerArgs << '-Xlint:unchecked'
options.compilerArgs << '-Xlint:deprecation'
if (project.hasProperty('warnings') && project.warnings.contains('fail')) {
options.compilerArgs << '-Werror'
}
if (project.hasProperty('warnings') && project.warnings.contains('none')) {
options.compilerArgs << '-nowarn'
}
if (project.plugins.hasPlugin('org.springframework.boot')) {
options.generatedSourceOutputDirectory = file("$buildDir/generated/sources/annotationProcessor/java/main")
}
options.generatedSourceOutputDirectory = file("$buildDir/generated/sources/annotationProcessor/java/main")
}

apply plugin: 'eclipse'
apply plugin: 'checkstyle'
apply plugin: 'jacoco'
apply plugin: 'net.ltgt.errorprone'
apply plugin: 'com.github.spotbugs'
apply plugin: 'com.github.andygoossens.modernizer'
apply from: "${rootDir}/buildSrc/src/main/groovy/org.apache.fineract.dependencies.gradle"

group = 'org.apache.fineract'

/* define the valid syntax level for source files */
sourceCompatibility = JavaVersion.VERSION_17
/* define binary compatibility version */
targetCompatibility = JavaVersion.VERSION_17
// 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
Expand All @@ -353,18 +420,15 @@ configure(project.fineractJavaProjects) {
}

configurations {
implementation.setCanBeResolved(true)
api.setCanBeResolved(true)
}
tasks.withType(Copy) {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}
tasks.withType(JavaCompile) {
options.compilerArgs += [
"-Xlint:unchecked",
"-Xlint:cast",
"-Xlint:auxiliaryclass",
"-Xlint:deprecation",
"-Xlint:dep-ann",
"-Xlint:divzero",
"-Xlint:empty",
Expand Down Expand Up @@ -398,6 +462,10 @@ configure(project.fineractJavaProjects) {
options.deprecation = true
}

check {
dependsOn(rat, licenseMain, licenseTest)
}

dependencies {
spotbugsPlugins 'jp.skypencil.findbugs.slf4j:bug-pattern:1.5.0@jar'
}
Expand Down Expand Up @@ -469,7 +537,7 @@ configure(project.fineractJavaProjects) {
reports {
html.required = true
xml.required = true
html.destination file("${buildDir}/code-coverage")
html.outputLocation = layout.buildDirectory.dir('code-coverage')
}
}

Expand All @@ -479,11 +547,12 @@ configure(project.fineractJavaProjects) {
errorprone "com.google.errorprone:error_prone_core:2.35.1"
}

tasks.withType(JavaCompile) {
tasks.withType(JavaCompile).configureEach {
options.errorprone {
enabled = project.gradle.startParameter.taskNames.contains('build') || project.gradle.startParameter.taskNames.contains('check')
disableWarningsInGeneratedCode = true
excludedPaths = ".*/build/.*"
if (project.path == ':fineract-client') {
excludedPaths = '.*/build/generated/java/src/main/java/.*'
}
disable(
// TODO Remove disabled checks from this list, by fixing remaining usages
"UnusedVariable",
Expand Down Expand Up @@ -669,6 +738,19 @@ configure(project.fineractJavaProjects) {
'java/util/Optional.get:()Ljava/lang/Object;' // Disable forcing the usage of Optional.orElseThrow(java.util.function.Supplier<? extends X>)
]
}

tasks.withType(Javadoc) {
options.addStringOption('Xdoclint:none', '-quiet')
options.encoding = 'UTF-8'
// Disable strict checking to prevent build failures on invalid javadoc
options.addBooleanOption('html5', true)
// Add this if you're using Java 17 records or other modern features
if (JavaVersion.current().isCompatibleWith(JavaVersion.VERSION_17)) {
options.addBooleanOption('html5', true)
}
// Ignore any errors during javadoc generation
failOnError = false
}
}

configure(project.fineractCustomProjects) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ dependencyManagement {
dependency 'org.mock-server:mockserver-junit-jupiter:5.15.0'
dependency 'org.webjars:webjars-locator-core:0.59'
dependency 'com.icegreen:greenmail-junit5:2.0.1'
dependency 'com.intuit.karate:karate-junit5:1.4.1'

// fineract client dependencies
dependency "com.squareup.retrofit2:retrofit:2.11.0"
Expand Down
8 changes: 5 additions & 3 deletions custom/acme/event/externalevent/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@
* specific language governing permissions and limitations
* under the License.
*/
description = 'ACME Corp.: Fineract external events'
description = 'ACME Fineract Event External Event'

group = 'com.acme.fineract.event'
group = 'com.acme.fineract'

archivesBaseName = 'acme-fineract-event-externalevent'
base {
archivesName = 'acme-fineract-event-externalevent'
}

apply from: 'dependencies.gradle'
8 changes: 5 additions & 3 deletions custom/acme/event/starter/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@
* specific language governing permissions and limitations
* under the License.
*/
description = 'ACME Corp.: Fineract Event Starter'
description = 'ACME Fineract Event Starter'

group = 'com.acme.fineract.event'
group = 'com.acme.fineract'

archivesBaseName = 'acme-fineract-event-starter'
base {
archivesName = 'acme-fineract-event-starter'
}

apply from: 'dependencies.gradle'
6 changes: 4 additions & 2 deletions custom/acme/loan/cob/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@
* specific language governing permissions and limitations
* under the License.
*/
description = 'ACME Corp.: Fineract COB Loan'
description = 'ACME Fineract Loan COB'

group = 'com.acme.fineract'

archivesBaseName = 'acme-fineract-loan-cob'
base {
archivesName = 'acme-fineract-loan-cob'
}

apply from: 'dependencies.gradle'
6 changes: 4 additions & 2 deletions custom/acme/loan/job/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@
* specific language governing permissions and limitations
* under the License.
*/
description = 'ACME Corp.: Fineract Loan Job'
description = 'ACME Fineract Loan Job'

group = 'com.acme.fineract'

archivesBaseName = 'acme-fineract-loan-job'
base {
archivesName = 'acme-fineract-loan-job'
}

apply from: 'dependencies.gradle'
6 changes: 4 additions & 2 deletions custom/acme/loan/processor/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@
* specific language governing permissions and limitations
* under the License.
*/
description = 'ACME Corp.: Fineract Loan Transaction Processors'
description = 'ACME Fineract Loan Processor'

group = 'com.acme.fineract'

archivesBaseName = 'acme-fineract-loan-processor'
base {
archivesName = 'acme-fineract-loan-processor'
}

apply from: 'dependencies.gradle'
6 changes: 4 additions & 2 deletions custom/acme/loan/starter/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@
* specific language governing permissions and limitations
* under the License.
*/
description = 'ACME Corp.: Fineract COB Starter'
description = 'ACME Fineract Loan Starter'

group = 'com.acme.fineract'

archivesBaseName = 'acme-fineract-loan-starter'
base {
archivesName = 'acme-fineract-loan-starter'
}

apply from: 'dependencies.gradle'
8 changes: 5 additions & 3 deletions custom/acme/note/service/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@
* specific language governing permissions and limitations
* under the License.
*/
description = 'ACME Corp.: Fineract Note Service'
description = 'ACME Fineract Note Service'

group = 'com.acme.fineract.portfolio.note'
group = 'com.acme.fineract'

archivesBaseName = 'acme-fineract-note-service'
base {
archivesName = 'acme-fineract-note-service'
}

apply from: 'dependencies.gradle'
Loading

0 comments on commit 384a52b

Please sign in to comment.