<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.eclipse.hono</groupId>
    <artifactId>hono-adapters</artifactId>
    <version>0.5-M2</version>
  </parent>
  <artifactId>hono-adapter-mqtt-vertx</artifactId>
  <name>Hono MQTT Adapter</name>

  <dependencies>
    <dependency>
      <groupId>io.vertx</groupId>
      <artifactId>vertx-mqtt-server</artifactId>
      <version>${vertx-mqtt.version}</version>
    </dependency>
    <dependency>
      <groupId>org.eclipse.hono</groupId>
      <artifactId>hono-client</artifactId>
    </dependency>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot</artifactId>
    </dependency>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-autoconfigure</artifactId>
    </dependency>
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-api</artifactId>
    </dependency>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-logging</artifactId>
      <scope>runtime</scope>
    </dependency>
    <dependency>
      <groupId>org.eclipse.hono</groupId>
      <artifactId>hono-legal</artifactId>
    </dependency>
  </dependencies>

  <repositories>
    <repository>
      <id>oss.sonatype.org-snapshot</id>
      <url>https://oss.sonatype.org/content/repositories/snapshots</url>
    </repository>
  </repositories>

  <build>
    <plugins>
      <plugin>
        <!-- Copy legal documents from "legal" module to "target/classes" folder so that we make sure to include 
          legal docs in all modules. -->
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
      </plugin>
    </plugins>
  </build>

  <profiles>
    <profile>
      <id>build-docker-image</id>
      <activation>
        <property>
          <name>docker.host</name>
        </property>
      </activation>
      <build>
        <plugins>
          <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
          </plugin>
          <plugin>
            <groupId>io.fabric8</groupId>
            <artifactId>docker-maven-plugin</artifactId>
            <configuration>
              <verbose>true</verbose>
              <images>
                <image>
                  <build>
                    <from>anapsix/alpine-java:8</from>
                    <ports>
                      <port>1883</port>
                    </ports>
                    <runCmds>
                      <runCmd>adduser -S -D hono nogroup</runCmd>
                    </runCmds>
                    <user>hono</user>
                    <workdir>/home/hono</workdir>
                    <cmd>
                      <exec>
                        <arg>java</arg>
                        <arg>-Dvertx.disableDnsResolver=true</arg>
                        <arg>-Dnetworkaddress.cache.ttl=0</arg>
                        <arg>-Dnetworkaddress.cache.negative.ttl=0</arg>
                        <arg>-jar</arg>
                        <arg>
                          /opt/hono/${project.artifactId}-${project.version}.jar
                        </arg>
                      </exec>
                    </cmd>
                    <assembly>
                      <basedir>/opt/hono</basedir>
                      <descriptorRef>artifact</descriptorRef>
                    </assembly>
                  </build>
                </image>
              </images>
            </configuration>
            <executions>
              <execution>
                <phase>package</phase>
                <goals>
                  <goal>build</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>

</project>
