Subject: [PATCH] See #8269: Add support for maven as an alternative to Eclipse and ant

See CONTRIBUTING.md for a mapping of `ant` tasks to `maven` tasks/goals.
Of note, each mapping is as close to a 1-1 match as possible. In the event that
we move off of `ant`, the `pom.xml` file can be simplified, especially if the
directory layout is changed to the maven defaults.
---
Index: tools/checkstyle/jmapviewer_checks.xml
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/tools/checkstyle/jmapviewer_checks.xml b/tools/checkstyle/jmapviewer_checks.xml
--- a/tools/checkstyle/jmapviewer_checks.xml	(revision 36196)
+++ b/tools/checkstyle/jmapviewer_checks.xml	(date 1703615281508)
@@ -112,7 +112,7 @@
     <property name="lineSeparator" value="lf"/>
   </module>
   <module name="SuppressionFilter">
-    <property name="file" value="${basedir}/tools/checkstyle/jmapviewer_filters.xml"/>
+    <property name="file" value="tools/checkstyle/jmapviewer_filters.xml"/>
     <property name="optional" value="true"/>
   </module>
   <module name="SuppressWithPlainTextCommentFilter">
Index: build.xml
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/build.xml b/build.xml
--- a/build.xml	(revision 36196)
+++ b/build.xml	(date 1703684663771)
@@ -139,7 +139,7 @@
     <target name="checkstyle" depends="resolve">
         <taskdef resource="com/puppycrawl/tools/checkstyle/ant/checkstyle-ant-task.properties"
             classpathref="checkstyle.classpath"/>
-        <checkstyle config="tools/checkstyle/jmapviewer_checks.xml">
+        <checkstyle config="${basedir}/tools/checkstyle/jmapviewer_checks.xml">
             <!-- Exclude the module-info since checkstyle currently cannot parse it -->
             <fileset dir="${basedir}/src" includes="**/*.java" excludes="module-info.java" />
             <formatter type="xml" toFile="checkstyle-jmapviewer.xml"/>
