<?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>

    <parent>
        <groupId>digital.nedra.commons</groupId>
        <artifactId>super-pom</artifactId>
        <version>2.0</version>
        <relativePath/>
    </parent>

    <artifactId>parent-pom</artifactId>
    <version>2.0</version>
    <packaging>pom</packaging>

    <name>parent-pom</name>
    <description>
        Fixes versions and settings of plugins and dependencies.
    </description>
    <url>https://commons.nedra.digital/java</url>

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

    <developers>
        <developer>
            <name>Nedra Java Team</name>
            <email>java.team@nedra.digital</email>
            <organization>Nedra</organization>
            <organizationUrl>https://nedra.digital</organizationUrl>
        </developer>
    </developers>

    <scm>
        <connection>scm:git:git://stash-gpn.nexign.com/scm/ndr_common_java/parent-pom.git</connection>
        <developerConnection>scm:git:https://stash-gpn.nexign.com/scm/ndr_common_java/parent-pom.git</developerConnection>
        <url>https://stash-gpn.nexign.com/scm/ndr_common_java/parent-pom</url>
    </scm>

    <properties>
        <build-tools.version>1.1</build-tools.version>
        <junit.version>4.13.2</junit.version>
        <spring-boot.version>3.0.2</spring-boot.version>
        <jackson-databind-nullable.version>0.2.4</jackson-databind-nullable.version>
        <openapi-generator-maven-plugin.version>6.3.0</openapi-generator-maven-plugin.version>
        <versions-maven-plugin.version>2.14.2</versions-maven-plugin.version>
        <maven-checkstyle-plugin.version>3.2.1</maven-checkstyle-plugin.version>
        <maven-checkstyle-plugin.enable-fail>true</maven-checkstyle-plugin.enable-fail>
        <jacoco-maven-plugin.version>0.8.8</jacoco-maven-plugin.version>
        <jacoco-maven-plugin.min-cov-ratio>0.60</jacoco-maven-plugin.min-cov-ratio>
        <jacoco-maven-plugin.haltOnFailure>true</jacoco-maven-plugin.haltOnFailure>
        <jacoco-maven-plugin.base-package-wildcard>digital/nedra/**/*</jacoco-maven-plugin.base-package-wildcard>
        <spring-session-bom.version>3.0.0</spring-session-bom.version>
        <caffeine.version>3.1.2</caffeine.version>
        <jackson.version>2.14.2</jackson.version>
        <guava.version>31.1-jre</guava.version>
        <springdoc.version>2.0.2</springdoc.version>
        <checkstyle.version>10.7.0</checkstyle.version>
    </properties>

    <dependencyManagement>
        <dependencies>
            <!-- spring session-->
            <dependency>
                <groupId>org.springframework.session</groupId>
                <artifactId>spring-session-bom</artifactId>
                <version>${spring-session-bom.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>

            <!-- spring boot-->
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-dependencies</artifactId>
                <version>${spring-boot.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>

            <!-- open api-->
            <dependency>
                <groupId>org.openapitools</groupId>
                <artifactId>jackson-databind-nullable</artifactId>
                <version>${jackson-databind-nullable.version}</version>
            </dependency>

            <dependency>
                <groupId>com.google.guava</groupId>
                <artifactId>guava</artifactId>
                <version>${guava.version}</version>
            </dependency>

            <!--  JSON Serialization      -->
            <dependency>
                <groupId>com.fasterxml.jackson.core</groupId>
                <artifactId>jackson-databind</artifactId>
                <version>${jackson.version}</version>
                <scope>compile</scope>
            </dependency>
            <dependency>
                <groupId>com.fasterxml.jackson.datatype</groupId>
                <artifactId>jackson-datatype-jdk8</artifactId>
                <version>${jackson.version}</version>
                <scope>compile</scope>
            </dependency>
            <dependency>
                <groupId>com.fasterxml.jackson.datatype</groupId>
                <artifactId>jackson-datatype-jsr310</artifactId>
                <version>${jackson.version}</version>
                <scope>compile</scope>
            </dependency>
            <dependency>
                <groupId>com.fasterxml.jackson.module</groupId>
                <artifactId>jackson-module-parameter-names</artifactId>
                <version>${jackson.version}</version>
                <scope>compile</scope>
            </dependency>

            <dependency>
                <groupId>com.github.ben-manes.caffeine</groupId>
                <artifactId>caffeine</artifactId>
                <version>${caffeine.version}</version>
            </dependency>

            <dependency>
                <groupId>junit</groupId>
                <artifactId>junit</artifactId>
                <version>${junit.version}</version>
                <scope>test</scope>
            </dependency>
            <!-- OpenAPI 3 -->
            <dependency>
                <groupId>org.springdoc</groupId>
                <artifactId>springdoc-openapi</artifactId>
                <version>${springdoc.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>versions-maven-plugin</artifactId>
                    <version>${versions-maven-plugin.version}</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-enforcer-plugin</artifactId>
                    <version>${maven-enforcer-plugin.version}</version>
                    <executions>
                        <execution>
                            <id>enforce-maven</id>
                            <goals>
                                <goal>enforce</goal>
                            </goals>
                            <configuration>
                                <rules>
                                    <requireMavenVersion>
                                        <version>3.0.5</version>
                                    </requireMavenVersion>
                                </rules>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-checkstyle-plugin</artifactId>
                    <version>${maven-checkstyle-plugin.version}</version>
                    <inherited>true</inherited>
                    <configuration>
                        <linkXRef>false</linkXRef>
                        <logViolationCountToConsole>true</logViolationCountToConsole>
                        <logViolationsToConsole>true</logViolationsToConsole>
                        <consoleOutput>true</consoleOutput>
                        <failOnViolation>${maven-checkstyle-plugin.enable-fail}</failOnViolation>
                        <failsOnError>${maven-checkstyle-plugin.enable-fail}</failsOnError>
                        <configLocation>checkstyle.xml</configLocation>
                    </configuration>
                    <dependencies>
                        <dependency>
                            <groupId>com.puppycrawl.tools</groupId>
                            <artifactId>checkstyle</artifactId>
                            <version>${checkstyle.version}</version>
                        </dependency>
                        <dependency>
                            <groupId>digital.nedra.commons</groupId>
                            <artifactId>build-tools</artifactId>
                            <version>${build-tools.version}</version>
                        </dependency>
                    </dependencies>
                    <executions>
                        <execution>
                            <id>ndr-validate</id>
                            <phase>validate</phase>
                            <goals>
                                <goal>check</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>

                <!-- spring-boot package plugin-->
                <plugin>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-maven-plugin</artifactId>
                    <version>${spring-boot.version}</version>
                    <executions>
                        <execution>
                            <goals>
                                <goal>repackage</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>

                <!-- spring controllers generation by open api doc-->
                <plugin>
                    <groupId>org.openapitools</groupId>
                    <artifactId>openapi-generator-maven-plugin</artifactId>
                    <version>${openapi-generator-maven-plugin.version}</version>
                    <executions>
                        <execution>
                            <goals>
                                <goal>generate</goal>
                            </goals>
                            <configuration>
                                <inputSpec>${project.basedir}/src/main/resources/swagger/api.yml</inputSpec>
                                <generatorName>spring</generatorName>
                                <!--suppress MavenModelInspection -->
                                <apiPackage>${swagger.api.package}</apiPackage>
                                <!--suppress MavenModelInspection -->
                                <modelPackage>${swagger.model.package}</modelPackage>
                                <skipValidateSpec>false</skipValidateSpec>
                                <configOptions>
                                    <delegatePattern>false</delegatePattern>
                                    <interfaceOnly>true</interfaceOnly>
                                    <returnSuccessCode>true</returnSuccessCode>
                                    <useSpringBoot3>true</useSpringBoot3>
                                </configOptions>
                                <additionalProperties>useTags=true</additionalProperties>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>

                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-release-plugin</artifactId>
                </plugin>

                <plugin>
                    <groupId>org.jacoco</groupId>
                    <artifactId>jacoco-maven-plugin</artifactId>
                    <version>${jacoco-maven-plugin.version}</version>
                    <executions>
                        <execution>
                            <id>default-prepare-agent</id>
                            <goals>
                                <goal>prepare-agent</goal>
                            </goals>
                        </execution>
                        <execution>
                            <id>default-report</id>
                            <phase>test</phase>
                            <goals>
                                <goal>report</goal>
                            </goals>
                            <configuration>
                                <includes>
                                    <include>${jacoco-maven-plugin.base-package-wildcard}</include>
                                </includes>
                            </configuration>
                        </execution>
                        <execution>
                            <id>default-check</id>
                            <phase>test</phase>
                            <goals>
                                <goal>check</goal>
                            </goals>
                            <configuration>
                                <haltOnFailure>${jacoco-maven-plugin.haltOnFailure}</haltOnFailure>
                                <includes>
                                    <include>${jacoco-maven-plugin.base-package-wildcard}</include>
                                </includes>
                                <rules>
                                    <rule>
                                        <element>BUNDLE</element>
                                        <limits>
                                            <limit>
                                                <value>COVEREDRATIO</value>
                                                <minimum>${jacoco-maven-plugin.min-cov-ratio}</minimum>
                                            </limit>
                                        </limits>
                                    </rule>
                                </rules>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </pluginManagement>
        <plugins>
            <plugin>
                <artifactId>maven-checkstyle-plugin</artifactId>
            </plugin>
            <plugin>
                <artifactId>maven-enforcer-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>
