<?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>io.telicent</groupId>
  <artifactId>rdf-abac-evaluator</artifactId>
  <version>1.2.2</version>
  <packaging>jar</packaging>
  <name>Telicent - RDF ABAC Evaluator</name>
  <description>Provides a REST service for RDF ABAC evaluation</description>
  <url>https://github.com/telicent-oss/rdf-abac-evaluator</url>

  <developers>
    <developer>
      <name>Telicent Developers</name>
      <email>opensource@telicent.io</email>
      <organization>Telicent Ltd</organization>
      <organizationUrl>https://telicent.io</organizationUrl>
    </developer>
  </developers>

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

  <organization>
    <name>Telicent Ltd.</name>
    <url>https://telicent.io/</url>
  </organization>

  <scm>
    <connection>scm:git:https://github.com/telicent-oss/rdf-abac-evaluator</connection>
    <developerConnection>scm:git:ssh://git@github.com/telicent-oss/rdf-abac-evaluator
        </developerConnection>
    <url>https://github.com/telicent-oss/rdf-abac-evaluator</url>
    <tag>1.2.2</tag>
  </scm>

  <distributionManagement>
    <snapshotRepository>
      <id>sonatype-oss</id>
      <name>Sonatype OSS Snapshots</name>
      <url>https://s01.oss.sonatype.org/content/repositories/snapshots</url>
    </snapshotRepository>
    <repository>
      <id>sonatype-oss</id>
      <name>Sonatype OSS</name>
      <url>https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/</url>
    </repository>
  </distributionManagement>

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

    <!-- Internal dependency versions -->
    <dependency.rdf-abac>0.73.4</dependency.rdf-abac>

    <!-- External dependency versions -->
    <dependency.caffeine>2.8.0</dependency.caffeine>
    <dependency.jetty>12.0.16</dependency.jetty>
    <!-- Logging dependency versions -->
    <dependency.slf4j>2.0.16</dependency.slf4j>
    <dependency.logback>1.5.16</dependency.logback>

    <!-- Test dependency versions -->
    <dependency.jackson>2.18.2</dependency.jackson>
    <dependency.junit5>5.11.4</dependency.junit5>
    <dependency.junit5-platform>1.11.4</dependency.junit5-platform>
    <dependency.log4j2>2.20.0</dependency.log4j2>
    <dependency.mockito>5.15.2</dependency.mockito>
    <dependency.mockito-inline>5.2.0</dependency.mockito-inline>
    <dependency.wiremock>3.12.0</dependency.wiremock>

    <!-- License P Configuration -->
    <license.header.path>${project.basedir}</license.header.path>

    <!-- Javadoc Configuration -->
    <javadoc.failOnWarnings>true</javadoc.failOnWarnings>

    <!-- Test coverage -->
    <skipTests>false</skipTests>
    <coverage.minimum>0.8</coverage.minimum>

    <!-- Plugin Versioning -->
    <plugin.cyclonedx>2.9.1</plugin.cyclonedx>
    <plugin.dependency>3.8.1</plugin.dependency>
    <plugin.gpg>3.2.7</plugin.gpg>
    <plugin.jacoco>0.8.12</plugin.jacoco>
    <plugin.jar>3.4.2</plugin.jar>
    <plugin.javadoc>3.11.2</plugin.javadoc>
    <plugin.license>4.6</plugin.license>
    <plugin.shade>3.6.0</plugin.shade>
    <plugin.sonatype>1.7.0</plugin.sonatype>
    <plugin.source>3.3.1</plugin.source>
    <plugin.surefire>3.5.2</plugin.surefire>
  </properties>

  <dependencies>
    <!-- Internal Telicent libs -->
    <dependency>
      <groupId>io.telicent.jena</groupId>
      <artifactId>rdf-abac-eval</artifactId>
      <version>${dependency.rdf-abac}</version>
      <exclusions>
        <exclusion>
          <groupId>org.slf4j</groupId>
          <artifactId>slf4j-api</artifactId>
        </exclusion>
      </exclusions>
    </dependency>

    <dependency>
      <groupId>org.eclipse.jetty</groupId>
      <artifactId>jetty-server</artifactId>
      <version>${dependency.jetty}</version>
    </dependency>
    <dependency>
      <groupId>org.eclipse.jetty</groupId>
      <artifactId>jetty-security</artifactId>
      <version>${dependency.jetty}</version>
    </dependency>

    <!-- Logging -->
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-api</artifactId>
      <version>${dependency.slf4j}</version>
    </dependency>
    <dependency>
      <groupId>ch.qos.logback</groupId>
      <artifactId>logback-classic</artifactId>
      <version>${dependency.logback}</version>
      <exclusions>
        <exclusion>
          <groupId>org.slf4j</groupId>
          <artifactId>slf4j-api</artifactId>
        </exclusion>
      </exclusions>
    </dependency>

    <!-- Testing Dependencies -->
    <dependency>
      <groupId>org.junit.jupiter</groupId>
      <artifactId>junit-jupiter</artifactId>
      <version>${dependency.junit5}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.junit.platform</groupId>
      <artifactId>junit-platform-suite</artifactId>
      <version>${dependency.junit5-platform}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.wiremock</groupId>
      <artifactId>wiremock-standalone</artifactId>
      <version>${dependency.wiremock}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.mockito</groupId>
      <artifactId>mockito-inline</artifactId>
      <version>${dependency.mockito-inline}</version>
      <scope>test</scope>
      <exclusions>
        <exclusion>
          <groupId>org.mockito</groupId>
          <artifactId>mockito-core</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
    <dependency>
      <groupId>org.mockito</groupId>
      <artifactId>mockito-junit-jupiter</artifactId>
      <version>${dependency.mockito}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>com.fasterxml.jackson.core</groupId>
      <artifactId>jackson-core</artifactId>
      <version>${dependency.jackson}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>com.fasterxml.jackson.core</groupId>
      <artifactId>jackson-databind</artifactId>
      <version>${dependency.jackson}</version>
      <scope>test</scope>
      <exclusions>
        <exclusion>
          <groupId>net.bytebuddy</groupId>
          <artifactId>byte-buddy</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
  </dependencies>

  <repositories>
    <repository>
      <id>sonatype-oss</id>
      <url>https://s01.oss.sonatype.org/content/repositories/snapshots/</url>
      <releases>
        <enabled>false</enabled>
      </releases>
      <snapshots>
        <enabled>true</enabled>
      </snapshots>
    </repository>
  </repositories>

  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>${plugin.surefire}</version>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>
        <version>${plugin.jar}</version>
        <configuration>
          <archive>
            <manifest>
              <mainClass>io.telicent.attribute.evaluator.ALEServer</mainClass>
            </manifest>
          </archive>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-shade-plugin</artifactId>
        <version>${plugin.shade}</version>
        <executions>
          <execution>
            <id>server-build</id>
            <goals>
              <goal>shade</goal>
            </goals>
            <configuration>
              <createDependencyReducedPom>false</createDependencyReducedPom>
              <outputFile>target/${project.artifactId}-${project.version}.jar</outputFile>
              <shadedArtifactAttached>true</shadedArtifactAttached>
              <transformers>
                <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                  <mainClass>io.telicent.attribute.evaluator.ALEServer</mainClass>
                </transformer>
                <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" />
                <transformer implementation="org.apache.maven.plugins.shade.resource.ApacheLicenseResourceTransformer" />
                <transformer implementation="org.apache.maven.plugins.shade.resource.ApacheNoticeResourceTransformer">
                  <addHeader>false</addHeader>
                </transformer>
              </transformers>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
        <version>${plugin.dependency}</version>
        <executions>
          <execution>
            <id>copy-dependencies</id>
            <phase>package</phase>
            <goals>
              <goal>copy-dependencies</goal>
            </goals>
            <configuration>
              <outputDirectory>${project.basedir}/lib</outputDirectory>
              <includeTypes>jar</includeTypes>
              <includeScope>runtime</includeScope>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <!-- Code Coverage Plugins -->
      <plugin>
        <groupId>org.jacoco</groupId>
        <artifactId>jacoco-maven-plugin</artifactId>
        <version>${plugin.jacoco}</version>
        <executions>
          <execution>
            <id>prepare-agent</id>
            <phase>process-test-classes</phase>
            <goals>
              <goal>prepare-agent</goal>
            </goals>
            <configuration>
              <!--
                            Needs to be true so that if a module invokes Maven surefire/failsafe multiple times,
                            e.g. with different configurations, the coverage from all those runs is combined
                            -->
              <append>true</append>
            </configuration>
          </execution>
          <execution>
            <id>report</id>
            <phase>package</phase>
            <goals>
              <goal>report</goal>
            </goals>
          </execution>
          <execution>
            <id>require-test-coverage</id>
            <phase>package</phase>
            <goals>
              <goal>check</goal>
            </goals>
            <configuration>
              <skip>${skipTests}</skip>
              <rules>
                <rule>
                  <element>BUNDLE</element>
                  <limits>
                    <limit>
                      <counter>CLASS</counter>
                      <value>COVEREDRATIO</value>
                      <minimum>${coverage.minimum}</minimum>
                    </limit>
                    <limit>
                      <counter>INSTRUCTION</counter>
                      <value>COVEREDRATIO</value>
                      <minimum>${coverage.minimum}</minimum>
                    </limit>
                    <limit>
                      <counter>METHOD</counter>
                      <value>COVEREDRATIO</value>
                      <minimum>${coverage.minimum}</minimum>
                    </limit>
                    <limit>
                      <counter>BRANCH</counter>
                      <value>COVEREDRATIO</value>
                      <minimum>${coverage.minimum}</minimum>
                    </limit>
                    <limit>
                      <counter>LINE</counter>
                      <value>COVEREDRATIO</value>
                      <minimum>${coverage.minimum}</minimum>
                    </limit>
                    <limit>
                      <counter>COMPLEXITY</counter>
                      <value>COVEREDRATIO</value>
                      <minimum>${coverage.minimum}</minimum>
                    </limit>
                  </limits>
                </rule>
              </rules>
              <haltOnFailure>true</haltOnFailure>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <!-- License Plugin -->
      <plugin>
        <groupId>com.mycila</groupId>
        <artifactId>license-maven-plugin</artifactId>
        <version>${plugin.license}</version>
        <configuration>
          <failIfMissing>true</failIfMissing>
          <aggregate>false</aggregate>
          <useDefaultMapping>true</useDefaultMapping>
          <strictCheck>true</strictCheck>
          <licenseSets>
            <licenseSet>
              <header>${license.header.path}/header.txt</header>
              <excludes>
                <exclude>header.txt</exclude>
                <exclude>LICENSE</exclude>
                <exclude>NOTICE</exclude>
                <exclude>pom.xml</exclude>
                <exclude>Dockerfile</exclude>
                <exclude>.github/**/*</exclude>
                <exclude>*-code-style.xml</exclude>
                <exclude>.editorconfig</exclude>
                <exclude>**/*.log</exclude>
                <!-- RDF Data Test Files -->
                <exclude>**/*.ttl</exclude>
                <!-- Config -->
                <exclude>**/*.yml</exclude>
                <exclude>**/*.json</exclude>
                <exclude>**/*.xml</exclude>
                <!-- Trivy cache -->
                <exclude>.trivy/**</exclude>
              </excludes>
            </licenseSet>
          </licenseSets>
          <mapping>
            <java>SLASHSTAR_STYLE</java>
          </mapping>
        </configuration>
        <executions>
          <execution>
            <phase>validate</phase>
            <goals>
              <goal>check</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <!-- Source Plugin -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-source-plugin</artifactId>
        <version>${plugin.source}</version>
        <executions>
          <execution>
            <id>attach-sources</id>
            <phase>verify</phase>
            <goals>
              <goal>jar-no-fork</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <!-- Javadoc Plugin -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-javadoc-plugin</artifactId>
        <version>${plugin.javadoc}</version>
        <executions>
          <execution>
            <phase>package</phase>
            <goals>
              <goal>jar</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <javadocVersion>${java.version}</javadocVersion>
          <quiet>true</quiet>
          <encoding>UTF-8</encoding>
          <charset>UTF-8</charset>
          <docencoding>UTF-8</docencoding>
          <failOnWarnings>${javadoc.failOnWarnings}</failOnWarnings>
        </configuration>
      </plugin>

      <!-- SBOM : CycloneDX -->
      <plugin>
        <groupId>org.cyclonedx</groupId>
        <artifactId>cyclonedx-maven-plugin</artifactId>
        <version>${plugin.cyclonedx}</version>
        <executions>
          <execution>
            <id>build-sbom-cyclonedx</id>
            <phase>package</phase>
            <goals>
              <goal>makeAggregateBom</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <outputName>${project.artifactId}-${project.version}-bom</outputName>
        </configuration>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-gpg-plugin</artifactId>
        <version>${plugin.gpg}</version>
        <executions>
          <execution>
            <goals>
              <goal>sign</goal>
            </goals>
            <phase>verify</phase>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <groupId>org.sonatype.plugins</groupId>
        <artifactId>nexus-staging-maven-plugin</artifactId>
        <version>${plugin.sonatype}</version>
        <extensions>true</extensions>
        <configuration>
          <serverId>sonatype-oss</serverId>
          <nexusUrl>https://s01.oss.sonatype.org/</nexusUrl>
          <autoReleaseAfterClose>true</autoReleaseAfterClose>
          <keepStagingRepositoryOnCloseRuleFailure>true</keepStagingRepositoryOnCloseRuleFailure>
          <stagingProgressTimeoutMinutes>15</stagingProgressTimeoutMinutes>
        </configuration>
      </plugin>

    </plugins>
  </build>

</project>