<?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>au.gov.qld.services.kiteworks</groupId>
        <artifactId>kiteworks_integration</artifactId>
        <version>2.0.3</version>
    </parent>

    <name>Kiteworks Spring Service for Qld Government</name>
    <artifactId>kiteworks-spring-service</artifactId>

    <properties>
        <maven.compiler.release>21</maven.compiler.release>
        <maven.compiler.source>21</maven.compiler.source>
        <maven.compiler.target>21</maven.compiler.target>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <argLine />
    </properties>

    <distributionManagement>
        <repository>
            <id>github</id>
            <name>GitHub Packages</name>
            <url>https://maven.pkg.github.com/qld-gov-au/kiteworks-integration</url>
        </repository>
    </distributionManagement>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <scope>import</scope>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-dependencies</artifactId>
                <version>3.5.6</version>
                <type>pom</type>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <dependencies>
        <dependency><groupId>au.gov.qld.services.kiteworks</groupId><artifactId>kiteworks-native-client</artifactId><version>2.0.3</version></dependency>

        <dependency><groupId>org.springframework</groupId><artifactId>spring-beans</artifactId></dependency>
        <dependency><groupId>org.springframework</groupId><artifactId>spring-context</artifactId></dependency>
        <dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-autoconfigure</artifactId></dependency>
        <dependency><groupId>org.apache.commons</groupId><artifactId>commons-lang3</artifactId><version>3.19.0</version></dependency>

        <!-- ########## Test dependencies ########## -->
        <dependency><scope>test</scope><groupId>org.junit.jupiter</groupId><artifactId>junit-jupiter-api</artifactId></dependency>
        <dependency><scope>test</scope><groupId>org.hamcrest</groupId><artifactId>hamcrest</artifactId><version>3.0</version></dependency>
        <dependency><scope>test</scope><groupId>org.mockito</groupId><artifactId>mockito-core</artifactId></dependency>
        <dependency><scope>test</scope><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-test</artifactId></dependency>
        <dependency><scope>test</scope><groupId>org.springframework.boot</groupId><artifactId>spring-boot-test</artifactId></dependency>

    </dependencies>

    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-source-plugin</artifactId>
                    <version>3.3.1</version>
                </plugin>
            </plugins>
        </pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>3.8.1</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>properties</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>3.5.4</version>
                <configuration>
                    <!-- https://javadoc.io/doc/org.mockito/mockito-core/latest/org.mockito/org/mockito/Mockito.html#0.3 -->
                    <argLine>@{argLine} -javaagent:${org.mockito:mockito-core:jar}</argLine>
                    <parallel>methods</parallel>
                    <threadCount>10</threadCount>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins </groupId>
                <artifactId>maven-failsafe-plugin</artifactId>
                <version>3.5.4</version>
                <executions>
<!--                    <execution>-->
<!--                        <id>IntegrationTest</id>-->
<!--                        <goals>-->
<!--                            <goal>verify</goal>-->
<!--                            <goal>integration-test</goal>-->
<!--                        </goals>-->
<!--                        <configuration>-->
<!--                            <includes>-->
<!--                                <include>**/*IntegrationTest.java</include>-->
<!--                            </includes>-->
<!--                            <skipTests>${failSafeSkipTests}</skipTests>-->
<!--                        </configuration>-->
<!--                    </execution>-->
                    <execution>
                        <id>IT</id>
                        <goals>
                            <goal>integration-test</goal>
                            <goal>verify</goal>
                        </goals>
                        <configuration>
                            <includes>
                                <include>**/*IT.java</include>
                            </includes>
                            <systemPropertyVariables>
                                <!--
                                Set a system property for the test clients to use when connecting.
                                Something like Apache's commons-configuration can pick this up
                                transparently.
                                -->
                            </systemPropertyVariables>
                            <skipTests>${failSafeSkipTests}</skipTests>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>sign-artifacts</id>
            <build>
                <plugins>
                    <plugin>
                        <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>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>skip-it-tests</id>
            <activation>
                <property>
                    <name>!env.KITEWORKS_SIGNATURE_KEY</name>
                </property>
            </activation>
            <properties>
                <failSafeSkipTests>true</failSafeSkipTests>
            </properties>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>exec-maven-plugin</artifactId>
                        <version>3.5.1</version>
                        <executions>
                            <execution>
                                <id>log-skip-message</id>
                                <phase>initialize</phase>
                                <goals>
                                    <goal>exec</goal>
                                </goals>
                                <configuration>
                                    <executable>echo</executable>
                                    <arguments>
                                        <argument>::warning:: [WARNING] Integration tests skipped: KITEWORKS_CLIENT_APP_SCOPES ;KITEWORKS_USER_ID ;KITEWORKS_CLIENT_SECRET ;KITEWORKS_ACCESS_TOKEN_URI ;KITEWORKS_CLIENT_ID; KITEWORKS_SIGNATURE_KEY ;KITEWORKS_BASE_URI ;KITEWORKS_REDIRECT_URI environment variable/s may not be set.</argument>
                                    </arguments>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
