<?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>io.vertx</groupId>
    <artifactId>vertx-ext-parent</artifactId>
    <version>37</version>
  </parent>

  <artifactId>vertx-mqtt</artifactId>
  <version>3.9.4</version>

  <developers>
    <developer>
      <name>Paolo Patierno</name>
      <email>ppatierno@live.com</email>
      <organization>Red Hat</organization>
      <organizationUrl>http://www.redhat.com</organizationUrl>
    </developer>
  </developers>

  <properties>
    <stack.version>3.9.4</stack.version>
    <junit.version>4.13.1</junit.version>
    <mockito.version>3.3.3</mockito.version>
    <paho.version>1.1.0</paho.version>
    <fabric8-docker-plugin.version>0.21.0</fabric8-docker-plugin.version>

    <!-- Depending on profile property for testing on CI server using broker provided by Eclipse-->
    <mqtt.server.host>mqtt.eclipse.org</mqtt.server.host>
    <mqtt.server.port>1883</mqtt.server.port>
  </properties>

  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>io.vertx</groupId>
        <artifactId>vertx-dependencies</artifactId>
        <version>${stack.version}</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
    </dependencies>
  </dependencyManagement>

  <name>Vert.x MQTT</name>
  <description>Vert.x MQTT reactive client and server</description>

  <dependencies>
    <dependency>
      <groupId>io.netty</groupId>
      <artifactId>netty-common</artifactId>
    </dependency>
    <dependency>
      <groupId>io.netty</groupId>
      <artifactId>netty-transport</artifactId>
    </dependency>
    <dependency>
      <groupId>io.netty</groupId>
      <artifactId>netty-handler</artifactId>
    </dependency>
    <dependency>
      <groupId>io.netty</groupId>
      <artifactId>netty-codec-mqtt</artifactId>
    </dependency>
    <dependency>
      <groupId>io.vertx</groupId>
      <artifactId>vertx-codegen</artifactId>
      <optional>true</optional>
    </dependency>
    <dependency>
      <groupId>io.vertx</groupId>
      <artifactId>vertx-docgen</artifactId>
      <optional>true</optional>
    </dependency>
    <dependency>
      <groupId>io.vertx</groupId>
      <artifactId>vertx-core</artifactId>
    </dependency>

    <!-- Testing -->
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>${junit.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>io.vertx</groupId>
      <artifactId>vertx-unit</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>io.vertx</groupId>
      <artifactId>vertx-core</artifactId>
      <type>test-jar</type>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.eclipse.paho</groupId>
      <artifactId>org.eclipse.paho.client.mqttv3</artifactId>
      <version>${paho.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.mockito</groupId>
      <artifactId>mockito-core</artifactId>
      <version>${mockito.version}</version>
      <scope>test</scope>
    </dependency>
  </dependencies>

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

  <build>
    <plugins>
      <plugin>
        <artifactId>maven-jar-plugin</artifactId>
        <executions>
          <execution>
            <id>default-jar</id>
            <configuration>
              <archive>
                <!-- A manifest containing the OSGi metadata has been generated using the maven-bundle-plugin -->
                <manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
              </archive>
            </configuration>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <groupId>biz.aQute.bnd</groupId>
        <artifactId>bnd-maven-plugin</artifactId>
        <version>3.2.0</version>

        <executions>
          <execution>
            <id>default-bnd-process</id>
            <goals>
              <goal>bnd-process</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <bnd><![CDATA[
          Import-Package: \
            groovy.lang.*;resolution:=optional,\
            org.codehaus.groovy.*;resolution:=optional,\
            kotlin.*;resolution:=optional,\
            io.vertx.groovy.*;resolution:=optional,\
            io.vertx.lang.rxjava.*;resolution:=optional,\
            io.vertx.lang.reactivex.*;resolution:=optional,\
            io.vertx.lang.groovy.*;resolution:=optional,\
            io.vertx.codegen.annotations;resolution:=optional,\
            io.vertx.rx.java;resolution:=optional,\
            io.vertx.rxjava.core.*;resolution:=optional,\
            io.vertx.reactivex;resolution:=optional,\
            io.vertx.reactivex.core.*;resolution:=optional,\
            rx.*;resolution:=optional,\
            io.reactivex.*;resolution:=optional,\
            *
          -exportcontents: !*impl, !examples, *
          ]]></bnd>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <configuration>
          <systemProperties>
            <mqtt.server.host>${mqtt.server.host}</mqtt.server.host>
            <mqtt.server.port>${mqtt.server.port}</mqtt.server.port>
          </systemProperties>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-failsafe-plugin</artifactId>
        <executions>
          <execution>
            <id>run-integration-test</id>
            <goals>
              <goal>integration-test</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <systemProperties>
            <mqtt.server.host>${mqtt.server.host}</mqtt.server.host>
            <mqtt.server.port>${mqtt.server.port}</mqtt.server.port>
          </systemProperties>
        </configuration>
      </plugin>
    </plugins>
  </build>

  <profiles>

    <!-- Profile for testing local testing with docker -->
    <profile>
      <id>local_test</id>
      <properties>
        <mqtt.server.host>localhost</mqtt.server.host>
        <mqtt.server.port>1884</mqtt.server.port>
        <dockerhost>localhost</dockerhost>
      </properties>
      <build>
        <plugins>
          <plugin>
            <groupId>io.fabric8</groupId>
            <artifactId>docker-maven-plugin</artifactId>
            <version>${fabric8-docker-plugin.version}</version>
            <configuration>
              <images>
                <image>
                  <name>ansi/mosquitto</name>
                  <alias>mosquitto</alias>
                  <run>
                    <ports>
                      <port>1884:1883</port>
                    </ports>
                    <wait>
                      <tcp>
                        <host>localhost</host>
                        <mode>mapped</mode>
                        <ports>
                          <port>1883</port>
                        </ports>
                      </tcp>
                      <time>40000</time>
                    </wait>
                  </run>
                </image>
              </images>
            </configuration>
            <executions>
              <execution>
                <id>run</id>
                <phase>pre-integration-test</phase>
                <goals>
                  <goal>start</goal>
                </goals>
              </execution>
              <execution>
                <id>stop</id>
                <phase>post-integration-test</phase>
                <goals>
                  <goal>stop</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>

</project>
