<?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>

    <groupId>au.gov.qld.services.selenium</groupId>
    <artifactId>selenium-helper</artifactId>
    <version>4.36.0.002</version>
    <url>https://github.com/qld-gov-au/selenium-helper</url>
    <name>Selenium Helper for Qld Government</name>
    <description>Selenium Helper for Qld Government - Test helper for integration testing</description>

    <scm>
        <url>https://github.com/qld-gov-au/selenium-helper</url>
        <connection>scm:git:https://github.com/qld-gov-au/selenium-helper.git</connection>
        <developerConnection>scm:git:https://github.com/qld-gov-au/selenium-helper.git</developerConnection>
        <tag>4.36.0.002</tag>
    </scm>

    <developers>
        <developer>
            <id>duttonw</id>
            <name>William Dutton</name>
            <email>william.dutton@smartservice.qld.gov.au</email>
        </developer>
    </developers>
    <licenses>
        <license>
            <name>GNU Lesser General Public License, version 2.1</name>
            <url>https://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt</url>
            <distribution>repo</distribution>
        </license>
    </licenses>

    <properties>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>17</java.version>
        <resource.delimiter>@</resource.delimiter>
        <maven.compiler.release>${java.version}</maven.compiler.release>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <selenium.version>4.36.0</selenium.version>

        <maven-compiler-plugin.version>3.13.0</maven-compiler-plugin.version>
        <maven-surefire-plugin.version>3.3.1</maven-surefire-plugin.version>
        <maven-failsafe-plugin.version>3.3.1</maven-failsafe-plugin.version>
        <git-commit-id-plugin.version>4.9.10</git-commit-id-plugin.version>
        <maven-pmd-plugin.version>3.24.0</maven-pmd-plugin.version>
        <owasp.dependency-check-maven.version>12.1.3</owasp.dependency-check-maven.version>

        <qa.directory>${project.basedir}/src/qa</qa.directory>
        <maven-checkstyle-plugin.version>3.4.0</maven-checkstyle-plugin.version>
        <checkstyle.version>10.17.0</checkstyle.version>
        <pmd.version>7.4.0</pmd.version>
        <spotbugs-maven-plugin.version>4.8.6.2</spotbugs-maven-plugin.version>
        <spotbugs.version>4.8.5</spotbugs.version>
        <findsecbugs-plugin.version>1.13.0</findsecbugs-plugin.version>
        <sb-contrib.version>7.6.4</sb-contrib.version>
        <jacoco.version>0.8.13</jacoco.version>

        <failsafe.skip>false</failsafe.skip>
        <surefire.skip>false</surefire.skip>
        <dependency.skip>false</dependency.skip>
    </properties>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <scope>import</scope>
                <type>pom</type>
                <groupId>org.assertj</groupId><artifactId>assertj-bom</artifactId><version>3.26.3</version>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <dependencies>
        <dependency><groupId>io.github.bonigarcia</groupId><artifactId>webdrivermanager</artifactId><version>6.3.2</version>
            <exclusions>
                <exclusion><groupId>org.slf4j</groupId><artifactId>slf4j-api</artifactId></exclusion>
                <exclusion><groupId>com.google.guava</groupId><artifactId>guava</artifactId></exclusion>
                <exclusion><groupId>com.google.errorprone</groupId><artifactId>error_prone_annotations</artifactId></exclusion>
                <exclusion><groupId>com.github.docker-java</groupId><artifactId>docker-java</artifactId></exclusion>
                <exclusion><groupId>com.github.docker-java</groupId><artifactId>docker-java-transport-httpclient5</artifactId></exclusion>
                <exclusion><groupId>commons-io</groupId><artifactId>commons-io</artifactId></exclusion>
                <exclusion><groupId>commons-codec</groupId><artifactId>commons-codec</artifactId></exclusion>
                <exclusion><groupId>org.apache.commons</groupId><artifactId>commons-compress</artifactId></exclusion>
                <exclusion><groupId>org.apache.commons</groupId><artifactId>commons-lang3</artifactId></exclusion>
            </exclusions>
        </dependency>
        <dependency><groupId>org.apache.commons</groupId><artifactId>commons-compress</artifactId><version>1.28.0</version>
            <exclusions>
                <exclusion><groupId>org.apache.commons</groupId><artifactId>commons-lang3</artifactId></exclusion>
            </exclusions>
        </dependency>
        <dependency><groupId>org.apache.commons</groupId><artifactId>commons-lang3</artifactId><version>3.19.0</version></dependency>



        <dependency><groupId>org.seleniumhq.selenium</groupId><artifactId>selenium-java</artifactId><version>${selenium.version}</version>
            <exclusions>
                <exclusion><groupId>commons-codec</groupId><artifactId>commons-codec</artifactId></exclusion>
                <exclusion><groupId>org.apache.commons</groupId><artifactId>commons-compress</artifactId></exclusion>
                <exclusion><groupId>org.apache.commons</groupId><artifactId>commons-lang3</artifactId></exclusion>
            </exclusions>
        </dependency>
        <dependency><groupId>org.seleniumhq.selenium</groupId><artifactId>htmlunit3-driver</artifactId><version>${selenium.version}</version>
            <exclusions>
                <exclusion><groupId>commons-codec</groupId><artifactId>commons-codec</artifactId></exclusion>
                <exclusion><groupId>org.apache.commons</groupId><artifactId>commons-compress</artifactId></exclusion>
                <exclusion><groupId>org.apache.commons</groupId><artifactId>commons-lang3</artifactId></exclusion>
            </exclusions>
        </dependency>

        <dependency><groupId>org.slf4j</groupId><artifactId>slf4j-api</artifactId><version>2.0.13</version></dependency>

        <dependency><scope>test</scope><groupId>ch.qos.logback</groupId><artifactId>logback-classic</artifactId><version>1.5.19</version></dependency>
        <dependency><scope>test</scope><groupId>org.junit.jupiter</groupId><artifactId>junit-jupiter-api</artifactId><version>5.10.3</version></dependency>
        <dependency><scope>test</scope><groupId>org.assertj</groupId><artifactId>assertj-core</artifactId></dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <artifactId>maven-enforcer-plugin</artifactId><version>3.6.2</version>
                <executions>
                    <execution>
                        <id>enforce</id>
                        <configuration>
                            <rules>
                                <dependencyConvergence />
                                <banDuplicatePomDependencyVersions />
                            </rules>
                        </configuration>
                        <goals>
                            <goal>enforce</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId><version>${maven-compiler-plugin.version}</version>
                <configuration>
                    <release>${java.version}</release>
                </configuration>
            </plugin>

            <plugin><groupId>org.jacoco</groupId><artifactId>jacoco-maven-plugin</artifactId><version>${jacoco.version}</version></plugin>

            <plugin>
                <artifactId>maven-eclipse-plugin</artifactId><version>2.10</version>
                <configuration>
                    <downloadSources>true</downloadSources>
                    <downloadJavadocs>false</downloadJavadocs>
                    <wtpversion>2.0</wtpversion>
                </configuration>
            </plugin>

            <plugin>
                <groupId>pl.project13.maven</groupId><artifactId>git-commit-id-plugin</artifactId><version>${git-commit-id-plugin.version}</version>
                <configuration>
                    <dotGitDirectory>${project.basedir}/.git</dotGitDirectory>
                    <!-- this is false by default, forces the plugin to generate the git.properties file -->
                    <generateGitPropertiesFile>true</generateGitPropertiesFile>
                    <!-- The path for the properties file to be generated. See Super Pom for default variable reference https://maven.apache.org/guides/introduction/introduction-to-the-pom.html -->
                    <generateGitPropertiesFilename>${project.build.outputDirectory}/git.properties
                    </generateGitPropertiesFilename>
                </configuration>
            </plugin>

            <!--Set up to ignore integration tests-->
            <!-- mvn clean test -->
            <plugin>
                <artifactId>maven-surefire-plugin</artifactId><version>${maven-surefire-plugin.version}</version>
                <configuration>
                    <skipTests>${surefire.skip}</skipTests>
                    <systemPropertyVariables>
                        <!--<headless.disabled>false</headless.disabled>-->
                    </systemPropertyVariables>
                </configuration>
            </plugin>

            <!-- integration tests which are not cumcumber mvn verify or mvn integration-test run's theses
             turn off with -Dskip.failsafe.tests=false -->
            <plugin>
                <artifactId>maven-failsafe-plugin</artifactId><version>${maven-failsafe-plugin.version}</version>
                <dependencies>
                    <dependency><groupId>org.apache.maven.surefire</groupId><artifactId>surefire-junit47</artifactId><version>${maven-failsafe-plugin.version}</version></dependency>
                </dependencies>
                <executions>
                    <execution>
                        <id>default</id>
                        <goals>
                            <goal>integration-test</goal>
                            <goal>verify</goal>
                        </goals>
                        <configuration>
                            <skipITs>${failsafe.skip}</skipITs>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin><artifactId>maven-checkstyle-plugin</artifactId><version>${maven-checkstyle-plugin.version}</version></plugin>

            <plugin><artifactId>maven-pmd-plugin</artifactId><version>${maven-pmd-plugin.version}</version></plugin>

            <plugin><groupId>com.github.spotbugs</groupId><artifactId>spotbugs-maven-plugin</artifactId></plugin>

        </plugins>

        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId><artifactId>maven-compiler-plugin</artifactId><version>${maven-compiler-plugin.version}</version>
                    <configuration>
                        <release>${java.version}</release>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.jacoco</groupId><artifactId>jacoco-maven-plugin</artifactId><version>${jacoco.version}</version>
                    <executions>
                        <!--
                            Prepares the property pointing to the JaCoCo runtime agent which
                            is passed as VM argument when Maven the Surefire plugin is executed.
                        -->
                        <execution>
                            <id>default-prepare-agent</id>
                            <phase>initialize</phase>
                            <goals>
                                <goal>prepare-agent</goal>
                            </goals>
                        </execution>
                        <execution>
                            <id>default-report</id>
                            <goals>
                                <goal>report</goal>
                            </goals>
                            <configuration>
                                <title>Jacoco Unit Tests ${project.name}</title>
                            </configuration>
                        </execution>
                        <execution>
                            <id>pre-integration-test</id>
                            <!--						<phase>pre-integration-test</phase>-->
                            <goals>
                                <goal>prepare-agent-integration</goal>
                            </goals>
                        </execution>
                        <execution>
                            <id>default-report-integration</id>
                            <goals>
                                <goal>report-integration</goal>
                            </goals>
                            <configuration>
                                <title>Jacoco Integration ${project.name}</title>
                            </configuration>
                        </execution>

                        <execution>
                            <id>default-merge</id>
                            <phase>verify</phase>
                            <goals>
                                <goal>merge</goal>
                            </goals>
                            <configuration>
                                <fileSets>
                                    <fileSet>
                                        <directory>${project.build.directory}</directory>
                                        <include>jacoco.exec</include>
                                        <include>jacoco-it.exec</include>
                                    </fileSet>
                                </fileSets>
                                <destFile>${project.build.directory}/jacoco-merge.exec</destFile>
                            </configuration>
                        </execution>
                        <execution>
                            <id>default-report-merge</id>
                            <goals>
                                <goal>report-integration</goal>
                            </goals>
                            <configuration>
                                <dataFile>${project.build.directory}/jacoco-merge.exec</dataFile>
                                <outputDirectory>${project.reporting.outputDirectory}/jacoco-merge</outputDirectory>
                                <title>Jacoco Merge ${project.name}</title>
                            </configuration>
                        </execution>

                        <execution>
                            <id>default-check</id>
                            <goals>
                                <goal>check</goal>
                            </goals>
                            <configuration>
                                <dataFile>${project.build.directory}/jacoco-merge.exec</dataFile>
                                <excludes>
                                    <!--<exclude>au/gov/qld/something/**/*.class</exclude>-->
                                </excludes>
                                <rules>
                                    <rule implementation="org.jacoco.maven.RuleConfiguration">
                                        <element>CLASS</element>
                                        <limits>
                                            <limit implementation="org.jacoco.report.check.Limit">
                                                <counter>BRANCH</counter>
                                                <value>COVEREDRATIO</value>
                                                <minimum>0.0</minimum><!-- FIXME! -->
                                            </limit>
                                            <limit implementation="org.jacoco.report.check.Limit">
                                                <counter>INSTRUCTION</counter>
                                                <value>COVEREDRATIO</value>
                                                <minimum>0.0</minimum><!-- FIXME! -->
                                            </limit>
                                        </limits>
                                    </rule>
                                    <rule implementation="org.jacoco.maven.RuleConfiguration">
                                        <element>BUNDLE</element>
                                        <limits>
                                            <limit implementation="org.jacoco.report.check.Limit">
                                                <counter>INSTRUCTION</counter>
                                                <value>COVEREDRATIO</value>
                                                <minimum>0.0</minimum><!-- FIXME! -->
                                            </limit>
                                        </limits>
                                    </rule>
                                </rules>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>

                <plugin>
                    <artifactId>maven-checkstyle-plugin</artifactId><version>${checkstyle.version}</version>
                    <dependencies>
                        <dependency>
                            <groupId>com.puppycrawl.tools</groupId>
                            <artifactId>checkstyle</artifactId>
                            <version>10.17.0</version>
                        </dependency>
                    </dependencies>
                    <configuration>
                        <includeTestSourceDirectory>true</includeTestSourceDirectory>
                        <configLocation>${qa.directory}/checkstyle_rules.xml</configLocation>
                        <propertyExpansion>qa.directory=${qa.directory}</propertyExpansion>
                        <excludes>
                            node_modules,src/main/webapp/WEB-INF/eligibility-checklist/node_modules,src/main/webapp/WEB-INF/eligibility-checklist/dist.tar.gz
                        </excludes>
                    </configuration>
                    <executions>
                        <execution>
                            <phase>test-compile</phase> <!-- too late at prepare-package -->
                            <goals>
                                <!--<goal>checkstyle</goal> --><!-- can be checkstyle to not fail the build-->
                                <goal>check</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>

                <plugin>
                    <artifactId>maven-pmd-plugin</artifactId><version>${maven-pmd-plugin.version}</version>
                    <dependencies>
                        <dependency><groupId>net.sourceforge.pmd</groupId><artifactId>pmd-core</artifactId><version>${pmd.version}</version></dependency>
                        <dependency><groupId>net.sourceforge.pmd</groupId><artifactId>pmd-java</artifactId><version>${pmd.version}</version></dependency>
                    </dependencies>
                    <configuration>
                        <includeTests>false</includeTests>
                        <rulesets>
                            <!--<ruleset>/rulesets/java/basic.xml</ruleset>-->
                            <ruleset>${qa.directory}/pmd-rules.xml</ruleset>
                        </rulesets>
                        <excludeRoots>
                            <excludeRoot>${project.basedir}/target/generated-sources</excludeRoot>
                        </excludeRoots>
                        <printFailingErrors>true</printFailingErrors>
                    </configuration>
                    <executions>
                        <execution>
                            <phase>validate</phase> <!-- too late at prepare-package -->
                            <goals>
                                <goal>check</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>

                <plugin>
                    <groupId>com.github.spotbugs</groupId><artifactId>spotbugs-maven-plugin</artifactId><version>${spotbugs-maven-plugin.version}</version>
                    <configuration>
                        <excludeFilterFile>${qa.directory}/findbugs-exclude.xml</excludeFilterFile>
                        <effort>Max</effort>
                        <threshold>High</threshold>
                        <includeTests>true</includeTests>
                        <plugins>
                            <plugin><groupId>com.h3xstream.findsecbugs</groupId><artifactId>findsecbugs-plugin</artifactId><version>${findsecbugs-plugin.version}</version></plugin>
                            <plugin><groupId>com.mebigfatguy.sb-contrib</groupId><artifactId>sb-contrib</artifactId><version>${sb-contrib.version}</version></plugin>
                        </plugins>
                    </configuration>
                    <executions>
                        <execution>
                            <phase>test-compile</phase> <!-- too late at prepare-package -->
                            <goals>
                                <!--<goal>findbugs</goal>--> <!--can be findbugs to not fail the build-->
                                <goal>check</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>

    <profiles>
        <profile>
            <id>github</id>
            <repositories>
                <repository>
                    <id>central</id>
                    <url>https://repo1.maven.org/maven2</url>
                </repository>
                <repository>
                    <id>github</id>
                    <url>https://maven.pkg.github.com/qld-gov-au/seleniumHelper</url>
                    <snapshots>
                        <enabled>true</enabled>
                    </snapshots>
                </repository>
            </repositories>
        </profile>
        <profile>
            <id>release</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.sonatype.central</groupId>
                        <artifactId>central-publishing-maven-plugin</artifactId>
                        <version>0.9.0</version>
                        <extensions>true</extensions>
                        <configuration>
                            <publishingServerId>central</publishingServerId>
                            <tokenAuth>true</tokenAuth>
                            <autoPublish>true</autoPublish>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-source-plugin</artifactId>
                        <version>3.3.1</version>
                        <executions>
                            <execution>
                                <id>attach-sources</id>
                                <phase>verify</phase>
                                <goals>
                                    <goal>jar-no-fork</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-javadoc-plugin</artifactId>
                        <version>3.12.0</version>
                        <executions>
                            <execution>
                                <id>attach-javadoc</id>
                                <goals>
                                    <goal>jar</goal>
                                </goals>
                            </execution>
                        </executions>
                        <configuration>
                            <stylesheet>java</stylesheet>
                            <doclint>none</doclint>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-gpg-plugin</artifactId>
                        <version>3.2.8</version>
                        <executions>
                            <execution>
                                <id>sign-artifacts</id>
                                <phase>verify</phase>
                                <goals>
                                    <goal>sign</goal>
                                </goals>
                            </execution>
                        </executions>
                        <configuration>
                            <gpgArguments>
                                <arg>--pinentry-mode</arg>
                                <arg>loopback</arg>
                            </gpgArguments>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>local-proxy</id>
            <activation>
                <property>
                    <name>env.http_proxy</name>
                </property>
            </activation>
            <properties>
                <springBootRunArguments>-Dspring.profiles.include="PROXY"</springBootRunArguments>
            </properties>
            <build>
                <plugins>
                    <plugin>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <configuration>
                            <systemPropertyVariables>
                                <spring.profiles.include>PROXY</spring.profiles.include>
                                <http_proxy>http://localhost:3128</http_proxy>
                                <https_proxy>http://localhost:3128</https_proxy>
                            </systemPropertyVariables>
                        </configuration>
                    </plugin>
                    <plugin>
                        <artifactId>maven-failsafe-plugin</artifactId>
                        <configuration>
                            <systemPropertyVariables>
                                <spring.profiles.include>PROXY</spring.profiles.include>
                                <http_proxy>http://proxy:3128</http_proxy>
                                <https_proxy>http://proxy:3128</https_proxy>
                            </systemPropertyVariables>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>displayBrowser</id>
            <properties>
                <headlessDisabled>-Dheadless.disabled=true</headlessDisabled>
            </properties>
        </profile>
        <profile>
            <id>doScreenPrints</id>
            <properties>
                <headlessDisabled>-DdoScreenPrints=true</headlessDisabled>
            </properties>
        </profile>
        <profile>
            <id>owasp</id>
            <activation>
                <property>
                    <!-- can't do all just won-->
                    <name>env.OSS_INDEX_PASSWORD</name>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.owasp</groupId><artifactId>dependency-check-maven</artifactId><version>${owasp.dependency-check-maven.version}</version>
                        <configuration>
                            <suppressionFile>${qa.directory}/owasp-dependency-checker-suppressions.xml</suppressionFile>
                            <failBuildOnCVSS>2</failBuildOnCVSS>
                            <skip>${dependency.skip}</skip>
                            <nvdApiKey>${env.NVD_NIST_APIKEY}</nvdApiKey>
                            <nvdApiKey>${env.OSS_INDEX_USERNAME}</nvdApiKey>
                            <nvdApiKey>${env.OSS_INDEX_PASSWORD}</nvdApiKey>
                            <bundleAuditAnalyzerEnabled>false</bundleAuditAnalyzerEnabled>
                        </configuration>
                        <executions>
                            <execution>
                                <!--<phase>validate</phase>--> <!-- too late at prepare-package -->
                                <goals>
                                    <goal>check</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
