<?xml version="1.0" encoding="UTF-8"?>
<!--
    Licensed to the Apache Software Foundation (ASF) under one or more
    contributor license agreements.  See the NOTICE file distributed with
    this work for additional information regarding copyright ownership.
    The ASF licenses this file to You 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>com.github.lburgazzoli</groupId>
  <artifactId>etcd4j-v3</artifactId>
  <version>0.0.8</version>
  <name>etcd4j-v3</name>
  <packaging>bundle</packaging>
  <description>etcd4j-v3</description>
  <url>https://github.com/lburgazzoli/etcd4j-v3</url>

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

  <developers>
    <developer>
      <name>Luca Burgazzoli</name>
    </developer>
  </developers>

  <scm>
    <connection>scm:git:git@github.com:lburgazzoli/etcd4j-v3.git</connection>
    <developerConnection>scm:git:git@github.com:lburgazzoli/etcd4j-v3.git</developerConnection>
    <url>https://github.com/lburgazzoli/etcd4j-v3.git</url>
    <tag>etcd4j-v3-0.0.8</tag>
  </scm>

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

    <jdk.version>1.8</jdk.version>

    <!-- etcd -->
    <etcd.version.major>3</etcd.version.major>
    <etcd.version.minor>2</etcd.version.minor>
    <etcd.version.build>5</etcd.version.build>

    <!-- plugins -->
    <build-helper-maven-plugin.version>3.0.0</build-helper-maven-plugin.version>
    <maven-source-plugin.version>3.0.1</maven-source-plugin.version>
    <maven-compiler-plugin.version>3.6.1</maven-compiler-plugin.version>
    <maven-resources-plugin.version>3.0.2</maven-resources-plugin.version>
    <maven-javadoc-plugin.version>2.10.4</maven-javadoc-plugin.version>
    <maven-bundle-plugin.version>3.3.0</maven-bundle-plugin.version>
    <maven-surefire-plugin.version>2.20</maven-surefire-plugin.version>
    <maven-failsafe-plugin.version>2.20</maven-failsafe-plugin.version>
    <depends-maven-plugin.version>1.4.0</depends-maven-plugin.version>
    <os-maven-plugin.version>1.5.0.Final</os-maven-plugin.version>
    <protobuf-maven-plugin.version>0.5.0</protobuf-maven-plugin.version>
    <docker-maven-plugin.version>0.21.0</docker-maven-plugin.version>
    <download-maven-plugin.version>1.3.0</download-maven-plugin.version>
    <maven-gpg-plugin.version>1.6</maven-gpg-plugin.version>
    <nexus-staging-maven-plugin.version>1.6.7</nexus-staging-maven-plugin.version>
    <maven-release-plugin.version>2.5.3</maven-release-plugin.version>

    <!-- dependencies -->
    <grpc.version>1.4.0</grpc.version>
    <slf4j.version>1.7.25</slf4j.version>
    <future-converter.version>1.1.0</future-converter.version>
    <netty-tcnative-boringssl.version>2.0.5.Final</netty-tcnative-boringssl.version>
    <log4j2.version>2.8.2</log4j2.version>
    <bytebuddy.version>1.7.1</bytebuddy.version>

    <!-- should be in sync with protobuf grpc dependencies -->
    <protobuf.version>3.3.0</protobuf.version>

    <!-- test dependencies -->
    <junit.version>4.12</junit.version>
  </properties>

  <dependencies>
    <dependency>
      <groupId>io.grpc</groupId>
      <artifactId>grpc-core</artifactId>
      <version>${grpc.version}</version>
    </dependency>
    <dependency>
      <groupId>io.grpc</groupId>
      <artifactId>grpc-netty</artifactId>
      <version>${grpc.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>org.slf4j</groupId>
      <artifactId>slf4j-api</artifactId>
      <version>${slf4j.version}</version>
    </dependency>
    <dependency>
      <groupId>net.javacrumbs.future-converter</groupId>
      <artifactId>future-converter-java8-guava</artifactId>
      <version>${future-converter.version}</version>
    </dependency>

    <dependency>
      <groupId>net.bytebuddy</groupId>
      <artifactId>byte-buddy</artifactId>
      <version>${bytebuddy.version}</version>
    </dependency>


    <!-- test -->
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>${junit.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>io.grpc</groupId>
      <artifactId>grpc-testing</artifactId>
      <version>${grpc.version}</version>
      <scope>test</scope>
    </dependency>

    <!-- test - ssl -->
    <dependency>
      <groupId>io.netty</groupId>
      <artifactId>netty-tcnative-boringssl-static</artifactId>
      <version>${netty-tcnative-boringssl.version}</version>
      <classifier>${os.detected.classifier}</classifier>
      <scope>test</scope>
    </dependency>

    <!-- test - logging -->
    <dependency>
      <groupId>org.apache.logging.log4j</groupId>
      <artifactId>log4j-api</artifactId>
      <version>${log4j2.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.apache.logging.log4j</groupId>
      <artifactId>log4j-core</artifactId>
      <version>${log4j2.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.apache.logging.log4j</groupId>
      <artifactId>log4j-slf4j-impl</artifactId>
      <version>${log4j2.version}</version>
      <scope>test</scope>
    </dependency>

  </dependencies>

  <build>
    <extensions>
      <extension>
        <groupId>kr.motd.maven</groupId>
        <artifactId>os-maven-plugin</artifactId>
        <version>${os-maven-plugin.version}</version>
      </extension>
    </extensions>
    <plugins>
      <plugin>
        <groupId>org.xolstice.maven.plugins</groupId>
        <artifactId>protobuf-maven-plugin</artifactId>
        <version>${protobuf-maven-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>
        </configuration>
        <executions>
          <execution>
            <goals>
              <goal>compile</goal>
              <goal>compile-custom</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>build-helper-maven-plugin</artifactId>
        <version>${build-helper-maven-plugin.version}</version>
        <executions>
          <execution>
            <id>test</id>
            <phase>generate-sources</phase>
            <goals>
              <goal>add-source</goal>
            </goals>
            <configuration>
              <sources>
                <source>${basedir}/target/generated-sources</source>
              </sources>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>${maven-compiler-plugin.version}</version>
        <extensions>true</extensions>
        <configuration>
          <source>${jdk.version}</source>
          <target>${jdk.version}</target>
          <encoding>UTF-8</encoding>
          <compilerArgs>
            <arg>-Xlint:all</arg>
          </compilerArgs>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-resources-plugin</artifactId>
        <version>${maven-resources-plugin.version}</version>
        <configuration>
          <encoding>UTF-8</encoding>
        </configuration>
      </plugin>
      <!--
          generate maven dependencies versions file that can be used later
          to install the right bundle in test phase.

          The file is:

              target/classes/META-INF/maven/dependencies.properties
      -->
      <plugin>
        <groupId>org.apache.servicemix.tooling</groupId>
        <artifactId>depends-maven-plugin</artifactId>
        <version>${depends-maven-plugin.version}</version>
        <executions>
          <execution>
            <id>generate-depends-file</id>
            <goals>
              <goal>generate-depends-file</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.felix</groupId>
        <artifactId>maven-bundle-plugin</artifactId>
        <version>${maven-bundle-plugin.version}</version>
        <extensions>true</extensions>
        <configuration>
          <instructions>
            <Bundle-SymbolicName>${project.groupId}.${project.artifactId}
            </Bundle-SymbolicName>
            <Bundle-Name>lburgazzoli :: ${project.artifactId}</Bundle-Name>
            <Export-Package>com.github.lburgazzoli.etcd.v3.*;-noimport:=true
            </Export-Package>
          </instructions>
        </configuration>
        <executions>
          <!--
            This execution makes sure that the manifest is available
            when the tests are executed
          -->
          <execution>
            <goals>
              <goal>manifest</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

  <profiles>

    <profile>
      <id>disable-java8-doclint</id>
      <activation>
        <jdk>[1.8,)</jdk>
      </activation>
      <properties>
        <additionalparam>-Xdoclint:none</additionalparam>
      </properties>
    </profile>

    <profile>
      <id>integration</id>
      <activation>
        <activeByDefault>false</activeByDefault>
      </activation>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-failsafe-plugin</artifactId>
            <version>${maven-failsafe-plugin.version}</version>
            <executions>
              <execution>
                <goals>
                  <goal>integration-test</goal>
                  <goal>verify</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>

    <profile>
      <id>docker</id>
      <activation>
        <activeByDefault>false</activeByDefault>
      </activation>
      <build>
        <plugins>
          <plugin>
            <groupId>io.fabric8</groupId>
            <artifactId>docker-maven-plugin</artifactId>
            <version>${docker-maven-plugin.version}</version>
            <executions>
              <execution>
                <id>start</id>
                <phase>pre-integration-test</phase>
                <goals>
                  <goal>start</goal>
                </goals>
                <configuration>
                  <showLogs>true</showLogs>
                  <images>
                    <image>
                      <name>quay.io/coreos/etcd:v${etcd.version.major}.${etcd.version.minor}.${etcd.version.build}</name>
                      <alias>etcd</alias>
                      <run>
                        <ports>
                          <port>+etcd.ip:etcd.port:2379</port>
                        </ports>
                        <wait>
                          <log>embed: ready to serve client requests</log>
                          <time>20000</time>
                        </wait>
                        <cmd>
                          <exec>
                            <arg>etcd</arg>
                            <arg>-name</arg>
                            <arg>etcd4j</arg>
                            <arg>-advertise-client-urls</arg>
                            <arg>http://127.0.0.1:2379</arg>
                            <arg>-listen-client-urls</arg>
                            <arg>http://0.0.0.0:2379</arg>
                          </exec>
                        </cmd>
                      </run>
                    </image>
                  </images>
                </configuration>
              </execution>
              <execution>
                <id>stop</id>
                <phase>post-integration-test</phase>
                <goals>
                  <goal>stop</goal>
                </goals>
                <configuration>
                  <allContainers>true</allContainers>
                </configuration>
              </execution>
            </executions>
          </plugin>

          <!--
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>${maven-surefire-plugin.version}</version>
            <configuration>
              <skipTests>true</skipTests>
            </configuration>
          </plugin>
          -->

          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-failsafe-plugin</artifactId>
            <version>${maven-failsafe-plugin.version}</version>
            <executions>
              <execution>
                <goals>
                  <goal>integration-test</goal>
                  <goal>verify</goal>
                </goals>
              </execution>
            </executions>
            <configuration>
              <systemProperties>
                <test.etcd.endpoints>${etcd.ip}:${etcd.port}:</test.etcd.endpoints>
              </systemProperties>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>

    <profile>
      <id>proto</id>
      <activation>
        <activeByDefault>false</activeByDefault>
      </activation>
      <build>
        <plugins>
          <plugin>
            <groupId>com.googlecode.maven-download-plugin</groupId>
            <artifactId>download-maven-plugin</artifactId>
            <version>${download-maven-plugin.version}</version>
            <executions>
              <execution>
                <id>get-proto-rpc</id>
                <phase>generate-resources</phase>
                <goals>
                  <goal>wget</goal>
                </goals>
                <configuration>
                  <url>https://raw.githubusercontent.com/coreos/etcd/release-${etcd.version.major}.${etcd.version.minor}/etcdserver/etcdserverpb/rpc.proto</url>
                  <outputDirectory>${project.basedir}/src/main/proto</outputDirectory>
                </configuration>
              </execution>
              <execution>
                <id>get-proto-kv</id>
                <phase>generate-resources</phase>
                <goals>
                  <goal>wget</goal>
                </goals>
                <configuration>
                  <url>https://raw.githubusercontent.com/coreos/etcd/release-${etcd.version.major}.${etcd.version.minor}/mvcc/mvccpb/kv.proto</url>
                  <outputDirectory>${project.basedir}/src/main/proto</outputDirectory>
                </configuration>
              </execution>
              <execution>
                <id>get-proto-auth</id>
                <phase>generate-resources</phase>
                <goals>
                  <goal>wget</goal>
                </goals>
                <configuration>
                  <url>https://raw.githubusercontent.com/coreos/etcd/release-${etcd.version.major}.${etcd.version.minor}/auth/authpb/auth.proto</url>
                  <outputDirectory>${project.basedir}/src/main/proto</outputDirectory>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>

    <profile>
      <id>release</id>
      <activation>
        <activeByDefault>false</activeByDefault>
      </activation><build>
        <plugins>

          <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-javadoc-plugin</artifactId>
            <version>${maven-javadoc-plugin.version}</version>
            <configuration>
              <aggregate>true</aggregate>
              <encoding>UTF-8</encoding>
              <excludePackageNames>*.protobuf.*</excludePackageNames>
            </configuration>
            <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>${maven-gpg-plugin.version}</version>
            <executions>
              <execution>
                <id>sign-artifacts</id>
                <phase>verify</phase>
                <goals>
                  <goal>sign</goal>
                </goals>
              </execution>
            </executions>
          </plugin>

          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-release-plugin</artifactId>
            <version>${maven-release-plugin.version}</version>
            <configuration>
              <useReleaseProfile>false</useReleaseProfile>
              <releaseProfiles>release</releaseProfiles>
              <goals>deploy</goals>
            </configuration>
          </plugin>

          <plugin>
            <groupId>org.sonatype.plugins</groupId>
            <artifactId>nexus-staging-maven-plugin</artifactId>
            <version>${nexus-staging-maven-plugin.version}</version>
            <extensions>true</extensions>
            <configuration>
              <serverId>ossrh</serverId>
              <nexusUrl>https://oss.sonatype.org/</nexusUrl>
              <autoReleaseAfterClose>true</autoReleaseAfterClose>
            </configuration>
          </plugin>
        </plugins>
      </build>

    </profile>

  </profiles>

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

</project>
