<?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
         https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>org.eclipse.ecsp</groupId>
    <artifactId>token-validator</artifactId>
    <version>0.0.3</version>
    <packaging>jar</packaging>

    <name>Token Validator</name>
    <description>Reusable Java library for validating JWT tokens and managing public keys</description>
    <url>https://github.com/eclipse-ecsp/token-validator</url>

    <scm>
        <connection>scm:git:https://github.com/eclipse-ecsp/token-validator.git</connection>
        <url>https://github.com/eclipse-ecsp/token-validator</url>
        <tag>HEAD</tag>
    </scm>

    <licenses>
        <license>
            <name>Apache-2.0</name>
            <url>http://www.apache.org/licenses/LICENSE-2.0</url>
        </license>
    </licenses>

    <issueManagement>
        <system>GitHub</system>
        <url>https://github.com/eclipse-ecsp/token-validator/issues</url>
    </issueManagement>

    <organization>
        <url>https://github.com/eclipse-ecsp</url>
        <name>eclipse-ecsp</name>
    </organization>

    <developers>
        <developer>
            <id>abhishekkumar-harman</id>
            <name>Abhishek Kumar</name>
            <email>Abhishek.Kumar87@harman.com</email>
        </developer>
    </developers>

    <repositories>
        <repository>
                <id>org.sonatype.central</id>
                <url>https://central.sonatype.com/repository/maven-snapshots/</url>
                <releases>
                    <enabled>false</enabled>
                </releases>
                <snapshots>
                    <enabled>true</enabled>
                </snapshots>
        </repository>
    </repositories>

    <pluginRepositories>
        <pluginRepository>
            <id>dash-licenses-releases</id>
            <url>https://repo.eclipse.org/content/repositories/dash-licenses-releases/</url>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </pluginRepository>
    </pluginRepositories>

    <properties>
        <java.version>25</java.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

        <!-- Dependency versions -->
        <spring.boot.version>4.0.7</spring.boot.version>
        <nimbus.jose.jwt.version>10.9</nimbus.jose.jwt.version>
        <httpclient5.version>5.6.1</httpclient5.version>
        <micrometer.version>1.16.5</micrometer.version>
        <ecsp.utils.version>1.2.3</ecsp.utils.version>
        <tomcat.version>11.0.22</tomcat.version>
        <classgraph.version>4.8.184</classgraph.version>

        <!-- Test dependency versions -->
        <junit.jupiter.version>6.0.3</junit.jupiter.version>
        <mockito.version>5.23.0</mockito.version>
        <wiremock.version>3.13.2</wiremock.version>
        <jetty-ee10.version>12.1.9</jetty-ee10.version>

        <!-- Plugin versions -->
        <maven.compiler.plugin.version>3.15.0</maven.compiler.plugin.version>
        <maven.surefire.plugin.version>3.5.5</maven.surefire.plugin.version>
        <maven.failsafe.plugin.version>3.5.5</maven.failsafe.plugin.version>
        <jacoco.plugin.version>0.8.14</jacoco.plugin.version>
        <checkstyle.plugin.version>3.6.0</checkstyle.plugin.version>
        <maven-clean-plugin.version>3.5.0</maven-clean-plugin.version>
        <maven-dependency-plugin.version>3.10.0</maven-dependency-plugin.version>
        <maven-deploy-plugin.version>3.1.4</maven-deploy-plugin.version>
        <maven-jar-plugin.version>3.5.0</maven-jar-plugin.version>
        <sonar-maven-plugin.version>5.6.0.6792</sonar-maven-plugin.version>
        <maven-gpg-plugin.version>3.2.8</maven-gpg-plugin.version>
        <central-publishing-maven-plugin.version>0.10.0</central-publishing-maven-plugin.version>
        <cyclonedx-maven-plugin.version>2.9.1</cyclonedx-maven-plugin.version>
        <maven-source-plugin.version>3.4.0</maven-source-plugin.version>
        <maven-javadoc-plugin.version>3.12.0</maven-javadoc-plugin.version>
        <license-tool-plugin.version>1.1.0</license-tool-plugin.version>

        <!-- JaCoCo coverage thresholds -->
        <jacoco.line.coverage>0.90</jacoco.line.coverage>
        <jacoco.branch.coverage>0.90</jacoco.branch.coverage>
        <sonar.java.checkstyle.reportPaths>${project.build.directory}/checkstyle-result.xml
        </sonar.java.checkstyle.reportPaths>

        <!-- Sonar plugin properties -->
        <sonar.core.codeCoveragePlugin>jacoco</sonar.core.codeCoveragePlugin>
        <sonar.coverage.jacoco.xmlReportPaths>${project.build.directory}/site/jacoco-ut/jacoco.xml
        </sonar.coverage.jacoco.xmlReportPaths>
        <sonar.language>java</sonar.language>
        
        <skipCheckstyle>false</skipCheckstyle>
        <skipJavadocs>false</skipJavadocs>
        <skipSource>false</skipSource>
        <skipGpgSign>true</skipGpgSign>
        <skipMavenPublishing>true</skipMavenPublishing>
        <skipDash>true</skipDash>
        <failWhenReviewNeeded>false</failWhenReviewNeeded>
    </properties>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-dependencies</artifactId>
                <version>${spring.boot.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
            <!-- Force consistent Jetty 12 versions for WireMock test dependency -->
            <dependency>
                <groupId>org.eclipse.jetty.ee10</groupId>
                <artifactId>jetty-ee10-servlet</artifactId>
                <version>${jetty-ee10.version}</version>
            </dependency>
            <dependency>
                <groupId>org.eclipse.jetty.ee10</groupId>
                <artifactId>jetty-ee10-servlets</artifactId>
                <version>${jetty-ee10.version}</version>
            </dependency>
            <dependency>
                <groupId>org.eclipse.jetty.ee10</groupId>
                <artifactId>jetty-ee10-webapp</artifactId>
                <version>${jetty-ee10.version}</version>
            </dependency>
            <dependency>
                <groupId>org.apache.tomcat.embed</groupId>
                <artifactId>tomcat-embed-el</artifactId>
                <version>${tomcat.version}</version>
            </dependency>
            <dependency>
                <groupId>io.github.classgraph</groupId>
                <artifactId>classgraph</artifactId>
                <version>${classgraph.version}</version>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <dependencies>
        <!-- Spring Boot Starter -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
        </dependency>

        <!-- Spring Boot Configuration Processor -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-configuration-processor</artifactId>
            <optional>true</optional>
        </dependency>

        <!-- Spring Boot Autoconfigure -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-autoconfigure</artifactId>
        </dependency>

        <!-- JWT Library: nimbus-jose-jwt -->
        <dependency>
            <groupId>com.nimbusds</groupId>
            <artifactId>nimbus-jose-jwt</artifactId>
            <version>${nimbus.jose.jwt.version}</version>
        </dependency>

        <!-- Apache HttpClient 5 for JWKS fetches -->
        <dependency>
            <groupId>org.apache.httpcomponents.client5</groupId>
            <artifactId>httpclient5</artifactId>
            <version>${httpclient5.version}</version>
        </dependency>

        <!-- ECSP Utils (IgniteLogger) -->
        <dependency>
            <groupId>org.eclipse.ecsp</groupId>
            <artifactId>utils</artifactId>
            <version>${ecsp.utils.version}</version>
        </dependency>

        <!-- Micrometer (optional - for metrics) -->
        <dependency>
            <groupId>io.micrometer</groupId>
            <artifactId>micrometer-core</artifactId>
            <version>${micrometer.version}</version>
            <optional>true</optional>
        </dependency>

        <!-- Spring Boot Validation -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-validation</artifactId>
        </dependency>

        <!-- Test Dependencies -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-core</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-junit-jupiter</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.wiremock</groupId>
            <artifactId>wiremock-jetty12</artifactId>
            <version>${wiremock.version}</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <!-- Maven Compiler Plugin -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>${maven.compiler.plugin.version}</version>
                <configuration>
                    <source>${java.version}</source>
                    <target>${java.version}</target>
                    <release>${java.version}</release>
                    <encoding>UTF-8</encoding>
                    <compilerArgs>
                        <arg>--enable-preview</arg>
                    </compilerArgs>
                </configuration>
            </plugin>

            <!-- Maven Surefire Plugin (unit tests) -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>${maven.surefire.plugin.version}</version>
                <configuration>
                    <argLine>@{argLine} --enable-preview</argLine>
                </configuration>
            </plugin>

            <!-- Maven Failsafe Plugin (integration tests) -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-failsafe-plugin</artifactId>
                <version>${maven.failsafe.plugin.version}</version>
                <configuration>
                    <argLine>@{argLine} --enable-preview</argLine>
                </configuration>
            </plugin>

            <!-- JaCoCo Plugin -->
            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <version>${jacoco.plugin.version}</version>
                <executions>
                    <execution>
                        <id>prepare-agent</id>
                        <goals>
                            <goal>prepare-agent</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>report</id>
                        <phase>verify</phase>
                        <goals>
                            <goal>report</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>check</id>
                        <phase>verify</phase>
                        <goals>
                            <goal>check</goal>
                        </goals>
                        <configuration>
                            <rules>
                                <rule>
                                    <element>BUNDLE</element>
                                    <limits>
                                        <limit>
                                            <counter>LINE</counter>
                                            <value>COVEREDRATIO</value>
                                            <minimum>${jacoco.line.coverage}</minimum>
                                        </limit>
                                        <limit>
                                            <counter>BRANCH</counter>
                                            <value>COVEREDRATIO</value>
                                            <minimum>${jacoco.branch.coverage}</minimum>
                                        </limit>
                                    </limits>
                                </rule>
                            </rules>
                            <excludes>
                                <exclude>**/TokenValidatorAutoConfiguration.class</exclude>
                                <exclude>**/TokenValidatorAutoConfiguration$*.class</exclude>
                                <exclude>**/TokenValidatorProperties.class</exclude>
                                <exclude>**/TokenValidatorProperties$*.class</exclude>
                                <exclude>**/PublicKeyRefreshScheduler.class</exclude>
                            </excludes>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <!-- Checkstyle Plugin -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-checkstyle-plugin</artifactId>
                <version>${checkstyle.plugin.version}</version>
                <configuration>
                    <configLocation>checkstyle.xml</configLocation>
                    <consoleOutput>true</consoleOutput>
                    <failsOnError>true</failsOnError>
                    <failOnViolation>true</failOnViolation>
                    <violationSeverity>warning</violationSeverity>
                    <includeTestSourceDirectory>true</includeTestSourceDirectory>
                    <propertyExpansion>
                        org.checkstyle.google.suppressionfilter.config=${project.basedir}/checkstyle-suppressions.xml
                    </propertyExpansion>
                </configuration>
                <executions>
                    <execution>
                        <id>validate</id>
                        <phase>validate</phase>
                        <goals>
                            <goal>check</goal>
                        </goals>
                    </execution>
                </executions>
                <dependencies>
                    <dependency>
                        <groupId>com.puppycrawl.tools</groupId>
                        <artifactId>checkstyle</artifactId>
                        <version>10.24.0</version>
                    </dependency>
                </dependencies>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-source-plugin</artifactId>
                <version>${maven-source-plugin.version}</version>
                <executions>
                    <execution>
                        <id>attach-sources</id>
                        <goals>
                            <goal>jar-no-fork</goal>
                        </goals>
                        <configuration>
                            <classifier>sources</classifier>
                        </configuration>
                    </execution>
                </executions>
                <configuration>
                    <skipSource>${skipSource}</skipSource>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <version>${maven-javadoc-plugin.version}</version>
                <executions>
                    <execution>
                        <id>attach-javadocs</id>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <skip>${skipJavadocs}</skip>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.eclipse.dash</groupId>
                <artifactId>license-tool-plugin</artifactId>
                <version>${license-tool-plugin.version}</version>
                <configuration>
                    <includeScope>test</includeScope>
                    <skip>${skipDash}</skip>
                    <failWhenReviewNeeded>${failWhenReviewNeeded}</failWhenReviewNeeded>
                    <timeout>300</timeout>
                    <batch>50</batch>
                </configuration>
                <executions>
                    <execution>
                        <id>license-check</id>
                        <goals>
                            <goal>license-check</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-gpg-plugin</artifactId>
                <version>${maven-gpg-plugin.version}</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>
                        <arg>--batch</arg>
                        <arg>--yes</arg>
                    </gpgArguments>
                    <skip>${skipGpgSign}</skip>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.sonatype.central</groupId>
                <artifactId>central-publishing-maven-plugin</artifactId>
                <version>${central-publishing-maven-plugin.version}</version>
                <extensions>true</extensions>
                <configuration>
                    <publishingServerId>central</publishingServerId>
                    <autoPublish>true</autoPublish>
                    <waitUntil>published</waitUntil>
                    <centralSnapshotsUrl>https://central.sonatype.com/repository/maven-snapshots/</centralSnapshotsUrl>
                    <skipPublishing>${skipMavenPublishing}</skipPublishing>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.sonarsource.scanner.maven</groupId>
                <artifactId>sonar-maven-plugin</artifactId>
                <version>${sonar-maven-plugin.version}</version>
            </plugin>
            <plugin>
                <groupId>org.cyclonedx</groupId>
                <artifactId>cyclonedx-maven-plugin</artifactId>
                <version>${cyclonedx-maven-plugin.version}</version>
                <configuration>
                    <projectType>application</projectType>
                    <schemaVersion>1.5</schemaVersion>
                    <includeBomSerialNumber>true</includeBomSerialNumber>
                    <includeCompileScope>true</includeCompileScope>
                    <includeProvidedScope>true</includeProvidedScope>
                    <includeRuntimeScope>true</includeRuntimeScope>
                    <includeSystemScope>true</includeSystemScope>
                    <includeTestScope>true</includeTestScope>
                    <includeLicenseText>true</includeLicenseText>
                    <outputFormat>all</outputFormat>
                    <outputDirectory>${project.basedir}/sbom</outputDirectory>
                    <verbose>false</verbose>
                </configuration>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>makeAggregateBom</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-deploy-plugin</artifactId>
                <version>${maven-deploy-plugin.version}</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>${maven-jar-plugin.version}</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>${maven-dependency-plugin.version}</version>
            </plugin>
        </plugins>
    </build>
    <reporting>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-report-plugin</artifactId>
                <configuration>
                    <aggregate>true</aggregate>
                </configuration>
                <reportSets>
                    <reportSet>
                        <reports>
                            <report>report</report>
                        </reports>
                        <configuration>
                            <aggregate>true</aggregate>
                        </configuration>
                    </reportSet>
                </reportSets>
            </plugin>
        </plugins>
    </reporting>
    <profiles>
        <profile>
            <id>default</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <properties>
                <skipDash>true</skipDash>
                <skipTests>false</skipTests>
                <skipGpgSign>true</skipGpgSign>
                <skipJavadocs>false</skipJavadocs>
                <skipSource>false</skipSource>
                <skipMavenPublishing>true</skipMavenPublishing>
            </properties>
        </profile>
        <profile>
            <id>snapshot</id>
            <activation>
                <activeByDefault>false</activeByDefault>
            </activation>
            <properties>
                <skipDash>true</skipDash>
                <skipTests>false</skipTests>
                <skipGpgSign>false</skipGpgSign>
                <skipJavadocs>false</skipJavadocs>
                <skipSource>false</skipSource>
                <skipMavenPublishing>false</skipMavenPublishing>
            </properties>
        </profile>
        <profile>
            <id>dash</id>
            <properties>
                <skipDash>false</skipDash>
                <failWhenReviewNeeded>true</failWhenReviewNeeded>
                <skipTests>true</skipTests>
                <skipCheckstyle>true</skipCheckstyle>
                <skipGpgSign>true</skipGpgSign>
                <skipJavadocs>true</skipJavadocs>
                <skipSource>true</skipSource>
                <skipMavenPublishing>true</skipMavenPublishing>
            </properties>
        </profile>
        <profile>
            <id>release</id>
            <properties>
                <skipDash>true</skipDash>
                <skipTests>false</skipTests>
                <skipGpgSign>false</skipGpgSign>
                <skipJavadocs>false</skipJavadocs>
                <skipSource>false</skipSource>
                <skipMavenPublishing>false</skipMavenPublishing>
            </properties>
        </profile>
    </profiles>
</project>
