<!--
SPDX-FileCopyrightText: 2017-present Open Networking Foundation <info@opennetworking.org>
SPDX-FileCopyrightText: 2022-present Intel Corporation
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>

    <parent>
        <groupId>org.sonatype.oss</groupId>
        <artifactId>oss-parent</artifactId>
        <version>7</version>
    </parent>

    <packaging>bundle</packaging>
    <groupId>io.atomix</groupId>
    <artifactId>atomix-sdk</artifactId>
    <version>0.1.1</version>
    <name>Atomix Java SDK</name>

    <properties>
        <jv>${project.version}</jv>

        <!-- Java -->
        <java.version>11</java.version>

        <!-- Dependencies -->
        <slf4j.version>1.7.7</slf4j.version>
        <protobuf.version>3.10.0</protobuf.version>
        <grpc.version>1.22.1</grpc.version>
        <guava.version>22.0</guava.version>
        <atomix.version>4.0.0-SNAPSHOT</atomix.version>
        <junit.version>4.12</junit.version>

        <!-- Maven plugins -->
        <maven.surefire.plugin.version>2.22.0</maven.surefire.plugin.version>
        <maven.source.plugin.version>2.2.1</maven.source.plugin.version>
        <maven.compiler.plugin.version>3.7.0</maven.compiler.plugin.version>
        <maven.javadoc.plugin.version>3.0.1</maven.javadoc.plugin.version>
        <maven.checkstyle.plugin.version>3.0.0</maven.checkstyle.plugin.version>
        <maven.wagon.plugin.version>2.0.0</maven.wagon.plugin.version>
        <maven.antrun.plugin.version>1.8</maven.antrun.plugin.version>
        <maven.build-helper.plugin.version>3.0.0</maven.build-helper.plugin.version>
        <maven.protobuf.plugin.version>0.5.1</maven.protobuf.plugin.version>
        <maven.bundle.plugin.version>5.1.8</maven.bundle.plugin.version>

        <!-- NOTE this is just a temporary workaround -->
        <atomix-runtime.version>master</atomix-runtime.version>
        <wagon-maven-plugin.atomix-runtime-url>https://raw.githubusercontent.com/atomix/runtime/${atomix-runtime.version}/</wagon-maven-plugin.atomix-runtime-url>

        <gogo-protobuf.version>v1.3.2</gogo-protobuf.version>
        <wagon-maven-plugin.gogo-protobuf-url>https://raw.githubusercontent.com/gogo/protobuf/${gogo-protobuf.version}</wagon-maven-plugin.gogo-protobuf-url>
    </properties>

    <dependencies>
        <dependency>
            <groupId>com.google.protobuf</groupId>
            <artifactId>protobuf-java</artifactId>
            <version>${protobuf.version}</version>
        </dependency>
        <dependency>
            <groupId>io.grpc</groupId>
            <artifactId>grpc-protobuf</artifactId>
            <version>${grpc.version}</version>
        </dependency>
        <dependency>
            <groupId>io.grpc</groupId>
            <artifactId>grpc-stub</artifactId>
            <version>${grpc.version}</version>
        </dependency>
        <dependency>
            <groupId>io.grpc</groupId>
            <artifactId>grpc-netty-shaded</artifactId>
            <version>${grpc.version}</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>${slf4j.version}</version>
        </dependency>
        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
            <version>${guava.version}</version>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>${junit.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>javax.annotation</groupId>
            <artifactId>javax.annotation-api</artifactId>
            <version>1.3.2</version>
        </dependency>
        <dependency>
            <groupId>io.grpc</groupId>
            <artifactId>grpc-testing</artifactId>
            <version>${grpc.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-core</artifactId>
            <version>3.4.0</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <profiles>
        <!-- JDK9+ -->
        <profile>
            <id>java9</id>
            <properties>
                <argLine.common>-Xss256k -Xms512m -Xmx2G -Dio.atomix.whitelistPackages=io.atomix</argLine.common>
                <argLine.extras>--add-modules jdk.unsupported --add-opens=java.base/java.nio=ALL-UNNAMED</argLine.extras>
                <argLine.javadocs>-html5</argLine.javadocs>
                <!-- coverall version 4.3.0 does not work with java 9, see https://github.com/trautonen/coveralls-maven-plugin/issues/112 -->
                <coveralls.skip>true</coveralls.skip>
            </properties>
            <activation>
                <jdk>[1.9,)</jdk>
            </activation>
        </profile>
        <profile>
            <id>sonatype-oss-release</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-source-plugin</artifactId>
                        <version>2.1.2</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>2.7</version>
                        <executions>
                            <execution>
                                <id>attach-javadocs</id>
                                <goals>
                                    <goal>jar</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-gpg-plugin</artifactId>
                        <version>1.1</version>
                        <executions>
                            <execution>
                                <id>sign-artifacts</id>
                                <phase>verify</phase>
                                <goals>
                                    <goal>sign</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

    <licenses>
        <license>
            <name>Apache License, Version 2.0</name>
            <url>http://apache.org/licenses/LICENSE-2.0</url>
            <distribution>repo</distribution>
        </license>
    </licenses>

    <developers>
        <developer>
            <name>Jordan Halterman</name>
            <url>https://github.com/kuujo</url>
        </developer>
        <developer>
            <name>Pier Luigi Ventre</name>
            <url>https://github.com/pierventre</url>
        </developer>
    </developers>

    <scm>
        <connection>scm:git:git@github.com:atomix/java-client.git</connection>
        <developerConnection>scm:git:git@github.com:atomix/java-client.git</developerConnection>
        <url>git@github.com:atomix/java-client.git</url>
    </scm>

    <issueManagement>
        <system>GitHub</system>
        <url>http://github.com/atomix/java-client/issues</url>
    </issueManagement>

    <build>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
            </resource>
            <resource>
                <directory>src/main/filtered-resources</directory>
                <filtering>true</filtering>
            </resource>
        </resources>
        <extensions>
            <extension>
                <groupId>kr.motd.maven</groupId>
                <artifactId>os-maven-plugin</artifactId>
                <version>1.5.0.Final</version>
            </extension>
        </extensions>

        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>${maven.surefire.plugin.version}</version>
                <configuration>
                    <shutdown>kill</shutdown>
                    <argLine>${argLine.extras} ${argLine.common}</argLine>
                </configuration>
            </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>
                        <phase>verify</phase>
                        <goals>
                            <goal>jar-no-fork</goal>
                        </goals>
                    </execution>
                </executions>
            </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>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.felix</groupId>
                <artifactId>maven-bundle-plugin</artifactId>
                <version>${maven.bundle.plugin.version}</version>
                <extensions>true</extensions>
                <configuration>
                    <instructions>
                        <Export-Package>
                            io.atomix.api.*,
                            io.atomix.client.*
                        </Export-Package>
                        <Import-Package>
                            !sun.nio.ch,!sun.misc,!java.*,com.google.protobuf;version=2.5.0,*
                        </Import-Package>
                    </instructions>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>1.1</version>
                <executions>
                    <execution>
                        <id>git submodule update</id>
                        <phase>initialize</phase>
                        <configuration>
                            <executable>git</executable>
                            <arguments>
                                <argument>submodule</argument>
                                <argument>update</argument>
                                <argument>--init</argument>
                                <argument>--recursive</argument>
                            </arguments>
                        </configuration>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>copoy gogo proto</id>
                        <phase>initialize</phase>
                        <configuration>
                            <executable>cp</executable>
                            <arguments>
                                <argument>-r</argument>
                                <argument>src/main/resources/gogoproto</argument>
                                <argument>runtime/api/</argument>
                            </arguments>
                        </configuration>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.xolstice.maven.plugins</groupId>
                <artifactId>protobuf-maven-plugin</artifactId>
                <version>${maven.protobuf.plugin.version}</version>
                <configuration>
                    <protocArtifact>com.google.protobuf:protoc:${protobuf.version}:exe:${os.detected.classifier}</protocArtifact>
                    <pluginId>grpc-java</pluginId>
                    <pluginArtifact>io.grpc:protoc-gen-grpc-java:${grpc.version}:exe:${os.detected.classifier}</pluginArtifact>
                    <protoSourceRoot>runtime/api</protoSourceRoot>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>compile</goal>
                            <goal>compile-custom</goal>
                        </goals>
                    </execution>
                </executions>
            </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>
                    <verbose>false</verbose>
                    <!-- workaround for https://bugs.openjdk.java.net/browse/JDK-8212233 -->
                    <javaApiLinks>
                        <property>
                            <name>foo</name>
                            <value>bar</value>
                        </property>
                    </javaApiLinks>
                    <quiet>true</quiet>
                    <doclint>none</doclint>
                    <additionalparam>${argLine.javadocs}</additionalparam>
                    <show>public</show>
                    <doctitle>Atomix Java Client (${jv})</doctitle>
                    <windowtitle>Atomix Java Client (${jv})</windowtitle>
                    <stylesheetfile>${basedir}/docs/style.css</stylesheetfile>
                    <excludePackageNames>*.impl*</excludePackageNames>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>
