<?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.kiteworks</groupId>
    <artifactId>kiteworks_integration</artifactId>
    <version>2.0.3</version>
    <packaging>pom</packaging>
    <url>https://github.com/qld-gov-au/kiteworks-integration</url>
    <name>Kiteworks Integration for Qld Government</name>
    <description>Kiteworks integration for Qld Government - Java client for kiteworks based on their swagger</description>

    <scm>
        <connection>scm:git:${project.scm.url}</connection>
        <developerConnection>scm:git:${project.scm.url}</developerConnection>
        <url>https://github.com/qld-gov-au/kiteworks-integration.git</url>
      <tag>2.0.3</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>

    <modules>
        <module>kiteworks-swagger-gen</module>
        <module>kiteworks-native-client</module>
        <module>kiteworks-spring-service</module>
    </modules>

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

    <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>
                <artifactId>maven-gpg-plugin</artifactId>
                <version>3.2.8</version>
                <executions>
                    <execution>
                        <id>sign-artifacts</id>
                        <phase>verify</phase>
                        <goals>
                            <goal>sign</goal>
                        </goals>
                        <configuration>

                            <!-- This is necessary for gpg to not try to use the pinentry programs -->
                            <gpgArguments>
                                <arg>--pinentry-mode</arg>
                                <arg>loopback</arg>
                            </gpgArguments>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <!-- Use spotless plugin to automatically format code,remove unused import,etc
                 To apply changes directly to the file,run `mvn spotless:apply`
                 Ref: https://github.com/diffplug/spotless/tree/main/plugin-maven
            -->
            <plugin>
                <groupId>com.diffplug.spotless</groupId>
                <artifactId>spotless-maven-plugin</artifactId>
                <version>3.0.0</version>
                <configuration>
                    <formats>
                        <!-- you can define as many formats as you want,each is independent -->
                        <format>
                            <!-- define the files to apply to -->
                            <includes>
                                <include>.gitignore</include>
                            </includes>
                            <!-- define the steps to apply to those files -->
                            <trimTrailingWhitespace />
                            <endWithNewline />
                            <indent>
                                <spaces>true</spaces> <!-- or <tabs>true</tabs> -->
                                <spacesPerTab>4</spacesPerTab> <!-- optional,default is 4 -->
                            </indent>
                        </format>
                    </formats>
                    <!-- define a language-specific format -->
                    <java>
                        <!-- no need to specify files,inferred automatically,but you can if you want -->

                        <!-- apply a specific flavor of google-java-format and reflow long strings -->
                        <googleJavaFormat>
                            <version>1.8</version>
                            <style>AOSP</style>
                            <reflowLongStrings>true</reflowLongStrings>
                        </googleJavaFormat>
                        <removeUnusedImports />
                        <importOrder />
                    </java>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>github</id>
            <distributionManagement>
                <repository>
                    <id>github</id>
                    <name>GitHub Packages</name>
                    <url>https://maven.pkg.github.com/qld-gov-au/kiteworks-integration</url>
                </repository>
                <snapshotRepository>
                    <id>github</id>
                    <name>GitHub Packages</name>
                    <url>https://maven.pkg.github.com/qld-gov-au/kiteworks-integration</url>
                </snapshotRepository>
            </distributionManagement>
        </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>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>
        <profile>
            <id>skip-gpg-signing</id>
<!--            <activation>-->
<!--                <property>-->
<!--                    <name>!env.GPG_KEY_ID</name>-->
<!--                </property>-->
<!--            </activation>-->
            <build>
                <plugins>
                    <plugin>
                        <artifactId>maven-gpg-plugin</artifactId>
                        <configuration>
                            <skip>true</skip>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>exec-maven-plugin</artifactId>
                        <version>3.5.1</version>
                        <executions>
                            <execution>
                                <id>log-skip-message</id>
                                <phase>verify</phase>
                                <goals>
                                    <goal>exec</goal>
                                </goals>
                                <configuration>
                                    <executable>echo</executable>
                                    <arguments>
                                        <argument>::warning:: [WARNING] GPG signing skipped, not set.</argument>
                                    </arguments>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
