<?xml version="1.0" encoding="UTF-8"?>

<!--
  ~ Copyright 2023 Maestro Cloud Control LLC
  ~
  ~ Licensed under the Apache License, Version 2.0 (the "License");
  ~ you may not use this file except in compliance with the License.
  ~ You may obtain a copy of the License at
  ~
  ~     http://www.apache.org/licenses/LICENSE-2.0
  ~
  ~ Unless required by applicable law or agreed to in writing, software
  ~ distributed under the License is distributed on an "AS IS" BASIS,
  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  ~ See the License for the specific language governing permissions and
  ~ limitations under the License.
  -->

<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.maestro3.cadf</groupId>
    <artifactId>m3-cadf</artifactId>
    <version>4.158.1</version>

    <name>${project.groupId}:${project.artifactId}</name>
    <description>CADF event standard library.</description>
    <url>https://github.com/Maestro-Cloud-Control/m3-cadf</url>

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

    <developers>
        <developer>
            <name>Karyna Filimonova</name>
            <email>oss.maestro3@gmail.com</email>
        </developer>
        <developer>
            <name>Serhii Akhmetshyn</name>
            <email>oss.maestro3@gmail.com</email>
        </developer>
        <developer>
            <name>Yevhen Nadin</name>
            <email>oss.maestro3@gmail.com</email>
        </developer>
        <developer>
            <name>Kyrylo Andreiev</name>
            <email>oss.maestro3@gmail.com</email>
        </developer>
    </developers>

    <scm>
        <connection>scm:git:https://github.com/Maestro-Cloud-Control/m3-cadf.git</connection>
        <developerConnection>scm:git:https://github.com/Maestro-Cloud-Control/m3-cadf.git</developerConnection>
        <url>https://github.com/Maestro-Cloud-Control/m3-cadf</url>
    </scm>

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

        <maven-compiler-plugin.version>3.14.1</maven-compiler-plugin.version>
        <maven-compiler-plugin.source>21</maven-compiler-plugin.source>
        <maven-compiler-plugin.target>21</maven-compiler-plugin.target>

        <maven-enforcer-plugin.version>3.6.2</maven-enforcer-plugin.version>
        <maven-help-plugin.version>3.5.1</maven-help-plugin.version>

        <jakarta-validation.version>3.0.2</jakarta-validation.version>

        <!-- Publishing -->
        <central.publishing.plugin.version>0.11.0</central.publishing.plugin.version>
        <maven.javadoc.plugin.version>3.12.0</maven.javadoc.plugin.version>
        <maven.source.plugin.version>3.4.0</maven.source.plugin.version>
        <maven.gpg.plugin.version>3.2.8</maven.gpg.plugin.version>

        <github.owner>Maestro-Cloud-Control</github.owner>
        <github.repository>m3-cadf</github.repository>

        <central.autoPublish>false</central.autoPublish>
        <central.waitUntil>validated</central.waitUntil>
    </properties>

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

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>${maven-compiler-plugin.version}</version>
                <configuration>
                    <source>${maven-compiler-plugin.source}</source>
                    <target>${maven-compiler-plugin.source}</target>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-enforcer-plugin</artifactId>
                <version>${maven-enforcer-plugin.version}</version>
                <executions>
                    <execution>
                        <id>enforce-no-duplicate-dependencies</id>
                        <goals>
                            <goal>enforce</goal>
                        </goals>
                        <configuration>
                            <rules>
                                <banDuplicatePomDependencyVersions/>
                                <requireUpperBoundDeps/>
                            </rules>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-help-plugin</artifactId>
                <version>${maven-help-plugin.version}</version>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <!-- Publish to GitHub Packages -->
        <profile>
            <id>github</id>

            <distributionManagement>
                <repository>
                    <id>github</id>
                    <name>GitHub Packages</name>
                    <url>https://maven.pkg.github.com/${github.owner}/${github.repository}</url>
                </repository>
            </distributionManagement>
        </profile>

        <!-- Publish release artifacts to Maven Central -->
        <profile>
            <id>central</id>

            <build>
                <plugins>
                    <!-- Generates artifactId-version-sources.jar -->
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-source-plugin</artifactId>
                        <version>${maven.source.plugin.version}</version>
                        <executions>
                            <execution>
                                <id>attach-sources</id>
                                <phase>package</phase>
                                <goals>
                                    <goal>jar-no-fork</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>

                    <!-- Generates artifactId-version-javadoc.jar -->
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-javadoc-plugin</artifactId>
                        <version>${maven.javadoc.plugin.version}</version>
                        <executions>
                            <execution>
                                <id>attach-javadocs</id>
                                <phase>package</phase>
                                <goals>
                                    <goal>jar</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <!-- Signs pom, jar, sources.jar and javadoc.jar -->
                    <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>
                    </plugin>

                    <!-- Uploads release bundle to Central Portal -->
                    <plugin>
                        <groupId>org.sonatype.central</groupId>
                        <artifactId>central-publishing-maven-plugin</artifactId>
                        <version>${central.publishing.plugin.version}</version>
                        <extensions>true</extensions>

                        <configuration>
                            <publishingServerId>central</publishingServerId>
                            <deploymentName>${project.artifactId}-${project.version}</deploymentName>

                            <autoPublish>${central.autoPublish}</autoPublish>
                            <waitUntil>${central.waitUntil}</waitUntil>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
