Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SDK-340: Add Spotless for code formatting and update documentation #300

Merged
merged 3 commits into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
<include>assembly.xml</include>
<include>.gitignore</include>
<include>content.properties</include>
<include>license-header.txt</include>
<include>OpenMRSFormatter.xml</include>
<include>pom.xml</include>
<include>README.md</include>
</includes>
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Original file line number Diff line number Diff line change
@@ -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.
Original file line number Diff line number Diff line change
Expand Up @@ -115,27 +115,42 @@
</execution>
</executions>
</plugin>
<!-- Spotless plugin -->
<plugin>
<groupId>net.revelc.code</groupId>
<artifactId>impsort-maven-plugin</artifactId>
<version>1.5.0</version>
<dependencies>
<!-- Needed because of maven 3.9.0 backward compatibility issue,
See : https://github.com/revelc/impsort-maven-plugin/issues/64 -->
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-utils</artifactId>
<version>3.5.1</version>
</dependency>
</dependencies>
<groupId>com.diffplug.spotless</groupId>
<artifactId>spotless-maven-plugin</artifactId>
<version>2.27.2</version>
<configuration>
<groups>javax, java, *</groups>
<removeUnused>true</removeUnused>
<java>
<licenseHeader>
<file>${project.basedir}/license-header.txt</file>
</licenseHeader>
<eclipse>
<file>${project.basedir}/OpenMRSFormatter.xml</file>
</eclipse>
<removeUnusedImports/>
<importOrder>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't we want <removeUnusedImports /> in this block too?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<order>javax,java</order>
</importOrder>
</java>
<formats>
<format>
<includes>
<include>**/*.xml</include>
</includes>
<licenseHeader>
<file>${project.basedir}/license-header.txt</file>
<delimiter>^(?!&lt;\?xml)</delimiter>
</licenseHeader>
</format>
</formats>
</configuration>
<executions>
<execution>
<id>spotless-apply</id>
<phase>validate</phase>
<goals>
<goal>sort</goal>
<goal>apply</goal>
</goals>
</execution>
</executions>
Expand Down
Loading
Loading