<?xml version="1.0" encoding="UTF-8"?>
<!--
 * Copyright (c) 2023 General Motors GTO LLC.
 * 
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License v. 2.0 which is available at
 * http://www.eclipse.org/legal/epl-2.0.
 * 
 * SPDX-FileType: DOCUMENTATION
 * SPDX-FileCopyrightText: 2023 General Motors GTO LLC
 * SPDX-License-Identifier: Apache-2.0
-->
<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>org.eclipse.uprotocol</groupId>
    <artifactId>up-java</artifactId>
    <name>Java Library for uProtocol</name>
    <description>Language specific uProtocol library for building and using UUri, UUID, UAttributes, UTransport, and more</description>
    <version>0.1.9</version>
    <packaging>jar</packaging>
    <url>https://github.com/eclipse-uprotocol/up-java/</url>    

    <properties>
        <java.version>11</java.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>11</maven.compiler.source>
        <maven.compiler.target>11</maven.compiler.target>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <junit.platform.version>1.9.1</junit.platform.version>
        <junit-jupiter.version>5.9.1</junit-jupiter.version>
        <junit.version>4.12</junit.version>
        <maven-surefire-plugin.version>3.0.0-M5</maven-surefire-plugin.version>
        <slf4j.version>2.6.18</slf4j.version>
        <cloudevents.version>2.4.2</cloudevents.version>
        <protobuf.version>3.21.10</protobuf.version>
        <git.tag.name>uprotocol-core-api-1.5.7</git.tag.name>
    </properties>

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


    <developers>
        <developer>
          <name>Steven Hartley</name>
          <email>steven.hartley@gm.com</email>
          <organization>General Motors</organization>
          <organizationUrl>https://www.gm.com</organizationUrl>
        </developer>
    </developers>

    <scm>
        <connection>scm:git:${project.scm.url}</connection>
        <developerConnection>scm:git:${project.scm.url}</developerConnection>
        <url>https://github.com/eclipse-uprotocol/up-java.git</url>
      <tag>up-java-0.1.9</tag>
    </scm>

    <build>
        <extensions>
            <extension>
                <groupId>kr.motd.maven</groupId>
                <artifactId>os-maven-plugin</artifactId>
                <version>1.6.2</version>
            </extension>
        </extensions>

        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>3.0.0</version>
                <executions>
                    <execution>
                        <id>clone-repository</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                        <configuration>
                            <executable>git</executable>

                            <arguments>
                                <argument>clone</argument>
                                <argument>--branch</argument>
                                <argument>${git.tag.name}</argument>
                                <argument>https://github.com/eclipse-uprotocol/up-core-api.git</argument>
                                <argument>${project.build.directory}/up-core-api</argument>
                            </arguments>
                            <!-- Allow non-zero exit code (error) -->
                            <successCodes>
                                <successCode>0</successCode>
                                <successCode>128</successCode> <!-- Git error code for existing repository -->
                            </successCodes>
                        </configuration>
                    </execution>
                    <execution>
                        <id>pull-repository</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                        <configuration>
                            <executable>git</executable>
                            <workingDirectory>${project.build.directory}/up-core-api</workingDirectory>
                            <arguments>
                                <argument>pull</argument>
                                <argument>origin</argument>
                                <argument>${git.tag.name}</argument>
                            </arguments>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>${java.version}</source>
                    <target>${java.version}</target>
                </configuration>
                <version>3.10.1</version> <!-- 3.8.1 -->
            </plugin>
            <!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-clean-plugin</artifactId>
                <version>3.1.0</version>
            </plugin>
            <!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <version>3.1.0</version>
            </plugin>
            <plugin>
                <groupId>org.xolstice.maven.plugins</groupId>
                <artifactId>protobuf-maven-plugin</artifactId>
                <version>0.6.1</version> <!-- Use the latest version -->
                <executions>
                    <execution>
                        <goals>
                            <goal>compile</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <protocArtifact>com.google.protobuf:protoc:3.17.3:exe:${os.detected.classifier}</protocArtifact>
                    <protoSourceRoot>${project.build.directory}/up-core-api/uprotocol</protoSourceRoot>
                    <outputDirectory>${project.build.directory}/generated-sources/protobuf/java</outputDirectory>

                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>${maven-surefire-plugin.version}</version> <!--  ${maven-surefire-plugin.version} 2.22.1 3.0.0-M1 3.0.0-M5-->
                <configuration>
                    <!--  allow to use unnamed modules -->
                    <useModulePath>false</useModulePath>
                    <argLine>${argLine}</argLine>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-jar-plugin</artifactId>
                <version>3.0.2</version>
            </plugin>
            <plugin>
                <artifactId>maven-install-plugin</artifactId>
                <version>2.5.2</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-project-info-reports-plugin</artifactId>
                <version>3.4.1</version>
            </plugin>
            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <version>0.8.8</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>prepare-agent</goal>
                        </goals>
                    </execution>
                    <!-- attached to Maven test phase -->
                    <execution>
                        <id>report</id>
                        <phase>test</phase>
                        <goals>
                            <goal>report</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
               <groupId>org.apache.maven.plugins</groupId>
               <artifactId>maven-source-plugin</artifactId>
               <version>3.3.0</version>
               <executions>
                  <execution>
                     <id>attach-sources</id>
                     <goals>
                        <goal>jar-no-fork</goal>
                     </goals>
                  </execution>
               </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <version>3.6.0</version>
                <configuration>
                    <doclint>all,-missing,-reference</doclint>
                </configuration>
                <executions>
                    <execution>
                        <id>attach-javadocs</id>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.eclipse.dash</groupId>
                <artifactId>license-tool-plugin</artifactId>
                <version>1.0.2</version>
                <executions>
                    <execution>
                        <id>license-check</id>
                        <phase>deploy</phase>
                        <goals>
                            <goal>license-check</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
               <groupId>org.sonatype.plugins</groupId>
               <artifactId>nexus-staging-maven-plugin</artifactId>
               <version>1.6.13</version>
               <extensions>true</extensions>
               <configuration>
                 <serverId>ossrh</serverId>
                 <nexusUrl>https://oss.sonatype.org/</nexusUrl>
                 <autoReleaseAfterClose>true</autoReleaseAfterClose>
                 <stagingProgressTimeoutMinutes>10</stagingProgressTimeoutMinutes>
               </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-release-plugin</artifactId>
                <version>3.0.1</version>
                <configuration>
                    <useReleaseProfile>false</useReleaseProfile>
                    <releaseProfiles>release</releaseProfiles>
                    <goals>deploy</goals>
                </configuration>
            </plugin>

        </plugins>
    </build>

    <dependencyManagement>
        <dependencies>

            <dependency>
                <groupId>io.cloudevents</groupId>
                <artifactId>cloudevents-protobuf</artifactId>
                <version>2.4.2</version>
            </dependency>


            <dependency>
                <groupId>com.google.errorprone</groupId>
                <artifactId>error_prone_annotations</artifactId>
                <version>2.11.0</version>
            </dependency>


            <dependency>
                <groupId>org.checkerframework</groupId>
                <artifactId>checker-qual</artifactId>
                <version>3.12.0</version>
            </dependency>

            <dependency>
                <groupId>com.google.protobuf</groupId>
                <artifactId>protobuf-bom</artifactId>
                <version>${protobuf.version}</version>
                <scope>import</scope>
                <type>pom</type>
            </dependency>

            <!-- CloudEvents Java SDK https://github.com/cloudevents/sdk-java -->
            <!-- https://github.com/cloudevents/sdk-java/pull/526 bump the version to fix serialization issue -->
            <dependency>
                <groupId>io.cloudevents</groupId>
                <artifactId>cloudevents-bom</artifactId>
                <version>${cloudevents.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>

            <dependency>
                <groupId>nl.jqno.equalsverifier</groupId>
                <artifactId>equalsverifier</artifactId>
                <version>3.14.1</version>
                <scope>test</scope>
            </dependency>

            <!--JUnit Jupiter Engine to depend on the JUnit5 engine and JUnit 5 API -->
            <dependency>
                <groupId>org.junit.jupiter</groupId>
                <artifactId>junit-jupiter-engine</artifactId>
                <version>${junit-jupiter.version}</version>
                <scope>test</scope>
            </dependency>

        </dependencies>
    </dependencyManagement>

    <dependencies>
        <!-- Testing -->
        <dependency>
            <groupId>nl.jqno.equalsverifier</groupId>
            <artifactId>equalsverifier</artifactId>
            <version>3.14.1</version>
            <scope>test</scope>
        </dependency>

        <!--JUnit Jupiter Engine to depend on the JUnit5 engine and JUnit 5 API -->
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-engine</artifactId>
            <scope>test</scope>
        </dependency>

        <!-- https://mvnrepository.com/artifact/io.cloudevents/cloudevents-protobuf -->
        <dependency>
            <groupId>io.cloudevents</groupId>
            <artifactId>cloudevents-protobuf</artifactId>
            
        </dependency>

        <!-- CloudEvents support https://cloudevents.github.io/sdk-java/  https://github.com/cloudevents/sdk-java-->
        <dependency>
            <groupId>io.cloudevents</groupId>
            <artifactId>cloudevents-core</artifactId>
        </dependency>
        <dependency>
            <groupId>io.cloudevents</groupId>
            <artifactId>cloudevents-api</artifactId>
        </dependency>
        <dependency>
            <groupId>io.cloudevents</groupId>
            <artifactId>cloudevents-json-jackson</artifactId>
        </dependency>

        <dependency>
            <groupId>com.google.protobuf</groupId>
            <artifactId>protobuf-java</artifactId>
        </dependency>


        <!-- https://search.maven.org/artifact/com.github.f4b6a3/uuid-creator -->
        <dependency>
            <groupId>com.github.f4b6a3</groupId>
            <artifactId>uuid-creator</artifactId>
            <version>5.1.2</version>
        </dependency>

        <dependency>
            <groupId>commons-validator</groupId>
            <artifactId>commons-validator</artifactId>
            <version>1.7</version>
        </dependency>

        <!-- JSON library for JUnit test cases -->
        <dependency>
            <groupId>org.json</groupId>
            <artifactId>json</artifactId>
            <version>20231013</version> <!-- Use the latest version -->
            <scope>test</scope>
        </dependency>
    </dependencies>

    <distributionManagement>
      <snapshotRepository>
        <id>ossrh</id>
        <url>https://oss.sonatype.org/content/repositories/snapshots</url>
      </snapshotRepository>
      <repository>
       <id>ossrh</id>
       <url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
      </repository>
    </distributionManagement>

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

    </pluginRepositories>
    
    <profiles>
        <profile>
            <id>release</id>
            <build>
                <plugins>

                    <plugin>
                       <groupId>org.apache.maven.plugins</groupId>
                       <artifactId>maven-source-plugin</artifactId>
                       <version>3.3.0</version>
                       <executions>
                          <execution>
                             <id>attach-sources</id>
                             <goals>
                                <goal>jar-no-fork</goal>
                             </goals>
                          </execution>
                       </executions>
                    </plugin>
        
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-gpg-plugin</artifactId>
                        <version>3.1.0</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>
                            </gpgArguments>
                            <passphraseServerId>gpg.passphrase</passphraseServerId>
                        </configuration>
                    </plugin>
                        
                </plugins>
            </build>

        </profile>
    </profiles>

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