<?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/xsd/maven-4.0.0.xsd">

	<modelVersion>4.0.0</modelVersion>

	<parent>
		<groupId>com.github.bordertech.common</groupId>
		<artifactId>bordertech-parent</artifactId>
		<version>1.0.6</version>
	</parent>

	<artifactId>qa-parent</artifactId>
	<packaging>pom</packaging>

	<properties>
		<bt.qa.skip>true</bt.qa.skip><!-- Basically a backwards compatible alias for wc.qa.skip -->
		<wc.qa.skip>${bt.qa.skip}</wc.qa.skip>
		<checkstyle.skip>${wc.qa.skip}</checkstyle.skip>
		<findbugs.skip>${wc.qa.skip}</findbugs.skip>
		<pmd.skip>${wc.qa.skip}</pmd.skip>
		<badges.skip>${wc.qa.skip}</badges.skip>
		<javadoc.excluded.packages />
		<checkstyle.excludes />

		<!--
			OWASP dependency vulnerability scanner.
		-->
		<bt.owasp.dependency-check.version>3.3.2</bt.owasp.dependency-check.version>
		<bt.owasp.dependency-check.enable>false</bt.owasp.dependency-check.enable>
		<!-- properties to allow for mirroring of CVE definitions -->
		<bt.owasp.dependency-check.cve.mirror>https://nvd.nist.gov/feeds/xml/cve</bt.owasp.dependency-check.cve.mirror>
		<bt.owasp.dependency-check.cve.12.path>1.2</bt.owasp.dependency-check.cve.12.path>
		<bt.owasp.dependency-check.cve.20.path>2.0</bt.owasp.dependency-check.cve.20.path>
		<!-- Non java analysers are off by default because, well this is a Maven builder! -->
		<!-- nodejs nsp requires nsp on the path at scan time -->
		<bt.owasp.dependency-check.enableNsp>false</bt.owasp.dependency-check.enableNsp>
		<!-- RetireJs analyser has a known bug https://github.com/jeremylong/DependencyCheck/issues/1467 -->
		<bt.owasp.dependency-check.enableRetireJs>false</bt.owasp.dependency-check.enableRetireJs>
		<!-- nuspec analyser -->
		<bt.owasp.dependency-check.enableNuspec>false</bt.owasp.dependency-check.enableNuspec>
		<!-- swift analyser -->
		<bt.owasp.dependency-check.enableSwift>false</bt.owasp.dependency-check.enableSwift>
		<!-- assembly .net analyser -->
		<bt.owasp.dependency-check.enableAssembly.Net>false</bt.owasp.dependency-check.enableAssembly.Net>
	</properties>

	<description>
		Quality assurance configuration for BorderTech java projects.
		Note that projects inheriting from this POM also inherit the release
		configuration from bordertech-parent.
	</description>


	<build>
		<pluginManagement>
			<plugins>
				<plugin>
					<groupId>org.owasp</groupId>
					<artifactId>dependency-check-maven</artifactId>
					<version>${bt.owasp.dependency-check.version}</version>
					<configuration>
						<failBuildOnAnyVulnerability>true</failBuildOnAnyVulnerability>
						<cveUrl12Modified>${bt.owasp.dependency-check.cve.mirror}/${bt.owasp.dependency-check.cve.12.path}/nvdcve-Modified.xml.gz</cveUrl12Modified>
						<cveUrl20Modified>${bt.owasp.dependency-check.cve.mirror}/${bt.owasp.dependency-check.cve.20.path}/nvdcve-2.0-Modified.xml.gz</cveUrl20Modified>
						<cveUrl12Base>${bt.owasp.dependency-check.cve.mirror}/${bt.owasp.dependency-check.cve.12.path}/nvdcve-%d.xml.gz</cveUrl12Base>
						<cveUrl20Base>${bt.owasp.dependency-check.cve.mirror}/${bt.owasp.dependency-check.cve.20.path}/nvdcve-2.0-%d.xml.gz</cveUrl20Base>
						<retireJsAnalyzerEnabled>${bt.owasp.dependency-check.enableRetireJs}</retireJsAnalyzerEnabled><!-- see https://github.com/jeremylong/DependencyCheck/issues/1467 before turning this on -->
						<nspAnalyzerEnabled>${bt.owasp.dependency-check.enableNsp}</nspAnalyzerEnabled>
						<nuspecAnalyzerEnabled>${bt.owasp.dependency-check.enableNuspec}</nuspecAnalyzerEnabled>
						<swiftPackageManagerAnalyzerEnabled>${bt.owasp.dependency-check.enableSwift}</swiftPackageManagerAnalyzerEnabled>
						<assemblyAnalyzerEnabled>${bt.owasp.dependency-check.enableAssembly.Net}</assemblyAnalyzerEnabled>
					</configuration>
				</plugin>
			</plugins>
		</pluginManagement>
		<plugins>
			<!-- Check the code style. -->
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-checkstyle-plugin</artifactId>
				<version>3.0.0</version>
				<configuration>
					<configLocation>bordertech/checkstyle.xml</configLocation>
					<consoleOutput>true</consoleOutput>
					<failsOnError>true</failsOnError>
					<failOnViolation>true</failOnViolation>
					<linkXRef>false</linkXRef>
					<includeTestSourceDirectory>false</includeTestSourceDirectory>
				</configuration>
				<dependencies>
					<dependency>
						<groupId>com.github.bordertech.common</groupId>
						<artifactId>build-tools</artifactId>
						<version>1.0.6</version>
					</dependency>
				</dependencies>
				<executions>
					<execution>
						<id>checkStyle</id>
						<phase>verify</phase>
						<goals>
							<goal>check</goal>
						</goals>
					</execution>
				</executions>
			</plugin>

			<!-- PMD Check. -->
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-pmd-plugin</artifactId>
				<version>3.5</version>
				<configuration>
					<failurePriority>2</failurePriority>
					<printFailingErrors>true</printFailingErrors>
					<includeTests>false</includeTests>
					<format>xml</format>
				</configuration>
				<executions>
					<execution>
						<id>checkPmd</id>
						<phase>verify</phase>
						<goals>
							<goal>check</goal>
						</goals>
					</execution>
				</executions>
			</plugin>

			<!-- Findbugs check. -->
			<plugin>
				<groupId>org.codehaus.mojo</groupId>
				<artifactId>findbugs-maven-plugin</artifactId>
				<version>3.0.3</version>
				<configuration>
					<failOnError>true</failOnError>
					<effort>Max</effort>
					<includeTests>false</includeTests>
					<threshold>Medium</threshold>
					<excludeFilterFile>bordertech/findbugs-exclude-filter.xml</excludeFilterFile>
				</configuration>
				<dependencies>
					<dependency>
						<groupId>com.github.bordertech.common</groupId>
						<artifactId>build-tools</artifactId>
						<version>1.0.6</version>
					</dependency>
				</dependencies>
				<executions>
					<execution>
						<id>checkFindbugs</id>
						<phase>verify</phase>
						<goals>
							<goal>check</goal>
						</goals>
					</execution>
				</executions>
			</plugin>

			<!-- Code coverage. -->
			<!-- Run twice for the report. -->
			<plugin>
				<groupId>org.jacoco</groupId>
				<artifactId>jacoco-maven-plugin</artifactId>
				<version>0.8.2</version>
				<executions>
					<!-- Prepare jacco agent. -->
					<execution>
						<id>jacoco-agent</id>
						<goals>
							<goal>prepare-agent</goal>
						</goals>
						<configuration>
							<propertyName>surefireArgLine</propertyName>
						</configuration>
					</execution>
				</executions>
			</plugin>

			<!-- Generate badges. -->
			<plugin>
				<groupId>com.github.bordertech.buildtools</groupId>
				<artifactId>badger</artifactId>
				<version>1.0.0</version>
				<executions>
					<execution>
						<phase>post-site</phase>
						<goals>
							<goal>badges</goal>
						</goals>
						<configuration>
							<skip>${badges.skip}</skip>
							<outputDir>target/site/badges</outputDir>
							<inputFiles>
								<inputFile>target/pmd.xml</inputFile>
								<inputFile>target/findbugs-report.xml</inputFile>
								<inputFile>target/findbugsXml.xml</inputFile>
								<inputFile>target/checkstyle-result.xml</inputFile>
								<inputFile>target/coverage-report.xml</inputFile>
							</inputFiles>
						</configuration>
					</execution>
				</executions>
			</plugin>

			<plugin>
				<groupId>org.owasp</groupId>
				<artifactId>dependency-check-maven</artifactId>
				<configuration>
					<skip>${bt.owasp.dependency-check.enable}</skip>
				</configuration>
				<executions>
					<execution>
						<id>checkDependencies</id>
						<phase>verify</phase>
						<goals>
							<goal>check</goal>
						</goals>
					</execution>
				</executions>
			</plugin>

		</plugins>
	</build>

	<reporting>
		<plugins>

			<!-- Generate Reports Information about the project. -->
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-project-info-reports-plugin</artifactId>
				<version>3.0.0</version>
				<reportSets>
					<reportSet>
						<reports>
							<report>index</report>
							<report>license</report>
							<report>mailing-list</report>
							<report>summary</report>
						</reports>
					</reportSet>
				</reportSets>
			</plugin>

			<!-- Self Aggregating. Plugin automatically aggregates sub modules. -->
			<!-- Produce a cross-reference of the project's source. (Self Aggregating). -->
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-jxr-plugin</artifactId>
				<version>2.5</version>
				<reportSets>
					<reportSet>
						<inherited>false</inherited>
						<reports>
							<report>aggregate</report>
							<!--
							<report>test-aggregate</report>
							-->
						</reports>
					</reportSet>
				</reportSets>
			</plugin>

			<!-- Generate Javadoc. (Self Aggregating)-->
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-javadoc-plugin</artifactId>
				<version>3.0.1</version>
				<configuration>
					<charset>UTF-8</charset>
					<encoding>UTF-8</encoding>
					<docencoding>UTF-8</docencoding>
					<breakiterator>true</breakiterator>
					<version>true</version>
					<keywords>true</keywords>
					<excludePackageNames>${javadoc.excluded.packages}</excludePackageNames>
				</configuration>
				<reportSets>
					<reportSet>
						<inherited>false</inherited>
						<reports>
							<report>aggregate</report>
							<!--
							<report>test-aggregate</report>
							-->
						</reports>
					</reportSet>
				</reportSets>
			</plugin>

			<!-- Generate the web interface version of the test results (Aggregate Parameter). -->
			<!-- Run site twice to get correct results. -->
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-surefire-report-plugin</artifactId>
				<version>${surefire.version}</version>
				<configuration>
					<aggregate>true</aggregate>
				</configuration>
				<reportSets>
					<reportSet>
						<inherited>false</inherited>
						<reports>
							<report>report</report>
						</reports>
					</reportSet>
				</reportSets>
			</plugin>

			<!-- QA Reports. -->
			<!-- Generate the Checkstyle report. (Self Aggregating) -->
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-checkstyle-plugin</artifactId>
				<version>3.0.0</version>
				<configuration>
					<skip>false</skip>
					<configLocation>bordertech/checkstyle.xml</configLocation>
					<consoleOutput>true</consoleOutput>
					<excludes>${checkstyle.excludes}</excludes>
					<headerFile />
				</configuration>
				<reportSets>
					<reportSet>
						<inherited>false</inherited>
						<reports>
							<report>checkstyle-aggregate</report>
						</reports>
					</reportSet>
				</reportSets>
			</plugin>

			<!-- PMD and CPD Reports (Aggregate Parameter). -->
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-pmd-plugin</artifactId>
				<version>3.10.0</version>
				<configuration>
					<skip>false</skip>
					<aggregate>true</aggregate>
					<failurePriority>5</failurePriority>
				</configuration>
				<reportSets>
					<reportSet>
						<inherited>false</inherited>
						<reports>
							<report>pmd</report>
							<report>cpd</report>
						</reports>
					</reportSet>
				</reportSets>
			</plugin>

			<!-- Generate Findbugs reports. (Does not support aggregate.) -->
			<!-- Run site twice to get Findbugs report.-->
			<plugin>
				<groupId>org.codehaus.mojo</groupId>
				<artifactId>findbugs-maven-plugin</artifactId>
				<version>3.0.5</version>
				<configuration>
					<skip>false</skip>
					<effort>Max</effort>
					<includeTests>false</includeTests>
					<excludeFilterFile>bordertech/findbugs-exclude-filter.xml</excludeFilterFile>
					<threshold>Low</threshold>
					<failOnError>false</failOnError>
					<findbugsXmlOutputDirectory>${project.build.directory}/findbugs-rep</findbugsXmlOutputDirectory>
				</configuration>
			</plugin>

			<!-- Generate the dependency vulnerability check report -->
			<plugin>
				<groupId>org.owasp</groupId>
				<artifactId>dependency-check-maven</artifactId>
				<version>${bt.owasp.dependency-check.version}</version>
				<reportSets>
					<reportSet>
						<reports>
							<report>aggregate</report>
						</reports>
						<configuration>
							<skip>false</skip>
							<failOnError>false</failOnError>
							<cveUrl12Modified>${bt.owasp.dependency-check.cve.mirror}/${bt.owasp.dependency-check.cve.12.path}/nvdcve-Modified.xml.gz</cveUrl12Modified>
							<cveUrl20Modified>${bt.owasp.dependency-check.cve.mirror}/${bt.owasp.dependency-check.cve.20.path}/nvdcve-2.0-Modified.xml.gz</cveUrl20Modified>
							<cveUrl12Base>${bt.owasp.dependency-check.cve.mirror}/${bt.owasp.dependency-check.cve.12.path}/nvdcve-%d.xml.gz</cveUrl12Base>
							<cveUrl20Base>${bt.owasp.dependency-check.cve.mirror}/${bt.owasp.dependency-check.cve.20.path}/nvdcve-2.0-%d.xml.gz</cveUrl20Base>
							<retireJsAnalyzerEnabled>${bt.owasp.dependency-check.enableRetireJs}</retireJsAnalyzerEnabled><!-- see https://github.com/jeremylong/DependencyCheck/issues/1467 before turning this on -->
							<nspAnalyzerEnabled>${bt.owasp.dependency-check.enableNsp}</nspAnalyzerEnabled>
							<nuspecAnalyzerEnabled>${bt.owasp.dependency-check.enableNuspec}</nuspecAnalyzerEnabled>
							<swiftPackageManagerAnalyzerEnabled>${bt.owasp.dependency-check.enableSwift}</swiftPackageManagerAnalyzerEnabled>
							<assemblyAnalyzerEnabled>${bt.owasp.dependency-check.enableAssembly.Net}</assemblyAnalyzerEnabled>
						</configuration>
					</reportSet>
				</reportSets>
			</plugin>

		</plugins>
	</reporting>

</project>
