Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Contributing To AAI By Assisting with Maven Warnings


Coding Style

See also:


Referring to aai-common/pom.xml:

Code Block
languagexml
titleaai-common/pom.xml
collapsetrue
                <!--
                Using https://code.revelc.net/formatter-maven-plugin/ for Eclipse formatter
                Using https://github.com/diffplug/spotless/tree/master/plugin-maven for import order
                Use in combination to rewrite code and imports, then checkstyle
                
                mvn formatter:format spotless:apply process-sources
                -->
                <plugin>
                     <groupId>net.revelc.code.formatter</groupId>
                     <artifactId>formatter-maven-plugin</artifactId>
                     <version>2.8.1</version>
                     <configuration>
                        <configFile>${project.parent.basedir}/onap-java-formatter.xml</configFile>
                     </configuration>
                     <!-- https://code.revelc.net/formatter-maven-plugin/
                          use mvn formatter:format to rewrite source files
                          use mvn formatter:validate to validate source files -->
                 </plugin>
                <plugin>
                  <groupId>com.diffplug.spotless</groupId>
                  <artifactId>spotless-maven-plugin</artifactId>
                  <version>1.18.0</version>
                  <configuration>
                    <java>
                     <importOrder>
                       <order>com,java,javax,org</order>
                     </importOrder>
                    </java>
                  </configuration>
                <!-- https://github.com/diffplug/spotless/tree/master/plugin-maven
                     use mvn spotless:apply to rewrite source files
                     use mvn spotless:check to validate source files -->
                </plugin>


The "onap-java-formatter.xml" file contains an Eclipse formatter configuration, which can be imported and used in the Eclipse IDE by developers writing new code.

The "net.revelc.code.formatter" plugin uses the Eclipse formatter configuration to re-format the Java source code.

The "com.diffplug.spotless" plugin is used to rewrite the "import" statements in the Java source code. Technically, "com.diffplug.spotless" plugin can also use Eclipse formatter configuration to rewrite the Java source code, but it seemed to throw exceptions on some scenarios, making it a less reliable way than the "net.revelc.code.formatter" plugin.

The "com.diffplug.spotless" plugin also has other language capabilities, which could be useful as well, e.g. Javascript, JSON, YAML, etc.

Other projects will be able to use this solution by:

  • copying the pom.xml plugin configuration into their own pom.xml
  • copying the "onap-java-formatter.xml" file into their own code repositories (or refer to it from a common module)