Index: CONTRIBUTING.md
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
new file mode 100644
--- /dev/null	(date 1703684067357)
+++ b/CONTRIBUTING.md	(date 1703684067357)
@@ -0,0 +1,31 @@
+# Contributing
+## How to test
+* Unit tests: `mvn test`
+* Manual testing: `mvn compile exec:java -Dexec.mainClass=org.openstreetmap.gui.jmapviewer.Demo`
+
+## How to report a bug
+Please open a ticket at [https://josm.openstreetmap.de/newticket?component=JMapViewer](https://josm.openstreetmap.de/newticket?component=JMapViewer).
+
+## How to submit changes
+Open a ticket at [https://josm.openstreetmap.de/newticket?component=JMapViewer](https://josm.openstreetmap.de/newticket?component=JMapViewer).
+See [https://josm.openstreetmap.de/wiki/DevelopersGuide/PatchGuide](https://josm.openstreetmap.de/wiki/DevelopersGuide/PatchGuide) for how to create the patch file and submit it.
+
+## Check patch conformance
+* `mvn validate`
+  * `mvn checkstyle:checkstyle`
+* `mvn spotbugs:check` -- this should be done by `mvn validate` as well, but it 
+  wasn't possible at time of writing due to existing spotbugs bugs in JMapViewer.
+
+## Ant targets -> Maven targets
+* `ant clean` -> `mvn clean`
+* `ant build` -> `mvn compile`
+* `ant test` -> `mvn test`
+* `ant svn_info` -> manual pom.xml editing for now
+* `ant pack` -> `mvn package` (note: slightly different source filename)
+* `ant create_run_jar` -> not migrated (use `mvn exec:java -Dexec.mainClass="org.openstreetmap.gui.jmapviewer.Demo"` instead)
+* `ant spotbugs` -> `mvn spotbugs:check`
+* `ant checkstyle` -> `mvn checkstyle:checkstyle`
+* `ant javadoc` -> `mvn javadoc:javadoc`
+* `ant create_release_zip` -> `mvn jar:jar`
+* `ant create_source_release_zip` -> `mvn source:jar`
+* `ant checkdepsupdate` -> `mvn versions:display-dependency-updates`
Index: pom.xml
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/pom.xml b/pom.xml
new file mode 100644
--- /dev/null	(date 1703683673737)
+++ b/pom.xml	(date 1703683673737)
@@ -0,0 +1,277 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <groupId>org.openstreetmap.jmapviewer</groupId>
+    <artifactId>jmapviewer</artifactId>
+    <version>2.19-SNAPSHOT</version>
+
+    <name>JMapViewer</name>
+    <url>https://josm.openstreetmap.de/browser/osm/applications/viewer/jmapviewer</url>
+    <properties>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+        <maven.compiler.release>8</maven.compiler.release>
+        <version.maven.spotbugs>4.8.1.0</version.maven.spotbugs>
+        <version.maven.jacoco>0.8.11</version.maven.jacoco>
+    </properties>
+    <licenses>
+        <license><!-- Might be GPL-2.0-or-later, but no instances of "or later" in source code -->
+            <name>GPL-2.0-only</name>
+            <url>https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html</url>
+            <distribution>repo</distribution>
+        </license>
+    </licenses>
+    <organization>
+        <name>JOSM</name>
+        <url>https://josm.openstreetmap.de</url>
+    </organization>
+    <contributors>
+        <contributor><name>Tim Haussmann</name></contributor>
+        <contributor><name>Jan Peter Stotz</name></contributor>
+        <contributor><name>Dirk Stöcker</name></contributor>
+        <contributor><name>Stefan Zeller</name></contributor>
+        <contributor><name>Karl Guggisberg</name></contributor>
+        <contributor><name>Dave Hansen</name></contributor>
+        <contributor><name>Ian Dees</name></contributor>
+        <contributor><name>Michael Vigovsky</name></contributor>
+        <contributor><name>Paul Hartmann</name></contributor>
+        <contributor><name>Gleb Smirnoff</name></contributor>
+        <contributor><name>Vincent Privat</name></contributor>
+        <contributor><name>Jason Huntley</name></contributor>
+        <contributor><name>Simon Legner</name></contributor>
+        <contributor><name>Teemu Koskinen</name></contributor>
+        <contributor><name>Jiri Klement</name></contributor>
+        <contributor><name>Matt Hoover</name></contributor>
+        <contributor><name>Alexei Kasatkin</name></contributor>
+        <contributor><name>Galo Higueras</name></contributor>
+        <contributor><name>Wiktor Niesiobędzki</name></contributor>
+        <contributor><name>Robert Scott</name></contributor>
+    </contributors>
+    <scm>
+        <connection>scm:svn:https://josm.openstreetmap.de/osmsvn/applications/viewer/jmapviewer/</connection>
+        <url>https://josm.openstreetmap.de/browser/osm/applications/viewer/jmapviewer/</url>
+    </scm>
+    <issueManagement>
+        <system>Trac</system>
+        <url>https://josm.openstreetmap.de</url>
+    </issueManagement>
+    <mailingLists>
+        <mailingList>
+            <name>josm-dev</name>
+            <archive>https://lists.openstreetmap.org/pipermail/josm-dev/</archive>
+            <post>josm-dev@openstreetmap.org</post>
+        </mailingList>
+    </mailingLists>
+    <distributionManagement>
+        <repository>
+            <id>josm-nexus-releases</id>
+            <name>JOSM Nexus (Releases)</name>
+            <url>https://josm.openstreetmap.de/nexus/content/repositories/releases/</url>
+        </repository>
+        <snapshotRepository>
+            <id>josm-nexus-snapshot</id>
+            <name>JOSM Nexus (Snapshot)</name>
+            <url>https://josm.openstreetmap.de/nexus/content/repositories/snapshots/</url>
+        </snapshotRepository>
+    </distributionManagement>
+
+    <dependencyManagement>
+        <dependencies>
+            <dependency>
+                <groupId>org.junit</groupId>
+                <artifactId>junit-bom</artifactId>
+                <version>5.10.1</version>
+                <type>pom</type>
+                <scope>import</scope>
+            </dependency>
+        </dependencies>
+    </dependencyManagement>
+
+    <dependencies>
+        <dependency>
+            <groupId>com.github.spotbugs</groupId>
+            <artifactId>spotbugs-annotations</artifactId>
+            <version>4.8.3</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.junit.platform</groupId>
+            <artifactId>junit-platform-launcher</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.junit.platform</groupId>
+            <artifactId>junit-platform-suite</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.junit.jupiter</groupId>
+            <artifactId>junit-jupiter-api</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.junit.jupiter</groupId>
+            <artifactId>junit-jupiter-engine</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.junit.jupiter</groupId>
+            <artifactId>junit-jupiter-params</artifactId>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <sourceDirectory>${project.basedir}/src</sourceDirectory>
+        <testSourceDirectory>${project.basedir}/test</testSourceDirectory>
+        <finalName>${project.name}-${project.version}</finalName>
+        <resources>
+            <resource>
+                <directory>${project.build.sourceDirectory}</directory>
+                <includes>
+                    <include>
+                        **/*.png
+                    </include>
+                </includes>
+            </resource>
+        </resources>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-jar-plugin</artifactId>
+                <version>3.3.0</version>
+                <configuration>
+                    <outputDirectory>releases/${project.version}</outputDirectory>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-source-plugin</artifactId>
+                <version>3.3.0</version>
+                <configuration>
+                    <outputDirectory>releases/${project.version}</outputDirectory>
+                </configuration>
+                <executions>
+                    <execution>
+                        <id>attach-sources</id>
+                        <phase>package</phase>
+                        <goals>
+                            <goal>jar-no-fork</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <version>3.11.0</version>
+                <executions>
+                    <execution>
+                        <id>default-compile</id>
+                        <configuration>
+                            <release>11</release>
+                        </configuration>
+                    </execution>
+                    <execution>
+                        <id>base-compile</id>
+                        <goals>
+                            <goal>compile</goal>
+                        </goals>
+                        <configuration>
+                            <release>8</release>
+                            <excludes>
+                                <exclude>module-info.java</exclude>
+                            </excludes>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+            <!-- Start optional plugins (these can be removed by Linux distributions for building) -->
+            <plugin>
+                <groupId>org.jacoco</groupId>
+                <artifactId>jacoco-maven-plugin</artifactId>
+                <version>${version.maven.jacoco}</version>
+                <executions>
+                    <execution>
+                        <id>default-prepare-agent</id>
+                        <goals>
+                            <goal>prepare-agent</goal>
+                        </goals>
+                    </execution>
+                    <execution>
+                        <id>default-report</id>
+                        <goals>
+                            <goal>report</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+            <plugin>
+                <groupId>com.github.spotbugs</groupId>
+                <artifactId>spotbugs-maven-plugin</artifactId>
+                <version>${version.maven.spotbugs}</version>
+                <configuration>
+                    <xmlOutput>true</xmlOutput>
+                    <spotbugsXmlOutputFilename>spotbugs-jmapviewer.xml</spotbugsXmlOutputFilename>
+                    <effort>max</effort>
+                </configuration>
+                <!-- This is commented out until all the current bugs are fixed. TODO uncomment!
+                <executions>
+                    <execution>
+                        <id>validate</id>
+                        <phase>validate</phase>
+                        <goals>
+                            <goal>check</goal>
+                        </goals>
+                    </execution>
+                </executions>
+                -->
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-checkstyle-plugin</artifactId>
+                <version>3.3.1</version>
+                <configuration>
+                    <configLocation>${project.basedir}/tools/checkstyle/jmapviewer_checks.xml</configLocation>
+                    <includeTestSourceDirectory>true</includeTestSourceDirectory>
+                    <outputFile>${project.basedir}/checkstyle-jmapviewer.xml</outputFile>
+                    <!-- checkstyle cannot parse module-info.java yet -->
+                    <excludes>module-info.java</excludes>
+                </configuration>
+                <executions>
+                    <execution>
+                        <id>validate</id>
+                        <phase>validate</phase>
+                        <goals>
+                            <goal>check</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+
+    <reporting>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-surefire-report-plugin</artifactId>
+                <version>3.2.3</version>
+            </plugin>
+            <plugin>
+                <groupId>org.jacoco</groupId>
+                <artifactId>jacoco-maven-plugin</artifactId>
+                <version>${version.maven.jacoco}</version>
+                <reportSets>
+                    <reportSet>
+                        <reports>
+                            <report>report</report>
+                        </reports>
+                    </reportSet>
+                </reportSets>
+            </plugin>
+        </plugins>
+    </reporting>
+</project>
