<?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>com.aserto</groupId>
    <artifactId>aserto-java</artifactId>
    <version>0.31.1</version>

    <name>${project.groupId}:${project.artifactId}</name>
    <description>Java SDK to interact with aserto services</description>
    <url>https://github.com/aserto-dev/aserto-java</url>

    <licenses>
        <license>
            <name>The Apache License, Version 2.0</name>
            <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
        </license>
    </licenses>

    <!-- this is required in order to publish to maven central -->
    <developers>
        <developer>
            <id>IrimieBogdan</id>
            <name>Irimie Bogdan</name>
            <email>bogdan.irimie@aserto.com</email>
            <organization>Aserto</organization>
            <organizationUrl>https://www.aserto.com/</organizationUrl>
        </developer>
    </developers>

    <scm>
        <connection>scm:git:git@github.com:aserto-dev/aserto-java.git</connection>
        <developerConnection>scm:git:ssh://git@github.com:aserto-dev/aserto-java.git</developerConnection>
        <url>https://github.com/aserto-dev/aserto-java/tree/main</url>
    </scm>

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

        <grpc.version>1.64.0</grpc.version>
        <log4j.version>2.23.1</log4j.version>
        <exclude-tests>IntegrationTest</exclude-tests>
    </properties>

    <dependencies>
        <dependency>
            <groupId>com.aserto</groupId>
            <artifactId>java-authorizer</artifactId>
            <version>0.20.11</version>
        </dependency>
        <dependency>
            <groupId>com.aserto</groupId>
            <artifactId>java-directory</artifactId>
            <version>0.31.2</version>
        </dependency>

        <!-- Used for unit testing -->
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-engine</artifactId>
            <version>5.10.2</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.assertj</groupId>
            <artifactId>assertj-core</artifactId>
            <version>3.26.0</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>io.grpc</groupId>
            <artifactId>grpc-testing</artifactId>
            <version>${grpc.version}</version>
            <scope>test</scope>
        </dependency>
        <!-- Version 4.y.z is compatible with Java 17 -->
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-core</artifactId>
            <version>4.11.0</version>
            <scope>test</scope>
        </dependency>

        <!-- Logging -->
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-api</artifactId>
            <version>${log4j.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-core</artifactId>
            <version>${log4j.version}</version>
        </dependency>
    </dependencies>

    <profiles>
        <profile>
            <id>integration</id>
            <properties>
                <!-- override exclude-tests property to remove IntegrationTest from it-->
                <exclude-tests></exclude-tests>
            </properties>
        </profile>

        <!-- used to sign the artifacts that will be published -->
        <profile>
            <id>ci-cd</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-gpg-plugin</artifactId>
                        <version>3.2.4</version>
                        <executions>
                            <execution>
                                <id>sign-artifacts</id>
                                <phase>verify</phase>
                                <goals>
                                    <goal>sign</goal>
                                </goals>
                                <configuration>
                                    <!-- Prevent gpg from using pinentry programs. Fixes: gpg: signing
                                        failed: Inappropriate ioctl for device -->
                                    <gpgArguments>
                                        <arg>--pinentry-mode</arg>
                                        <!-- pinentry-mode=loopback is necessary to avoid GPG prompting manual entry of the GPG passphrase -->
                                        <arg>loopback</arg>
                                    </gpgArguments>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

    <build>
        <plugins>
            <!-- creates a jar archive of the source files of the current project -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-source-plugin</artifactId>
                <version>3.3.1</version>
                <executions>
                    <execution>
                        <id>attach-sources</id>
                        <goals>
                            <goal>jar-no-fork</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <version>3.7.0</version>
                <executions>
                    <execution>
                        <id>attach-javadocs</id>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <!-- used to deploy the artifact to sonatype nexus -->
            <plugin>
                <groupId>org.sonatype.plugins</groupId>
                <artifactId>nexus-staging-maven-plugin</artifactId>
                <version>1.7.0</version>
                <extensions>true</extensions>
                <configuration>
                    <serverId>ossrh</serverId>
                    <nexusUrl>https://s01.oss.sonatype.org/</nexusUrl>
                    <autoReleaseAfterClose>true</autoReleaseAfterClose>
                </configuration>
            </plugin>

            <!-- used for Junit tests -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>3.2.3</version>
                <configuration>
                    <excludedGroups>${exclude-tests}</excludedGroups>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <!-- publish maven artifacts -->
    <distributionManagement>
        <snapshotRepository>
            <id>ossrh</id>
            <url>https://s01.oss.sonatype.org/content/repositories/snapshots</url>
        </snapshotRepository>
        <repository>
            <id>ossrh</id>
            <url>https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/</url>
        </repository>
    </distributionManagement>
</project>
