From 344e4fe21a67831a53e6b9488c1563806e4daf72 Mon Sep 17 00:00:00 2001 From: Petri Tuomola Date: Fri, 29 Oct 2021 20:17:36 +0800 Subject: [PATCH] FINERACT-1421: Fixing Eclipse build/debug --- README.md | 7 +++++-- build.gradle | 2 +- .../OpenJPA Enhance Builder.launch | 14 +++++++------- fineract-provider/build.gradle | 16 ++++++++++++++++ 4 files changed, 29 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index e86777292..20e800cfb 100644 --- a/README.md +++ b/README.md @@ -83,10 +83,13 @@ Instructions to run and debug in Eclipse IDE It is possible to run Fineract in Eclipse IDE and also to debug Fineract using Eclipse's debugging facilities. To do this, you need to create the Eclipse project files and import the project into an Eclipse workspace: -1. Import the fineract-provider project into your Eclipse workspace (File->Import->Gradle->Existing Gradle Project into Workspace, choose root directory fineract/fineract-provider) -2. Do a clean build of the project in Eclipse (Project->Clean...) +1. Create Eclipse project files into the Fineract project by running `./gradlew cleanEclipse eclipse` +2. Import the fineract-provider project into your Eclipse workspace (File->Import->General->Existing Projects into Workspace, choose root directory fineract/fineract-provider) +3. Do a clean build of the project in Eclipse (Project->Clean...) 3. Run / debug Fineract by right clicking on org.apache.fineract.ServerApplication class and choosing Run As / Debug As -> Java Application. All normal Eclipse debugging features (breakpoints, watchpoints etc) should work as expected. +If you change the project settings (dependencies etc) in Gradle, you should redo step 1 and refresh the project in Eclipse. + You can also use Eclipse Junit support to run tests in Eclipse (Run As->Junit Test) Finally, modifying source code in Eclipse automatically triggers hot code replace to a running instance, allowing you to immediately test your changes diff --git a/build.gradle b/build.gradle index ebb9a0b38..6152ba9c8 100644 --- a/build.gradle +++ b/build.gradle @@ -355,7 +355,7 @@ allprojects { configure(project.fineractJavaProjects) { // NOTE: order matters! - apply plugin: 'java-library' + apply plugin: 'java' apply plugin: 'idea' apply plugin: 'eclipse' apply plugin: 'checkstyle' diff --git a/fineract-provider/.externalToolBuilders/OpenJPA Enhance Builder.launch b/fineract-provider/.externalToolBuilders/OpenJPA Enhance Builder.launch index a741f730b..38eef72af 100644 --- a/fineract-provider/.externalToolBuilders/OpenJPA Enhance Builder.launch +++ b/fineract-provider/.externalToolBuilders/OpenJPA Enhance Builder.launch @@ -1,10 +1,10 @@ - - - - - - - + + + + + + + diff --git a/fineract-provider/build.gradle b/fineract-provider/build.gradle index cf8b8e8ac..e61d2f2bb 100644 --- a/fineract-provider/build.gradle +++ b/fineract-provider/build.gradle @@ -19,7 +19,9 @@ description = 'Fineract Provider' apply plugin: 'org.zeroturnaround.gradle.jrebel' +apply plugin: 'java' apply plugin: 'war' +apply plugin: 'eclipse' apply plugin: 'org.springframework.boot' apply plugin: 'openjpa' apply plugin: 'com.gorylenko.gradle-git-properties' @@ -175,6 +177,20 @@ war { enabled = true } +// 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: "/.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.outputDir sourceSets.test.output.resourcesDir = sourceSets.test.java.outputDir