<?xml version="1.0" encoding="UTF-8"?>
<!--
GlobalMentor, Inc. Root POM
Copyright © 2018-2019 GlobalMentor, Inc. (http://www.globalmentor.com/)

## Properties

`project.releaseVersion`
: Set to the version to use for release, without any qualifiers, as per [Semantic Versioning 2.0.0 Item 9](https://semver.org/#spec-item-9).
  For example, both `1.2.3-SNAPSHOT` and `1.2.3-beta.4` yield a release version of `1.2.3`.
`build.year`
: Set to the year in which the project was built, in UTC; a string in the format `YYYY`. 
`build.date`
: Set to the date on which the project was built, in UTC; a string in the format `YYYY-MM-DD`.
`binSourceDirectory`
: The source directory for scripts; defaults to `${project.basedir}/src/bin`.
`binOutputDirectory`
: The output directory for scripts; defaults to `${project.build.directory}/bin`
`exe.main.class`
: The full class name of the class containing the `main()` method for an executable JAR; no default.

## Scripts

To copy and process scripts, include the following plugins as desired.

```xml
<plugin>
	<groupId>org.apache.maven.plugins</groupId>
	<artifactId>maven-resources-plugin</artifactId>
	<executions>
		<execution>
			<id>copy-bin</id>
			<phase>process-resources</phase>
		</execution>
	</executions>
</plugin>
<plugin>
	<groupId>org.apache.maven.plugins</groupId>
	<artifactId>maven-antrun-plugin</artifactId>
	<executions>
		<execution>
			<id>set-shell-scripts-executable</id>
			<phase>process-resources</phase>
		</execution>
		<execution>
			<id>remove-shell-script-extensions</id>
			<phase>process-resources</phase>
		</execution>
	</executions>
</plugin>
```

## Executables

To generate an executable, define `exe.main.class` and then include the following plugins as desired.
Note that the AntRun `create-bin-output-dir` execution is optional if a previous execution,
such as `copy-bin`, did not create the output bin directory already.

```xml
<plugin>
	<groupId>org.apache.maven.plugins</groupId>
	<artifactId>maven-antrun-plugin</artifactId>
	<executions>
		<execution>
			<id>create-bin-output-dir</id>
			<phase>process-resources</phase>
		</execution>
	</executions>
</plugin>
<plugin>
	<groupId>org.apache.maven.plugins</groupId>
	<artifactId>maven-shade-plugin</artifactId>
	<executions>
		<execution>
			<id>generate-exe-jar</id>
			<phase>package</phase>
		</execution>
	</executions>
</plugin>
<plugin>
	<groupId>com.akathist.maven.plugins.launch4j</groupId>
	<artifactId>launch4j-maven-plugin</artifactId>
	<executions>
		<execution>
			<id>generate-exe</id>
			<phase>package</phase>
		</execution>
	</executions>
</plugin>
```
 -->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 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>com.globalmentor</groupId>
	<artifactId>globalmentor-root</artifactId>
	<version>0.8.7</version>
	<packaging>pom</packaging>

	<name>GlobalMentor Root</name>
	<description>GlobalMentor root POM.</description>
	<url>http://www.globalmentor.com/software/</url>

	<organization>
		<name>GlobalMentor, Inc.</name>
		<url>http://www.globalmentor.com/</url>
	</organization>

	<developers>
		<developer>
			<name>Garret Wilson</name>
			<email>garret@globalmentor.com</email>
			<organization>GlobalMentor, Inc.</organization>
			<organizationUrl>http://www.globalmentor.com/</organizationUrl>
		</developer>
	</developers>

	<licenses>
		<license>
			<name>Apache License, Version 2.0</name>
			<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
			<distribution>repo</distribution>
		</license>
	</licenses>

	<scm>
		<connection>scm:git:https://bitbucket.org/globalmentor/globalmentor-pom.git</connection>
		<developerConnection>scm:git:https://bitbucket.org/globalmentor/globalmentor-pom.git</developerConnection>
		<url>https://bitbucket.org/globalmentor/globalmentor-pom</url>
	</scm>

	<modules>
		<module>../root-opensource</module>
	</modules>

	<properties>
		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
		<maven.compiler.source>1.8</maven.compiler.source>
		<maven.compiler.target>1.8</maven.compiler.target>
		<gpg.keyname>software@globalmentor.com</gpg.keyname>
		<mockito.version>3.2.4</mockito.version>
		<junit.version>5.5.2</junit.version>
		<hamcrest.version>2.2</hamcrest.version>
		<binSourceDirectory>${project.basedir}/src/bin</binSourceDirectory>
		<binOutputDirectory>${project.build.directory}/bin</binOutputDirectory>
		<!-- set if generating executable JAR and exe file
			<exe.main.class>com.example.cli.Example</exe.main.class>
		-->
		<exe.filename>${project.artifactId}.exe</exe.filename>
	</properties>

	<dependencies>
		<dependency>
			<groupId>com.google.code.findbugs</groupId>
			<artifactId>jsr305</artifactId>
			<optional>true</optional>
		</dependency>

		<!-- test scope dependencies -->

		<dependency>
			<groupId>org.junit.jupiter</groupId>
			<artifactId>junit-jupiter-engine</artifactId>
			<scope>test</scope>
		</dependency>

		<dependency>
			<groupId>org.junit.vintage</groupId>
			<artifactId>junit-vintage-engine</artifactId>
			<scope>test</scope>
		</dependency>

		<dependency>
			<groupId>org.hamcrest</groupId>
			<artifactId>hamcrest</artifactId>
			<scope>test</scope>
		</dependency>

		<dependency>
			<groupId>org.hamcrest</groupId>
			<artifactId>hamcrest-core</artifactId>
			<scope>test</scope>
		</dependency>

		<dependency>
			<groupId>com.github.npathai</groupId>
			<artifactId>hamcrest-optional</artifactId>
			<scope>test</scope>
		</dependency>

		<dependency>
			<groupId>org.slf4j</groupId>
			<artifactId>slf4j-simple</artifactId>
			<scope>test</scope>
		</dependency>
	</dependencies>

	<dependencyManagement>
		<dependencies>
			<dependency>
				<groupId>com.github.npathai</groupId>
				<artifactId>hamcrest-optional</artifactId>
				<version>2.0.0</version>
			</dependency>

			<dependency>
				<groupId>com.google.code.findbugs</groupId>
				<artifactId>jsr305</artifactId>
				<version>3.0.2</version>
			</dependency>

			<dependency>
				<groupId>org.junit.jupiter</groupId>
				<artifactId>junit-jupiter-engine</artifactId>
				<version>${junit.version}</version>
			</dependency>

			<dependency>
				<groupId>org.junit.vintage</groupId>
				<artifactId>junit-vintage-engine</artifactId>
				<version>${junit.version}</version>
			</dependency>

			<dependency>
				<groupId>org.hamcrest</groupId>
				<artifactId>hamcrest</artifactId>
				<version>${hamcrest.version}</version>
			</dependency>

			<!-- 
				This dependency was included so JUnit Vintage, i.e., Junit `4.12`, doesn't pull in the outdated version `1.3` of `hamcrest-core`.
				This should be removed whenever JUnit Vintage is removed as well.

				See [Hamcrest Issue #224](https://github.com/hamcrest/JavaHamcrest/issues/224).
			-->
			<dependency>
				<groupId>org.hamcrest</groupId>
				<artifactId>hamcrest-core</artifactId>
				<version>${hamcrest.version}</version>
			</dependency>

			<dependency>
				<groupId>org.slf4j</groupId>
				<artifactId>slf4j-simple</artifactId>
				<version>1.7.30</version>
			</dependency>

			<dependency>
				<groupId>org.mockito</groupId>
				<artifactId>mockito-core</artifactId>
				<version>${mockito.version}</version>
			</dependency>

			<dependency>
				<groupId>org.zalando</groupId>
				<artifactId>faux-pas</artifactId>
				<version>0.8.0</version>
			</dependency>

			<dependency>
				<groupId>javax.servlet</groupId>
				<artifactId>javax.servlet-api</artifactId>
				<version>4.0.1</version>
			</dependency>

			<dependency>
				<groupId>javax.ws.rs</groupId>
				<artifactId>javax.ws.rs-api</artifactId>
				<version>2.1.1</version>
			</dependency>

			<dependency>
				<groupId>javax.servlet.jsp</groupId>
				<artifactId>javax.servlet.jsp-api</artifactId>
				<version>2.3.3</version>
			</dependency>

			<dependency>
				<groupId>javax.servlet</groupId>
				<artifactId>jstl</artifactId>
				<version>1.2</version>
			</dependency>

			<dependency>
				<groupId>javax.faces</groupId>
				<artifactId>javax.faces-api</artifactId>
				<version>2.3</version>
				<scope>provided</scope>
			</dependency>

			<dependency>
				<groupId>javax.el</groupId>
				<artifactId>javax.el-api</artifactId>
				<version>3.0.0</version>
				<scope>provided</scope>
			</dependency>
		</dependencies>
	</dependencyManagement>

	<build>
		<pluginManagement>
			<plugins>
				<plugin>
					<groupId>com.akathist.maven.plugins.launch4j</groupId>
					<artifactId>launch4j-maven-plugin</artifactId>
					<version>1.7.25</version>
					<executions>
						<execution>
							<id>generate-exe</id>
							<!--
								Generates a Windows `.exe` file from the `-exe.jar` in `${buildDirectory}`.
								Depends on the output of the `maven-shade-plugin` `generate-exe-jar` execution.  
								Enable by specifying a phase (e.g. `package`) in child POM.
							 -->
							<phase>none</phase>
							<goals>
								<goal>launch4j</goal>
							</goals>
							<configuration>
								<headerType>console</headerType>
								<outfile>${binOutputDirectory}/${exe.filename}</outfile>
								<jar>${project.build.directory}/${project.artifactId}-${project.version}-exe.jar</jar>
								<errTitle>${project.name}</errTitle>
								<jre>
									<minVersion>${maven.compiler.release}</minVersion>
								</jre>
								<versionInfo>
									<fileVersion>${project.releaseVersion}.0</fileVersion>
									<txtFileVersion>${project.version}</txtFileVersion>
									<fileDescription>${project.description}</fileDescription>
									<copyright>Copyright © ${project.inceptionYear}-${build.year} ${project.organization.name}. All rights reserved.</copyright>
									<productName>${project.name}</productName>
									<internalName>${project.artifactId}</internalName>
									<productVersion>${project.releaseVersion}.0</productVersion>
									<txtProductVersion>${project.version}</txtProductVersion>
									<originalFilename>${exe.filename}</originalFilename>
								</versionInfo>
							</configuration>
						</execution>
					</executions>
				</plugin>

				<plugin>
					<groupId>org.apache.maven.plugins</groupId>
					<artifactId>maven-antrun-plugin</artifactId>
					<version>1.8</version>
					<executions>
						<execution>
							<id>create-bin-output-dir</id>
							<!--
								Create the `${binOutputDirectory}` directory for use by later tasks.
								Enable by specifying a phase (e.g. `process-resources`) in child POM.
							 -->
							<phase>none</phase>
							<goals>
								<goal>run</goal>
							</goals>
							<configuration>
								<target>
									<mkdir dir="${binOutputDirectory}" />
								</target>
							</configuration>
						</execution>
						<execution>
							<id>set-shell-scripts-executable</id>
							<!--
								Enable execute permission for the shell scripts in `${binOutputDirectory}`.
								Enable by specifying a phase (e.g. `process-resources`) in child POM.
							 -->
							<phase>none</phase>
							<goals>
								<goal>run</goal>
							</goals>
							<configuration>
								<target>
									<chmod dir="${binOutputDirectory}" includes="**/*.sh" perm="+x" />
								</target>
							</configuration>
						</execution>
						<execution>
							<id>remove-shell-script-extensions</id>
							<!--
								Remove the `.sh` extension from shell scripts in `${binOutputDirectory}`.
								Enable by specifying a phase (e.g. `process-resources`) in child POM.
							 -->
							<phase>none</phase>
							<goals>
								<goal>run</goal>
							</goals>
							<configuration>
								<target>
									<move todir="${binOutputDirectory}">
										<fileset dir="${binOutputDirectory}">
											<include name="**/*.sh" />
										</fileset>
										<mapper type="glob" from="*.sh" to="*" />
									</move>
								</target>
							</configuration>
						</execution>
					</executions>
				</plugin>

				<plugin>
					<groupId>org.apache.maven.plugins</groupId>
					<artifactId>maven-assembly-plugin</artifactId>
					<version>3.2.0</version>
				</plugin>

				<plugin>
					<groupId>org.apache.maven.plugins</groupId>
					<artifactId>maven-clean-plugin</artifactId>
					<version>3.1.0</version>
				</plugin>

				<plugin>
					<groupId>org.apache.maven.plugins</groupId>
					<artifactId>maven-compiler-plugin</artifactId>
					<version>3.8.0</version>
				</plugin>

				<plugin>
					<groupId>org.apache.maven.plugins</groupId>
					<artifactId>maven-deploy-plugin</artifactId>
					<version>3.0.0-M1</version>
				</plugin>

				<plugin>
					<groupId>org.apache.maven.plugins</groupId>
					<artifactId>maven-dependency-plugin</artifactId>
					<version>3.1.1</version>
				</plugin>

				<plugin>
					<groupId>org.apache.maven.plugins</groupId>
					<artifactId>maven-enforcer-plugin</artifactId>
					<version>3.0.0-M2</version>
				</plugin>

				<plugin>
					<groupId>org.apache.maven.plugins</groupId>
					<artifactId>maven-failsafe-plugin</artifactId>
					<version>2.22.1</version>
				</plugin>

				<plugin>
					<groupId>org.apache.maven.plugins</groupId>
					<artifactId>maven-gpg-plugin</artifactId>
					<version>1.6</version>
				</plugin>

				<plugin>
					<groupId>org.apache.maven.plugins</groupId>
					<artifactId>maven-install-plugin</artifactId>
					<version>3.0.0-M1</version>
				</plugin>

				<plugin>
					<groupId>org.apache.maven.plugins</groupId>
					<artifactId>maven-jar-plugin</artifactId>
					<version>3.1.0</version>
				</plugin>

				<plugin>
					<groupId>org.apache.maven.plugins</groupId>
					<artifactId>maven-javadoc-plugin</artifactId>
					<version>3.0.1</version>
				</plugin>

				<plugin>
					<groupId>org.apache.maven.plugins</groupId>
					<artifactId>maven-release-plugin</artifactId>
					<version>2.5.3</version>
				</plugin>

				<plugin>
					<groupId>org.apache.maven.plugins</groupId>
					<artifactId>maven-resources-plugin</artifactId>
					<version>3.1.0</version>
					<executions>
						<execution>
							<id>copy-bin</id>
							<!--
								Copies scripts from `${binSourceDirectory}` to `${binOutputDirectory}`.
								Uses `~{}` delimiters, because `${}` clashes with script variable replacement.
								Enable by specifying a phase (e.g. `process-resources`) in child POM.
							 -->
							<phase>none</phase>
							<goals>
								<goal>resources</goal>
							</goals>
							<configuration>
								<resources>
									<resource>
										<directory>${binSourceDirectory}</directory>
										<includes>
											<include>**/*.bat</include>
											<include>**/*.sh</include>
										</includes>
										<filtering>true</filtering>
									</resource>
								</resources>
								<useDefaultDelimiters>false</useDefaultDelimiters>
								<delimiters>
									<delimiter>~{*}</delimiter>
								</delimiters>
								<outputDirectory>${binOutputDirectory}</outputDirectory>
							</configuration>
						</execution>
					</executions>
				</plugin>

				<plugin>
					<groupId>org.apache.maven.plugins</groupId>
					<artifactId>maven-site-plugin</artifactId>
					<version>3.8.2</version>
				</plugin>

				<plugin>
					<groupId>org.apache.maven.plugins</groupId>
					<artifactId>maven-shade-plugin</artifactId>
					<version>3.2.1</version>
					<executions>
						<execution>
							<id>generate-exe-jar</id>
							<!--
								Generates a shaded executable JAR in `${buildDirectory}`.
								Enable by specifying a phase (e.g. `package`) in child POM.
							 -->
							<phase>none</phase>
							<goals>
								<goal>shade</goal>
							</goals>
							<configuration>
								<shadedArtifactAttached>true</shadedArtifactAttached>
								<shadedClassifierName>exe</shadedClassifierName>
								<transformers>
									<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
										<mainClass>${exe.main.class}</mainClass>
									</transformer>
									<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" />
								</transformers>
							</configuration>
						</execution>
					</executions>
				</plugin>

				<plugin>
					<groupId>org.apache.maven.plugins</groupId>
					<artifactId>maven-source-plugin</artifactId>
					<version>3.0.1</version>
				</plugin>

				<plugin>
					<groupId>org.apache.maven.plugins</groupId>
					<artifactId>maven-surefire-plugin</artifactId>
					<version>2.22.1</version>
				</plugin>

				<plugin>
					<groupId>org.codehaus.mojo</groupId>
					<artifactId>build-helper-maven-plugin</artifactId>
					<version>3.0.0</version>
				</plugin>

				<plugin>
					<groupId>org.codehaus.mojo</groupId>
					<artifactId>versions-maven-plugin</artifactId>
					<version>2.7</version>
				</plugin>

				<plugin>
					<groupId>org.sonatype.plugins</groupId>
					<artifactId>nexus-staging-maven-plugin</artifactId>
					<version>1.6.8</version>
					<extensions>true</extensions>
					<configuration>
						<serverId>ossrh</serverId>
						<nexusUrl>https://oss.sonatype.org/</nexusUrl>
						<autoReleaseAfterClose>true</autoReleaseAfterClose>
					</configuration>
				</plugin>

				<plugin>
					<groupId>org.apache.maven.plugins</groupId>
					<artifactId>maven-war-plugin</artifactId>
					<version>3.2.2</version>
				</plugin>

				<!-- Eclipse m2e settings; does not influence Maven build. -->
				<plugin>
					<groupId>org.eclipse.m2e</groupId>
					<artifactId>lifecycle-mapping</artifactId>
					<version>1.0.0</version>
					<configuration>
						<lifecycleMappingMetadata>
							<pluginExecutions>
								<!-- Ignore Eclipse's lack of support for the Maven Antrun Plugin. -->
								<pluginExecution>
									<pluginExecutionFilter>
										<groupId>org.apache.maven.plugins</groupId>
										<artifactId>maven-antrun-plugin</artifactId>
										<versionRange>[1.3,)</versionRange>
										<goals>
											<goal>run</goal>
										</goals>
									</pluginExecutionFilter>
									<action>
										<ignore></ignore>
									</action>
								</pluginExecution>
							</pluginExecutions>
						</lifecycleMappingMetadata>
					</configuration>
				</plugin>
			</plugins>
		</pluginManagement>

		<plugins>
			<plugin>
				<groupId>org.codehaus.mojo</groupId>
				<artifactId>build-helper-maven-plugin</artifactId>
				<executions>
					<execution>
						<id>set-project-release-version</id>
						<goals>
							<goal>regex-property</goal>
						</goals>
						<configuration>
							<name>project.releaseVersion</name>
							<value>${project.version}</value>
							<regex>-.*</regex>
							<failIfNoMatch>false</failIfNoMatch>
						</configuration>
					</execution>
					<execution>
						<id>set-build-year</id>
						<goals>
							<goal>timestamp-property</goal>
						</goals>
						<configuration>
							<locale>en</locale>
							<timeZone>UTC</timeZone>
							<name>build.year</name>
							<pattern>yyyy</pattern>
						</configuration>
					</execution>
					<execution>
						<id>set-build-date</id>
						<goals>
							<goal>timestamp-property</goal>
						</goals>
						<configuration>
							<locale>en</locale>
							<timeZone>UTC</timeZone>
							<name>build.date</name>
							<pattern>yyyy-MM-dd</pattern>
						</configuration>
					</execution>
				</executions>
			</plugin>

			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-compiler-plugin</artifactId>
			</plugin>

			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-enforcer-plugin</artifactId>
				<executions>
					<execution>
						<id>enforce-maven</id>
						<goals>
							<goal>enforce</goal>
						</goals>
						<configuration>
							<rules>
								<requireMavenVersion>
									<version>3.0.5</version>
								</requireMavenVersion>
							</rules>
						</configuration>
					</execution>
				</executions>
			</plugin>

			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-failsafe-plugin</artifactId>
				<executions>
					<execution>
						<goals>
							<goal>integration-test</goal>
							<goal>verify</goal>
						</goals>
					</execution>
				</executions>
			</plugin>

			<plugin>
				<groupId>org.codehaus.mojo</groupId>
				<artifactId>versions-maven-plugin</artifactId>
			</plugin>

			<plugin>
				<groupId>org.sonatype.plugins</groupId>
				<artifactId>nexus-staging-maven-plugin</artifactId>
			</plugin>
		</plugins>
	</build>

	<distributionManagement>
		<snapshotRepository>
			<id>ossrh</id>
			<url>https://oss.sonatype.org/content/repositories/snapshots</url>
		</snapshotRepository>
		<repository>
			<id>ossrh</id>
			<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
		</repository>
	</distributionManagement>

	<profiles>
		<profile>
			<id>release</id>
			<build>
				<plugins>
					<plugin>
						<groupId>org.apache.maven.plugins</groupId>
						<artifactId>maven-source-plugin</artifactId>
						<executions>
							<execution>
								<goals>
									<goal>jar-no-fork</goal>
								</goals>
							</execution>
						</executions>
					</plugin>

					<plugin>
						<groupId>org.apache.maven.plugins</groupId>
						<artifactId>maven-javadoc-plugin</artifactId>
						<configuration>
							<quiet>true</quiet>
							<detectOfflineLinks>false</detectOfflineLinks>
							<tags>
								<tag>
									<name>apiNote</name>
									<placement>a</placement>
									<head>API Note:</head>
								</tag>
								<tag>
									<name>implSpec</name>
									<placement>a</placement>
									<head>Implementation Specification:</head>
								</tag>
								<tag>
									<name>implNote</name>
									<placement>a</placement>
									<head>Implementation Note:</head>
								</tag>
								<tag>
									<name>param</name>
								</tag>
								<tag>
									<name>return</name>
								</tag>
								<tag>
									<name>throws</name>
								</tag>
								<tag>
									<name>since</name>
								</tag>
								<tag>
									<name>version</name>
								</tag>
								<tag>
									<name>serialData</name>
								</tag>
								<tag>
									<name>see</name>
								</tag>
							</tags>
						</configuration>
						<executions>
							<execution>
								<goals>
									<goal>jar</goal>
								</goals>
							</execution>
						</executions>
					</plugin>

					<plugin>
						<groupId>org.apache.maven.plugins</groupId>
						<artifactId>maven-gpg-plugin</artifactId>
						<executions>
							<execution>
								<goals>
									<goal>sign</goal>
								</goals>
							</execution>
						</executions>
					</plugin>
				</plugins>
			</build>
		</profile>
	</profiles>
</project>
