From a7983a8c3924f9161dc463585998122862321df0 Mon Sep 17 00:00:00 2001 From: mherman22 Date: Mon, 14 Oct 2024 20:39:33 +0300 Subject: [PATCH 1/3] Add Spotless for code formatting and update documentation --- .../archetype-resources/OpenMRSFormatter.xml | 281 ++++++++++++++++++ .../resources/archetype-resources/README.md | 20 ++ .../archetype-resources/license-header.txt | 7 + .../resources/archetype-resources/pom.xml | 44 ++- .../resources/archetype-resources/README.md | 20 ++ .../resources/archetype-resources/pom.xml | 47 +++ .../archetype-resources/OpenMRSFormatter.xml | 281 ++++++++++++++++++ .../resources/archetype-resources/README.md | 22 +- .../archetype-resources/license-header.txt | 7 + .../resources/archetype-resources/pom.xml | 80 +++-- 10 files changed, 748 insertions(+), 61 deletions(-) create mode 100644 archetype-module-content/src/main/resources/archetype-resources/OpenMRSFormatter.xml create mode 100644 archetype-module-content/src/main/resources/archetype-resources/license-header.txt create mode 100644 archetype-module-refapp/src/main/resources/archetype-resources/OpenMRSFormatter.xml create mode 100644 archetype-module-refapp/src/main/resources/archetype-resources/license-header.txt diff --git a/archetype-module-content/src/main/resources/archetype-resources/OpenMRSFormatter.xml b/archetype-module-content/src/main/resources/archetype-resources/OpenMRSFormatter.xml new file mode 100644 index 000000000..cbca21814 --- /dev/null +++ b/archetype-module-content/src/main/resources/archetype-resources/OpenMRSFormatter.xml @@ -0,0 +1,281 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/archetype-module-content/src/main/resources/archetype-resources/README.md b/archetype-module-content/src/main/resources/archetype-resources/README.md index 7647c7abf..e079b65f2 100644 --- a/archetype-module-content/src/main/resources/archetype-resources/README.md +++ b/archetype-module-content/src/main/resources/archetype-resources/README.md @@ -18,3 +18,23 @@ The contents of a typical Content Package are: * The content.properties file is important because when Implementers add this Content Package to their distribution, the content.properties file will automatically be read and compared with their exitisting distro.properties file. * An automatic distro Build Helper Tool then fetches the content package's information and extracts the content into the Implementation's distro.properties file. * **Dependencies** are especially important here, as the Build Helper Tool will add any dependencies from the Content Package into an Implementation's distro.properties file. + +Running Spotless +---------------- +This project uses Spotless for code formatting. Spotless is embedded in the build process, so when you run `mvn clean package`, Spotless will automatically format your code according to the project's style guidelines. + +If you want to run Spotless separately, you can use the following Maven commands: + +To apply the formatting: + + mvn spotless:apply + +This will automatically format your code according to the project's style guidelines. It's recommended to run this command before committing your changes. + +To check if your code adheres to the style guidelines without making any changes, you can run: + + mvn spotless:check + +If this command reports any violations, you can then run `mvn spotless:apply` to fix them. + +Remember, in most cases, you don't need to run these commands separately as Spotless will run automatically during the build process with `mvn clean package`. diff --git a/archetype-module-content/src/main/resources/archetype-resources/license-header.txt b/archetype-module-content/src/main/resources/archetype-resources/license-header.txt new file mode 100644 index 000000000..23731d754 --- /dev/null +++ b/archetype-module-content/src/main/resources/archetype-resources/license-header.txt @@ -0,0 +1,7 @@ +This Source Code Form is subject to the terms of the Mozilla Public License, +v. 2.0. If a copy of the MPL was not distributed with this file, You can +obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under +the terms of the Healthcare Disclaimer located at http://openmrs.org/license. + +Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS +graphic logo is a trademark of OpenMRS Inc. diff --git a/archetype-module-content/src/main/resources/archetype-resources/pom.xml b/archetype-module-content/src/main/resources/archetype-resources/pom.xml index 6162c6b2a..7832e0cb4 100644 --- a/archetype-module-content/src/main/resources/archetype-resources/pom.xml +++ b/archetype-module-content/src/main/resources/archetype-resources/pom.xml @@ -115,27 +115,41 @@ + - net.revelc.code - impsort-maven-plugin - 1.5.0 - - - - org.codehaus.plexus - plexus-utils - 3.5.1 - - + com.diffplug.spotless + spotless-maven-plugin + 2.27.2 - javax, java, * - true + + + ${project.basedir}/license-header.txt + + + ${project.basedir}/OpenMRSFormatter.xml + + + + javax,java,org,com, + + + + + + **/*.xml + + + ${project.basedir}/license-header.txt + + + + spotless-apply + validate - sort + apply diff --git a/archetype-module-platform/src/main/resources/archetype-resources/README.md b/archetype-module-platform/src/main/resources/archetype-resources/README.md index 4b6eac636..342f369eb 100644 --- a/archetype-module-platform/src/main/resources/archetype-resources/README.md +++ b/archetype-module-platform/src/main/resources/archetype-resources/README.md @@ -19,6 +19,26 @@ It will allow you to deploy any changes to your web resources such as jsp or js files without re-installing the module. The deploy path says where OpenMRS is deployed. +Running Spotless +---------------- +This project uses Spotless for code formatting. Spotless is embedded in the build process, so when you run `mvn clean package`, Spotless will automatically format your code according to the project's style guidelines. + +If you want to run Spotless separately, you can use the following Maven commands: + +To apply the formatting: + + mvn spotless:apply + +This will automatically format your code according to the project's style guidelines. It's recommended to run this command before committing your changes. + +To check if your code adheres to the style guidelines without making any changes, you can run: + + mvn spotless:check + +If this command reports any violations, you can then run `mvn spotless:apply` to fix them. + +Remember, in most cases, you don't need to run these commands separately as Spotless will run automatically during the build process with `mvn clean package`. + Installation ------------ 1. Build the module to produce the .omod file. diff --git a/archetype-module-platform/src/main/resources/archetype-resources/pom.xml b/archetype-module-platform/src/main/resources/archetype-resources/pom.xml index 85a0a6176..6d1d9ae89 100644 --- a/archetype-module-platform/src/main/resources/archetype-resources/pom.xml +++ b/archetype-module-platform/src/main/resources/archetype-resources/pom.xml @@ -52,6 +52,53 @@ + + + + + + com.diffplug.spotless + spotless-maven-plugin + 2.27.2 + + + + ${project.basedir}/license-header.txt + + + ${project.basedir}/OpenMRSFormatter.xml + + + + javax,java,org,com, + + + + + + **/*.xml + + + ${project.basedir}/license-header.txt + + + + + + + spotless-apply + validate + + apply + + + + + + + + + ${openmrsPlatformVersion} diff --git a/archetype-module-refapp/src/main/resources/archetype-resources/OpenMRSFormatter.xml b/archetype-module-refapp/src/main/resources/archetype-resources/OpenMRSFormatter.xml new file mode 100644 index 000000000..cbca21814 --- /dev/null +++ b/archetype-module-refapp/src/main/resources/archetype-resources/OpenMRSFormatter.xml @@ -0,0 +1,281 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/archetype-module-refapp/src/main/resources/archetype-resources/README.md b/archetype-module-refapp/src/main/resources/archetype-resources/README.md index 4b6eac636..448de0e03 100644 --- a/archetype-module-refapp/src/main/resources/archetype-resources/README.md +++ b/archetype-module-refapp/src/main/resources/archetype-resources/README.md @@ -19,12 +19,32 @@ It will allow you to deploy any changes to your web resources such as jsp or js files without re-installing the module. The deploy path says where OpenMRS is deployed. +Running Spotless +---------------- +This project uses Spotless for code formatting. Spotless is embedded in the build process, so when you run `mvn clean package`, Spotless will automatically format your code according to the project's style guidelines. + +If you want to run Spotless separately, you can use the following Maven commands: + +To apply the formatting: + + mvn spotless:apply + +This will automatically format your code according to the project's style guidelines. It's recommended to run this command before committing your changes. + +To check if your code adheres to the style guidelines without making any changes, you can run: + + mvn spotless:check + +If this command reports any violations, you can then run `mvn spotless:apply` to fix them. + +Remember, in most cases, you don't need to run these commands separately as Spotless will run automatically during the build process with `mvn clean package`. + Installation ------------ 1. Build the module to produce the .omod file. 2. Use the OpenMRS Administration > Manage Modules screen to upload and install the .omod file. -If uploads are not allowed from the web (changable via a runtime property), you can drop the omod +If uploads are not allowed from the web (changeable via a runtime property), you can drop the omod into the ~/.OpenMRS/modules folder. (Where ~/.OpenMRS is assumed to be the Application Data Directory that the running openmrs is currently using.) After putting the file in there simply restart OpenMRS/tomcat and the module will be loaded and started. diff --git a/archetype-module-refapp/src/main/resources/archetype-resources/license-header.txt b/archetype-module-refapp/src/main/resources/archetype-resources/license-header.txt new file mode 100644 index 000000000..23731d754 --- /dev/null +++ b/archetype-module-refapp/src/main/resources/archetype-resources/license-header.txt @@ -0,0 +1,7 @@ +This Source Code Form is subject to the terms of the Mozilla Public License, +v. 2.0. If a copy of the MPL was not distributed with this file, You can +obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under +the terms of the Healthcare Disclaimer located at http://openmrs.org/license. + +Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS +graphic logo is a trademark of OpenMRS Inc. diff --git a/archetype-module-refapp/src/main/resources/archetype-resources/pom.xml b/archetype-module-refapp/src/main/resources/archetype-resources/pom.xml index 20985c0fc..9e15146d2 100644 --- a/archetype-module-refapp/src/main/resources/archetype-resources/pom.xml +++ b/archetype-module-refapp/src/main/resources/archetype-resources/pom.xml @@ -124,61 +124,51 @@ + - net.revelc.code.formatter - formatter-maven-plugin - 2.13.0 - - LF - eclipse/OpenMRSFormatter.xml - - - - org.openmrs.tools - openmrs-tools - ${openmrsPlatformToolsVersion} - - - - - - format - - - + org.apache.maven.plugins + maven-resources-plugin + 3.1.0 + - net.revelc.code - impsort-maven-plugin - 1.5.0 - - - - org.codehaus.plexus - plexus-utils - 3.5.1 - - + com.diffplug.spotless + spotless-maven-plugin + 2.27.2 - javax, java, * - true + + + ${project.basedir}/license-header.txt + + + ${project.basedir}/OpenMRSFormatter.xml + + + + javax,java,org,com, + + + + + + **/*.xml + + + ${project.basedir}/license-header.txt + + + + spotless-apply + validate - sort + apply - - - org.apache.maven.plugins - maven-resources-plugin - 3.1.0 - - @@ -186,8 +176,8 @@ openmrs-repo - OpenMRS Nexus Repository - https://mavenrepo.openmrs.org/public + OpenMRS Nexus Repository + https://mavenrepo.openmrs.org/public central From c47be74b7293c8e40ac5e855dacd034974a58c49 Mon Sep 17 00:00:00 2001 From: mherman22 Date: Mon, 14 Oct 2024 21:42:34 +0300 Subject: [PATCH 2/3] fix failing integration test --- .../META-INF/maven/archetype-metadata.xml | 2 + .../resources/archetype-resources/pom.xml | 1 + .../basic/reference/OpenMRSFormatter.xml | 281 ++++++++++++++++++ .../projects/basic/reference/README.md | 20 ++ .../basic/reference/license-header.txt | 7 + .../projects/basic/reference/pom.xml | 45 ++- .../resources/archetype-resources/pom.xml | 1 + .../resources/archetype-resources/pom.xml | 1 + 8 files changed, 343 insertions(+), 15 deletions(-) create mode 100644 archetype-module-content/src/test/resources/projects/basic/reference/OpenMRSFormatter.xml create mode 100644 archetype-module-content/src/test/resources/projects/basic/reference/license-header.txt diff --git a/archetype-module-content/src/main/resources/META-INF/maven/archetype-metadata.xml b/archetype-module-content/src/main/resources/META-INF/maven/archetype-metadata.xml index 5fbdefc15..a7d76be2a 100644 --- a/archetype-module-content/src/main/resources/META-INF/maven/archetype-metadata.xml +++ b/archetype-module-content/src/main/resources/META-INF/maven/archetype-metadata.xml @@ -33,6 +33,8 @@ assembly.xml .gitignore content.properties + license-header.txt + OpenMRSFormatter.xml pom.xml README.md diff --git a/archetype-module-content/src/main/resources/archetype-resources/pom.xml b/archetype-module-content/src/main/resources/archetype-resources/pom.xml index 7832e0cb4..2ece7ca3e 100644 --- a/archetype-module-content/src/main/resources/archetype-resources/pom.xml +++ b/archetype-module-content/src/main/resources/archetype-resources/pom.xml @@ -140,6 +140,7 @@ ${project.basedir}/license-header.txt + ^(?!<\?xml) diff --git a/archetype-module-content/src/test/resources/projects/basic/reference/OpenMRSFormatter.xml b/archetype-module-content/src/test/resources/projects/basic/reference/OpenMRSFormatter.xml new file mode 100644 index 000000000..cbca21814 --- /dev/null +++ b/archetype-module-content/src/test/resources/projects/basic/reference/OpenMRSFormatter.xml @@ -0,0 +1,281 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/archetype-module-content/src/test/resources/projects/basic/reference/README.md b/archetype-module-content/src/test/resources/projects/basic/reference/README.md index 7647c7abf..e079b65f2 100644 --- a/archetype-module-content/src/test/resources/projects/basic/reference/README.md +++ b/archetype-module-content/src/test/resources/projects/basic/reference/README.md @@ -18,3 +18,23 @@ The contents of a typical Content Package are: * The content.properties file is important because when Implementers add this Content Package to their distribution, the content.properties file will automatically be read and compared with their exitisting distro.properties file. * An automatic distro Build Helper Tool then fetches the content package's information and extracts the content into the Implementation's distro.properties file. * **Dependencies** are especially important here, as the Build Helper Tool will add any dependencies from the Content Package into an Implementation's distro.properties file. + +Running Spotless +---------------- +This project uses Spotless for code formatting. Spotless is embedded in the build process, so when you run `mvn clean package`, Spotless will automatically format your code according to the project's style guidelines. + +If you want to run Spotless separately, you can use the following Maven commands: + +To apply the formatting: + + mvn spotless:apply + +This will automatically format your code according to the project's style guidelines. It's recommended to run this command before committing your changes. + +To check if your code adheres to the style guidelines without making any changes, you can run: + + mvn spotless:check + +If this command reports any violations, you can then run `mvn spotless:apply` to fix them. + +Remember, in most cases, you don't need to run these commands separately as Spotless will run automatically during the build process with `mvn clean package`. diff --git a/archetype-module-content/src/test/resources/projects/basic/reference/license-header.txt b/archetype-module-content/src/test/resources/projects/basic/reference/license-header.txt new file mode 100644 index 000000000..23731d754 --- /dev/null +++ b/archetype-module-content/src/test/resources/projects/basic/reference/license-header.txt @@ -0,0 +1,7 @@ +This Source Code Form is subject to the terms of the Mozilla Public License, +v. 2.0. If a copy of the MPL was not distributed with this file, You can +obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under +the terms of the Healthcare Disclaimer located at http://openmrs.org/license. + +Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS +graphic logo is a trademark of OpenMRS Inc. diff --git a/archetype-module-content/src/test/resources/projects/basic/reference/pom.xml b/archetype-module-content/src/test/resources/projects/basic/reference/pom.xml index ea8cddba2..8435b9d36 100644 --- a/archetype-module-content/src/test/resources/projects/basic/reference/pom.xml +++ b/archetype-module-content/src/test/resources/projects/basic/reference/pom.xml @@ -115,27 +115,42 @@ + - net.revelc.code - impsort-maven-plugin - 1.5.0 - - - - org.codehaus.plexus - plexus-utils - 3.5.1 - - + com.diffplug.spotless + spotless-maven-plugin + 2.27.2 - javax, java, * - true + + + ${project.basedir}/license-header.txt + + + ${project.basedir}/OpenMRSFormatter.xml + + + + javax,java,org,com, + + + + + + **/*.xml + + + ${project.basedir}/license-header.txt + ^(?!<\?xml) + + + + spotless-apply + validate - sort + apply diff --git a/archetype-module-platform/src/main/resources/archetype-resources/pom.xml b/archetype-module-platform/src/main/resources/archetype-resources/pom.xml index 6d1d9ae89..629ea2018 100644 --- a/archetype-module-platform/src/main/resources/archetype-resources/pom.xml +++ b/archetype-module-platform/src/main/resources/archetype-resources/pom.xml @@ -80,6 +80,7 @@ ${project.basedir}/license-header.txt + ^(?!<\?xml) diff --git a/archetype-module-refapp/src/main/resources/archetype-resources/pom.xml b/archetype-module-refapp/src/main/resources/archetype-resources/pom.xml index 9e15146d2..56bfad349 100644 --- a/archetype-module-refapp/src/main/resources/archetype-resources/pom.xml +++ b/archetype-module-refapp/src/main/resources/archetype-resources/pom.xml @@ -155,6 +155,7 @@ ${project.basedir}/license-header.txt + ^(?!<\?xml) From be62c86da397eb00b28485138c194e5903aed118 Mon Sep 17 00:00:00 2001 From: mherman22 Date: Tue, 15 Oct 2024 16:40:59 +0300 Subject: [PATCH 3/3] reviews --- .../src/main/resources/archetype-resources/pom.xml | 2 +- .../src/test/resources/projects/basic/reference/pom.xml | 2 +- .../src/main/resources/archetype-resources/pom.xml | 2 +- .../src/main/resources/archetype-resources/pom.xml | 6 +++--- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/archetype-module-content/src/main/resources/archetype-resources/pom.xml b/archetype-module-content/src/main/resources/archetype-resources/pom.xml index 2ece7ca3e..41d249ba5 100644 --- a/archetype-module-content/src/main/resources/archetype-resources/pom.xml +++ b/archetype-module-content/src/main/resources/archetype-resources/pom.xml @@ -130,7 +130,7 @@ - javax,java,org,com, + javax,java diff --git a/archetype-module-content/src/test/resources/projects/basic/reference/pom.xml b/archetype-module-content/src/test/resources/projects/basic/reference/pom.xml index 8435b9d36..a2772a674 100644 --- a/archetype-module-content/src/test/resources/projects/basic/reference/pom.xml +++ b/archetype-module-content/src/test/resources/projects/basic/reference/pom.xml @@ -130,7 +130,7 @@ - javax,java,org,com, + javax,java diff --git a/archetype-module-platform/src/main/resources/archetype-resources/pom.xml b/archetype-module-platform/src/main/resources/archetype-resources/pom.xml index 629ea2018..158a47f02 100644 --- a/archetype-module-platform/src/main/resources/archetype-resources/pom.xml +++ b/archetype-module-platform/src/main/resources/archetype-resources/pom.xml @@ -70,7 +70,7 @@ - javax,java,org,com, + javax,java diff --git a/archetype-module-refapp/src/main/resources/archetype-resources/pom.xml b/archetype-module-refapp/src/main/resources/archetype-resources/pom.xml index 56bfad349..8bdae3f34 100644 --- a/archetype-module-refapp/src/main/resources/archetype-resources/pom.xml +++ b/archetype-module-refapp/src/main/resources/archetype-resources/pom.xml @@ -145,7 +145,7 @@ - javax,java,org,com, + javax,java @@ -177,8 +177,8 @@ openmrs-repo - OpenMRS Nexus Repository - https://mavenrepo.openmrs.org/public + OpenMRS Nexus Repository + https://mavenrepo.openmrs.org/public central