<?xml version="1.0" encoding="UTF-8"?>
<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/maven-v4_0_0.xsd">
	<modelVersion>4.0.0</modelVersion>

	<groupId>com.mastercard.test.flow</groupId>
	<artifactId>parent</artifactId>
	<version>0.0.4</version>
	<packaging>pom</packaging>
	<name>flow</name>
	<description>Testing framework</description>
	<url>https://github.com/Mastercard/flow</url>

	<licenses>
		<license>
			<name>Apache License, Version 2.0</name>
			<url>https://opensource.org/licenses/Apache-2.0</url>
		</license>
	</licenses>

	<developers>
		<developer>
			<organization>Mastercard</organization>
			<organizationUrl>https://mastercard.com</organizationUrl>
		</developer>
	</developers>

	<modules>
		<module>api</module>
		<module>message</module>
		<module>builder</module>
		<module>model</module>
		<module>validation</module>
		<module>assert</module>
		<module>report</module>
		<module>aggregator</module>
		<module>example</module>
		<module>doc</module>
	</modules>

	<scm>
		<connection>scm:git:https://github.com/Mastercard/flow.git</connection>
		<developerConnection>scm:git:https://github.com/Mastercard/flow.git</developerConnection>
		<tag>v0.0.4</tag>
		<url>https://github.com/Mastercard/flow</url>
	</scm>

	<distributionManagement>
		<repository>
			<id>ossrh</id>
			<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
		</repository>
	</distributionManagement>

	<properties>
		<maven.compiler.target>1.8</maven.compiler.target>
		<maven.compiler.source>1.8</maven.compiler.source>
		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
		<jline.version>3.21.0</jline.version>
		<sonar.organization>mastercard</sonar.organization>
		<sonar.host.url>https://sonarcloud.io</sonar.host.url>
		<!-- The health of the example project is not terribly interesting, and
		     it seems a little unfair to be dinged for code that sonar can't 
		     exercise due to living in a headless environment, so... -->
		<sonar.exclusions>**/example/**/*.java,
			**/com/mastercard/test/flow/assrt/filter/gui/*.java,
			**/com/mastercard/test/flow/validation/coppice/**/*.java</sonar.exclusions>
	</properties>

	<dependencyManagement>
		<dependencies>

			<dependency>
				<!-- JSON support -->
				<groupId>com.fasterxml.jackson.core</groupId>
				<artifactId>jackson-databind</artifactId>
				<version>2.13.3</version>
			</dependency>

			<dependency>
				<!-- formatter for SQL queries -->
				<groupId>com.github.vertical-blank</groupId>
				<artifactId>sql-formatter</artifactId>
				<version>2.0.3</version>
			</dependency>

			<dependency>
				<!-- testing -->
				<groupId>org.junit.jupiter</groupId>
				<artifactId>junit-jupiter</artifactId>
				<version>5.8.2</version>
			</dependency>

			<dependency>
				<!-- testing for test components -->
				<groupId>org.junit.platform</groupId>
				<artifactId>junit-platform-launcher</artifactId>
				<version>1.9.0</version>
			</dependency>

			<dependency>
				<!-- assert components for junit 4 -->
				<groupId>junit</groupId>
				<artifactId>junit</artifactId>
				<version>4.13.2</version>
			</dependency>

			<dependency>
				<!-- Mocks for testing -->
				<groupId>org.mockito</groupId>
				<artifactId>mockito-core</artifactId>
				<version>4.6.1</version>
			</dependency>

			<dependency>
				<!-- cli input -->
				<groupId>org.jline</groupId>
				<artifactId>jline-reader</artifactId>
				<version>${jline.version}</version>
			</dependency>

			<dependency>
				<!-- ANSI code support for jline -->
				<groupId>org.jline</groupId>
				<artifactId>jline-terminal-jansi</artifactId>
				<version>${jline.version}</version>
			</dependency>

			<dependency>
				<!-- web browser automation -->
				<groupId>org.seleniumhq.selenium</groupId>
				<artifactId>selenium-java</artifactId>
				<version>4.3.0</version>
			</dependency>

			<dependency>
				<!-- We use a headless chrome instance to test the report, this 
			     provides automatic management of the drivers for that -->
				<groupId>io.github.bonigarcia</groupId>
				<artifactId>webdrivermanager</artifactId>
				<version>5.3.0</version>
			</dependency>

			<dependency>
				<!-- text diffs -->
				<groupId>io.github.java-diff-utils</groupId>
				<artifactId>java-diff-utils</artifactId>
				<version>4.12</version>
			</dependency>

			<dependency>
				<!-- REST framework -->
				<groupId>com.sparkjava</groupId>
				<artifactId>spark-core</artifactId>
				<version>2.9.4</version>
			</dependency>

			<dependency>
				<!-- Logging support (version dictated by spark) -->
				<groupId>org.slf4j</groupId>
				<artifactId>slf4j-simple</artifactId>
				<version>1.7.32</version>
			</dependency>

		</dependencies>
	</dependencyManagement>

	<build>
		<pluginManagement>
			<plugins>

				<plugin>
					<!-- junit5 support -->
					<groupId>org.apache.maven.plugins</groupId>
					<artifactId>maven-surefire-plugin</artifactId>
					<version>3.0.0-M7</version>
				</plugin>

				<plugin>
					<!-- `mvn formatter:format` to apply the format -->
					<groupId>net.revelc.code.formatter</groupId>
					<artifactId>formatter-maven-plugin</artifactId>
					<version>2.16.0</version>
					<configuration>
						<!-- This plugin only executes in the child modules, so we need to 
							step one dir up and then back down to the format file. If we end up with 
							deeper-nested projects then they'll need to step commensurately further up -->
						<configFile>${project.basedir}/../src/main/eclipse/mctf_format.xml</configFile>
						<lineEnding>LF</lineEnding>
					</configuration>
					<executions>
						<execution>
							<goals>
								<!-- Fails builds on non-compliant formatting -->
								<goal>validate</goal>
							</goals>
						</execution>
					</executions>
				</plugin>

				<plugin>
					<!-- `mvn sortpom:sort` to format the pom files -->
					<groupId>com.github.ekryd.sortpom</groupId>
					<artifactId>sortpom-maven-plugin</artifactId>
					<version>3.0.1</version>
					<configuration>
						<lineSeparator>\n</lineSeparator>
						<nrOfIndentSpace>-1</nrOfIndentSpace>
						<createBackupFile>false</createBackupFile>
						<expandEmptyElements>false</expandEmptyElements>
						<spaceBeforeCloseEmptyElement>true</spaceBeforeCloseEmptyElement>
					</configuration>
				</plugin>

				<plugin>
					<!-- `mvn -Paggregate clean test org.pitest:pitest-maven:mutationCoverage package`
					     to generate target/pit-reports in each module and then collate them in aggregator -->
					<!-- Alternatively you can create a 'target/mutate' file in a given 
					     project to have mutation testing performed for a single project only on
					     a `mvn test-compile` invocation -->
					<groupId>org.pitest</groupId>
					<artifactId>pitest-maven</artifactId>
					<version>1.9.5</version>
					<configuration>
						<timestampedReports>false</timestampedReports>
						<exportLineCoverage>true</exportLineCoverage>
						<outputFormats>
							<value>HTML</value>
							<value>XML</value>
						</outputFormats>
						<threads>8</threads>
					</configuration>
					<dependencies>
						<dependency>
							<groupId>org.pitest</groupId>
							<artifactId>pitest-junit5-plugin</artifactId>
							<version>1.0.0</version>
						</dependency>
					</dependencies>
				</plugin>

				<plugin>
					<!-- `mvn javadoc:aggregate` to generate target/site/apidocs in the 
						parent -->
					<!-- `mvn javadoc:javadoc` to generate target/site/apidocs in each module -->
					<groupId>org.apache.maven.plugins</groupId>
					<artifactId>maven-javadoc-plugin</artifactId>
					<!-- Downgrade to avoid https://issues.apache.org/jira/browse/MJAVADOC-700 -->
					<version>3.2.0</version>
				</plugin>

				<plugin>
					<!-- Building the report apps without tools installed -->
					<groupId>com.github.eirslett</groupId>
					<artifactId>frontend-maven-plugin</artifactId>
					<version>1.12.1</version>
				</plugin>

				<plugin>
					<!-- building the report apps with installed tools -->
					<groupId>org.codehaus.mojo</groupId>
					<artifactId>exec-maven-plugin</artifactId>
					<version>3.1.0</version>
				</plugin>

				<plugin>
					<groupId>org.apache.maven.plugins</groupId>
					<artifactId>maven-deploy-plugin</artifactId>
					<version>3.0.0</version>
				</plugin>

			</plugins>
		</pluginManagement>

		<plugins>

			<plugin>
				<groupId>net.revelc.code.formatter</groupId>
				<artifactId>formatter-maven-plugin</artifactId>
			</plugin>

			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-source-plugin</artifactId>
				<version>3.2.1</version>
				<executions>
					<execution>
						<id>attach-sources</id>
						<goals>
							<goal>jar</goal>
						</goals>
					</execution>
				</executions>
			</plugin>

			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-javadoc-plugin</artifactId>
				<executions>
					<execution>
						<id>generate-javadoc</id>
						<goals>
							<goal>jar</goal>
						</goals>
						<phase>package</phase>
						<configuration>
							<nodeprecated>true</nodeprecated>
							<additionalOptions>-Xdoclint:none</additionalOptions>
						</configuration>
					</execution>
				</executions>
			</plugin>

			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-release-plugin</artifactId>
				<version>3.0.0-M6</version>
				<configuration>
					<arguments>-Dnode=system -DexcludedGroups=avoid_on_release</arguments>
					<autoVersionSubmodules>true</autoVersionSubmodules>
					<lineSeparator>lf</lineSeparator>
					<tagNameFormat>v@{project.version}</tagNameFormat>
				</configuration>
			</plugin>

		</plugins>
	</build>

	<profiles>

		<profile>
			<!-- Mutation testing can take a while to run, so it's tedious to have 
			     to invoke it on every module when you're iterating on one of them. This profile 
			     runs mutation testing for those projects that have a file called 'mutate' 
			     in their target directory in the test-compile phase -->
			<!-- Hence to mutate a single project, from the parent project do: -->
			<!-- touch <module>/target/mutate -->
			<!-- mvn test-compile -->
			<id>mutate</id>
			<activation>
				<file>
					<exists>target/mutate</exists>
				</file>
			</activation>
			<build>
				<plugins>
					<plugin>
						<groupId>org.pitest</groupId>
						<artifactId>pitest-maven</artifactId>
						<executions>
							<execution>
								<goals>
									<goal>mutationCoverage</goal>
								</goals>
								<phase>test-compile</phase>
							</execution>
						</executions>
					</plugin>
				</plugins>
			</build>
		</profile>

		<profile>
			<!-- By default mutation testing will be started from fresh on every invocation, but
			     when you're working on a single class this can slow down your iteration cycle.
			     Activating this profile with `-Piterate` will cause pitest to take account of
			     historic results and only exercise the changes since last time. This is much
			     faster, but can sometimes give erroneous results -->
			<id>iterate</id>
			<build>
				<plugins>
					<plugin>
						<groupId>org.pitest</groupId>
						<artifactId>pitest-maven</artifactId>
						<configuration>
							<historyInputFile>target/pit_hist</historyInputFile>
							<historyOutputFile>target/pit_hist</historyOutputFile>
						</configuration>
					</plugin>
				</plugins>
			</build>
		</profile>

		<profile>
			<!-- Sets some convenient plugin configuration when we're doing a full mutation testing run -->
			<id>aggregate</id>
			<build>
				<plugins>
					<plugin>
						<groupId>org.apache.maven.plugins</groupId>
						<artifactId>maven-surefire-plugin</artifactId>
						<configuration>
							<!-- Skip the filter gui tests - they won't run in headless env and they're
							     annoying to sit through due to the mouse-stealing behaviour -->
							<excludedGroups>gui</excludedGroups>
							<systemPropertyVariables>
								<!-- Skips the selenium tests - they don't contribute to java coverage
								     and they're a bit slow  -->
								<browser.skip>true</browser.skip>
							</systemPropertyVariables>
						</configuration>
					</plugin>
				</plugins>
			</build>
		</profile>

		<profile>
			<!-- Sonar doesn't understand pitest output, so we fall back to jacoco to get test coverage metrics into sonar -->
			<id>coverage</id>
			<build>
				<plugins>
					<plugin>
						<groupId>org.jacoco</groupId>
						<artifactId>jacoco-maven-plugin</artifactId>
						<version>0.8.8</version>
						<executions>
							<execution>
								<id>prepare-agent</id>
								<goals>
									<goal>prepare-agent</goal>
								</goals>
							</execution>
							<execution>
								<id>report</id>
								<goals>
									<goal>report</goal>
								</goals>
								<configuration>
									<formats>
										<format>XML</format>
										<format>HTML</format>
									</formats>
								</configuration>
							</execution>
						</executions>
					</plugin>
					<plugin>
						<groupId>org.apache.maven.plugins</groupId>
						<artifactId>maven-surefire-plugin</artifactId>
						<configuration>
							<!-- Skip the filter gui tests - they won't run in headless env and they're
							     annoying to sit through due to the mouse-stealing behaviour -->
							<excludedGroups>gui</excludedGroups>
							<systemPropertyVariables>
								<!-- Skips the selenium tests - they don't contribute to java coverage
								     and they're a bit slow  -->
								<browser.skip>true</browser.skip>
							</systemPropertyVariables>
						</configuration>
					</plugin>
				</plugins>
			</build>
		</profile>

		<profile>
			<!-- Runs the example application integration test. -->
			<!-- Invoke with `mkdir -p target; mvn -Peait test` -->
			<id>eait</id>
			<build>
				<plugins>
					<plugin>
						<groupId>org.apache.maven.plugins</groupId>
						<artifactId>maven-surefire-plugin</artifactId>
						<configuration>
							<!-- We only want the example app integration test -->
							<test>com.mastercard.test.flow.example.app.itest.IntegrationTest</test>
							<!-- don't fail projects that don't contain the integration test -->
							<failIfNoSpecifiedTests>false</failIfNoSpecifiedTests>
							<!-- Runs the tests in maven's JVM, so we can interact with the CLI 
							     from the terminal -->
							<forkCount>0</forkCount>
							<systemPropertyVariables>
								<!-- Triggers the filter CLI -->
								<mctf.filter.update>true</mctf.filter.update>
								<!-- Default to the same filters as last time -->
								<mctf.filter.repeat>true</mctf.filter.repeat>
								<!-- Causes the report to be presented in a browser -->
								<mctf.itest.report.serve>true</mctf.itest.report.serve>
							</systemPropertyVariables>
						</configuration>
					</plugin>
				</plugins>
			</build>
		</profile>

		<profile>
			<!-- Signs artifacts for release -->
			<id>release</id>
			<build>
				<plugins>
					<plugin>
						<groupId>org.apache.maven.plugins</groupId>
						<artifactId>maven-gpg-plugin</artifactId>
						<version>3.0.1</version>
						<executions>
							<execution>
								<id>sign-artifacts</id>
								<goals>
									<goal>sign</goal>
								</goals>
								<phase>verify</phase>
							</execution>
						</executions>
					</plugin>
				</plugins>
			</build>
		</profile>
	</profiles>

</project>
