<?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.smart-caches</groupId>
    <artifactId>parent</artifactId>
    <version>0.20.2</version>
    <modules>
        <module>projectors-core</module>
        <module>projector-driver</module>
        <module>cli</module>
        <module>event-sources</module>
        <module>jaxrs-base-server</module>
        <module>event-sources/event-source-file</module>
        <module>observability-core</module>
        <module>live-reporter</module>
        <module>configurator</module>
        <module>jwt-auth-common</module>
    </modules>
    <packaging>pom</packaging>
    <name>Telicent Smart Caches - Parent</name>
    <description>Provides common libraries for building Java based Smart Caches for the Telicent Core platform</description>
    <url>https://github.com/telicent-oss/smart-caches-core</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>Apache-2.0</name>
            <url>https://www.apache.org/licenses/LICENSE-2.0.txt</url>
            <distribution>repo</distribution>
            <comments>A business-friendly OSS license</comments>
        </license>
    </licenses>

    <scm>
        <connection>scm:git:https://github.com/telicent-oss/smart-caches-core</connection>
        <developerConnection>scm:git:ssh://git@github.com/telicent-oss/smart-caches-core</developerConnection>
        <url>https://github.com/telicent-oss/smart-caches-core</url>
      <tag>0.20.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
        -->
        <jdk.version>17</jdk.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

        <!-- License Plugin Configuration -->
        <!--
        Note that all submodules need to declare this appropriately as well so that the plugin can correctly find
        the header.txt file in this top directory even when run on a submodule -->
        <license.header.path>${project.basedir}</license.header.path>

        <!-- Code Coverage Configuration -->
        <!--
        Controls the minimum code coverage ratio that modules which have opted into code coverage enforcement are
        required to meet.  If a submodule wants to increase/decrease this value they can do so by redefining this
        property in their pom.xml
        -->
        <coverage.minimum>0.8</coverage.minimum>

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

        <!-- Parallel Testing -->
        <!--
        Controls how many JVM forks are used for parallel testing in some modules, set to a conservative 2 which offers
        decent reductions in test time but avoids overloading the developers machine especially when parallel tests are
        spinning up containers
        -->
        <test.maxForks>2</test.maxForks>

        <!-- Plugin Versions -->
        <plugin.clean>3.4.0</plugin.clean>
        <plugin.compiler>3.13.0</plugin.compiler>
        <plugin.cyclonedx>2.8.0</plugin.cyclonedx>
        <plugin.dependency>3.7.0</plugin.dependency>
        <plugin.enforcer>3.5.0</plugin.enforcer>
        <plugin.gpg>3.2.4</plugin.gpg>
        <plugin.jacoco>0.8.12</plugin.jacoco>
        <plugin.jar>3.4.2</plugin.jar>
        <plugin.javadoc>3.7.0</plugin.javadoc>
        <plugin.license>4.5</plugin.license>
        <plugin.nexus>1.7.0</plugin.nexus>
        <plugin.shade>3.2.4</plugin.shade>
        <plugin.source>3.3.1</plugin.source>
        <plugin.surefire>3.3.0</plugin.surefire>
        <plugin.versions>2.16.2</plugin.versions>

        <!-- Dependency Versions -->
        <dependency.airline>3.0.0</dependency.airline>
        <dependency.commons-collections>4.4</dependency.commons-collections>
        <dependency.commons-lang>3.14.0</dependency.commons-lang>
        <dependency.jackson>2.17.1</dependency.jackson>
        <dependency.jakarta-inject>2.0.1</dependency.jakarta-inject>
        <dependency.jena>5.0.0</dependency.jena>
        <dependency.jersey>3.1.7</dependency.jersey>
        <dependency.jetty>12.0.10</dependency.jetty>
        <dependency.jwt-auth>0.15.0</dependency.jwt-auth>
        <dependency.kafka>3.7.0</dependency.kafka>
        <dependency.logback>1.5.6</dependency.logback>
        <dependency.lombok>1.18.32</dependency.lombok>
        <dependency.mockito>5.12.0</dependency.mockito>
        <dependency.opentelemetry.agent>1.33.4</dependency.opentelemetry.agent>
        <dependency.opentelemetry.sdk>1.39.0</dependency.opentelemetry.sdk>
        <dependency.opentelemetry.sdk-alpha>1.25.0-alpha</dependency.opentelemetry.sdk-alpha>
        <dependency.rdf-abac>0.71.2</dependency.rdf-abac>
        <dependency.resilience4j>2.2.0</dependency.resilience4j>
        <dependency.servlet>6.0.0</dependency.servlet>
        <dependency.slf4j>2.0.13</dependency.slf4j>
        <dependency.slf4j-test>3.0.1</dependency.slf4j-test>
        <dependency.testcontainers>1.19.8</dependency.testcontainers>
        <dependency.testng>7.10.2</dependency.testng>
    </properties>

    <dependencyManagement>
        <dependencies>
            <!-- Jena for RDF processing -->
            <dependency>
                <groupId>org.apache.jena</groupId>
                <artifactId>apache-jena-libs</artifactId>
                <version>${dependency.jena}</version>
                <type>pom</type>
            </dependency>

            <dependency>
                <groupId>org.apache.jena</groupId>
                <artifactId>jena-arq</artifactId>
                <version>${dependency.jena}</version>
            </dependency>

            <dependency>
                <groupId>org.apache.jena</groupId>
                <artifactId>jena-rdfpatch</artifactId>
                <version>${dependency.jena}</version>
            </dependency>

            <!-- RDF ABAC -->
            <dependency>
                <groupId>io.telicent.jena</groupId>
                <artifactId>rdf-abac-core</artifactId>
                <version>${dependency.rdf-abac}</version>
            </dependency>

            <!-- Jackson for serialization to JSON/YAML etc -->
            <dependency>
                <groupId>com.fasterxml.jackson.core</groupId>
                <artifactId>jackson-core</artifactId>
                <version>${dependency.jackson}</version>
            </dependency>

            <dependency>
                <groupId>com.fasterxml.jackson.core</groupId>
                <artifactId>jackson-databind</artifactId>
                <version>${dependency.jackson}</version>
            </dependency>

            <dependency>
                <groupId>com.fasterxml.jackson.core</groupId>
                <artifactId>jackson-annotations</artifactId>
                <version>${dependency.jackson}</version>
            </dependency>

            <!-- TestNG and Mockito for testing -->
            <dependency>
                <groupId>org.testng</groupId>
                <artifactId>testng</artifactId>
                <version>${dependency.testng}</version>
            </dependency>

            <dependency>
                <groupId>org.mockito</groupId>
                <artifactId>mockito-core</artifactId>
                <version>${dependency.mockito}</version>
            </dependency>

            <!--
            SLF4J and a concrete implementation for Logging

            Plus bring in a mock SLF4J harness that lets us test our logging output is as expected
            -->
            <dependency>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-api</artifactId>
                <version>${dependency.slf4j}</version>
            </dependency>

            <dependency>
                <groupId>org.slf4j</groupId>
                <artifactId>jul-to-slf4j</artifactId>
                <version>${dependency.slf4j}</version>
            </dependency>

            <dependency>
                <groupId>ch.qos.logback</groupId>
                <artifactId>logback-classic</artifactId>
                <version>${dependency.logback}</version>
            </dependency>

            <dependency>
                <groupId>com.github.valfirst</groupId>
                <artifactId>slf4j-test</artifactId>
                <version>${dependency.slf4j-test}</version>
            </dependency>

            <!-- Kafka for Event Sourcing -->
            <dependency>
                <groupId>org.apache.kafka</groupId>
                <artifactId>kafka-clients</artifactId>
                <version>${dependency.kafka}</version>
            </dependency>

            <!-- Apache Commons Libraries for Utilities -->
            <dependency>
                <groupId>org.apache.commons</groupId>
                <artifactId>commons-lang3</artifactId>
                <version>${dependency.commons-lang}</version>
            </dependency>

            <dependency>
                <groupId>org.apache.commons</groupId>
                <artifactId>commons-collections4</artifactId>
                <version>${dependency.commons-collections}</version>
            </dependency>

            <!-- Airline for CLIs -->
            <dependency>
                <groupId>com.github.rvesse</groupId>
                <artifactId>airline</artifactId>
                <version>${dependency.airline}</version>
            </dependency>

            <!-- JAX-RS related dependencies -->
            <dependency>
                <groupId>jakarta.servlet</groupId>
                <artifactId>jakarta.servlet-api</artifactId>
                <version>${dependency.servlet}</version>
            </dependency>

            <dependency>
                <groupId>org.glassfish.jersey.containers</groupId>
                <artifactId>jersey-container-grizzly2-servlet</artifactId>
                <version>${dependency.jersey}</version>
            </dependency>

            <dependency>
                <groupId>org.glassfish.jersey.media</groupId>
                <artifactId>jersey-media-json-jackson</artifactId>
                <version>${dependency.jersey}</version>
            </dependency>

            <dependency>
                <groupId>org.glassfish.jersey.inject</groupId>
                <artifactId>jersey-hk2</artifactId>
                <version>${dependency.jersey}</version>
            </dependency>

            <dependency>
                <groupId>org.glassfish.jersey.ext</groupId>
                <artifactId>jersey-bean-validation</artifactId>
                <version>${dependency.jersey}</version>
            </dependency>

            <dependency>
                <groupId>org.glassfish.jersey.core</groupId>
                <artifactId>jersey-client</artifactId>
                <version>${dependency.jersey}</version>
            </dependency>

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

            <dependency>
                <groupId>jakarta.inject</groupId>
                <artifactId>jakarta.inject-api</artifactId>
                <version>${dependency.jakarta-inject}</version>
            </dependency>

            <dependency>
                <groupId>io.telicent.public</groupId>
                <artifactId>jwt-servlet-auth-jaxrs3</artifactId>
                <version>${dependency.jwt-auth}</version>
            </dependency>

            <dependency>
                <groupId>io.telicent.public</groupId>
                <artifactId>jwt-servlet-auth-aws</artifactId>
                <version>${dependency.jwt-auth}</version>
            </dependency>

            <!-- resilience4j -->
            <dependency>
                <groupId>io.github.resilience4j</groupId>
                <artifactId>resilience4j-ratelimiter</artifactId>
                <version>${dependency.resilience4j}</version>
            </dependency>

            <!-- Open Telemetry -->
            <dependency>
                <groupId>io.opentelemetry</groupId>
                <artifactId>opentelemetry-sdk</artifactId>
                <version>${dependency.opentelemetry.sdk}</version>
            </dependency>
            <dependency>
                <groupId>io.opentelemetry</groupId>
                <artifactId>opentelemetry-api</artifactId>
                <version>${dependency.opentelemetry.sdk}</version>
            </dependency>
            <dependency>
                <groupId>io.opentelemetry.semconv</groupId>
                <artifactId>opentelemetry-semconv</artifactId>
                <version>${dependency.opentelemetry.sdk-alpha}</version>
            </dependency>
            <dependency>
                <groupId>io.opentelemetry.javaagent</groupId>
                <artifactId>opentelemetry-javaagent</artifactId>
                <version>${dependency.opentelemetry.agent}</version>
            </dependency>

            <!-- Lombok -->
            <dependency>
                <groupId>org.projectlombok</groupId>
                <artifactId>lombok</artifactId>
                <version>${dependency.lombok}</version>
            </dependency>
        </dependencies>

    </dependencyManagement>

    <build>

        <plugins>
            <!-- Enforcer Plugin -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-enforcer-plugin</artifactId>
                <version>${plugin.enforcer}</version>
                <executions>
                    <execution>
                        <id>enforce-versions</id>
                        <goals>
                            <goal>enforce</goal>
                        </goals>
                        <configuration>
                            <rules>
                                <requireMavenVersion>
                                    <version>3.8.1</version>
                                </requireMavenVersion>
                                <requireJavaVersion>
                                    <version>17,</version>
                                </requireJavaVersion>
                            </rules>
                        </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>**/pom.xml</exclude>
                                <exclude>.github/**/*</exclude>
                                <exclude>**/test-data/**/*</exclude>
                                <exclude>**/certs/*</exclude>
                                <exclude>**/*.version</exclude>
                                <exclude>**/CrossOriginFilter.java</exclude>
                                <exclude>**/*.md</exclude>
                                <exclude>**/*.jpeg</exclude>
                                <exclude>**/template</exclude>
                            </excludes>
                        </licenseSet>
                    </licenseSets>
                    <mapping>
                        <java>JAVADOC_STYLE</java>
                        <shrc>SCRIPT_STYLE</shrc>
                    </mapping>
                </configuration>
                <executions>
                    <execution>
                        <id>check-licenses</id>
                        <phase>validate</phase>
                        <goals>
                            <goal>check</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>buildnumber-maven-plugin</artifactId>
                <version>3.2.0</version>
                <executions>
                    <execution>
                        <phase>generate-resources</phase>
                        <goals>
                            <goal>create-metadata</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <doCheck>true</doCheck>
                    <doUpdate>true</doUpdate>
                    <outputName>${project.artifactId}.version</outputName>
                    <addOutputDirectoryToResources>true</addOutputDirectoryToResources>
                    <timestampFormat>yyyy-MM-dd HH:mm:ss</timestampFormat>
                    <properties>
                        <artifactId>${project.artifactId}</artifactId>
                        <groupId>${project.groupId}</groupId>
                        <buildEnv>${os.name} ${os.version} (${os.arch})</buildEnv>
                    </properties>
                </configuration>
            </plugin>

            <!-- Compiler Plugin -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>${plugin.compiler}</version>
                <configuration>
                    <source>${jdk.version}</source>
                    <target>${jdk.version}</target>
                    <release>${jdk.version}</release>
                        <annotationProcessorPaths>
                            <path>
                                <groupId>org.projectlombok</groupId>
                                <artifactId>lombok</artifactId>
                                <version>${dependency.lombok}</version>
                            </path>
                        </annotationProcessorPaths>
                </configuration>
            </plugin>

            <!-- JAR Plugin -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>${plugin.jar}</version>
                <executions>
                    <execution>
                        <id>create-test-jar</id>
                        <goals>
                            <goal>test-jar</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>package</phase>
                        <goals>
                            <goal>jar</goal>
                            <goal>test-jar</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>
                    <additionalJOptions>
                        <additionalJOption>-Xdoclint:-missing</additionalJOption>
                    </additionalJOptions>
                </configuration>
            </plugin>

            <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>
        </plugins>

        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-dependency-plugin</artifactId>
                    <version>${plugin.dependency}</version>
                    <executions>
                        <execution>
                            <goals>
                                <goal>go-offline</goal>
                            </goals>
                            <configuration>
                                <!--
                                When going offline don't try to resolve internal project dependencies.  This is
                                primarily only a problem when the version gets bumped.  However, in a CI/CD environment
                                this is always needed.
                                -->
                                <excludeGroupIds>io.telicent.smart-caches</excludeGroupIds>
                            </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>
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>versions-maven-plugin</artifactId>
                    <version>${plugin.versions}</version>
                    <configuration>
                        <ignoredVersions>.*[-\.]M.*,.*-alpha.*,.*-RC.*</ignoredVersions>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>

    <profiles>
        <profile>
            <id>telicent-oss</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.sonatype.plugins</groupId>
                        <artifactId>nexus-staging-maven-plugin</artifactId>
                        <version>${plugin.nexus}</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>
        </profile>
    </profiles>

    <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>
        <!-- Needed for Apache Jena SNAPSHOTs -->
        <repository>
            <id>apache-snapshots</id>
            <url>https://repository.apache.org/content/repositories/snapshots/</url>
            <releases>
                <enabled>false</enabled>
            </releases>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </repository>
        <!-- Needed for Airline SNAPSHOTs -->
        <repository>
            <id>ossrh</id>
            <url>https://oss.sonatype.org/content/repositories/snapshots</url>
            <releases>
                <enabled>false</enabled>
            </releases>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </repository>
    </repositories>

</project>
