<!--
    Copyright (c) 2016, 2019 Contributors to the Eclipse Foundation

    See the NOTICE file(s) distributed with this work for additional
    information regarding copyright ownership.

    This program and the accompanying materials are made available under the
    terms of the Eclipse Public License 2.0 which is available at
    http://www.eclipse.org/legal/epl-2.0

    SPDX-License-Identifier: EPL-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.eclipse.hono</groupId>
        <artifactId>hono-adapters</artifactId>
        <version>1.2.3</version>
    </parent>
    <artifactId>hono-adapter-lora-vertx</artifactId>
    <name>Hono LoRa Adapter</name>

    <description>A protocol adapter for connecting LoRa Backend Services like Kerlink or TTN.</description>
    <url>https://www.eclipse.org/hono</url>

    <dependencies>
        <dependency>
            <groupId>org.eclipse.hono</groupId>
            <artifactId>hono-adapter-http-vertx-base</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
        </dependency>
        <dependency>
            <groupId>io.vertx</groupId>
            <artifactId>vertx-core</artifactId>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-annotations</artifactId>
            <version>${jackson.version}</version>
        </dependency>
        <dependency>
            <groupId>org.hamcrest</groupId>
            <artifactId>hamcrest-core</artifactId>
        </dependency>
    </dependencies>
    
    <build>
        <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
        <plugin>
            <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>io.fabric8</groupId>
                    <artifactId>docker-maven-plugin</artifactId>
                    <configuration>
                    <images>
                        <image>
                            <build>
                            <from>${java-base-image.name}</from>
                                <ports>
                                <port>8080</port>
                                <port>8443</port>
                                <port>${vertx.health.port}</port>
                            </ports>
                            <cmd>
                            <exec>
                                <arg>java</arg>
                                <arg>--illegal-access=permit</arg>
                                <arg>-Dvertx.cacheDirBase=/tmp</arg>
                                <arg>-Dloader.home=/opt/hono</arg>
                                <arg>-Dloader.path=extensions</arg>
                                <arg>-cp</arg>
                                <arg>/opt/hono/${project.artifactId}-${project.version}-${classifier.spring.boot.artifact}.jar</arg>
                                <arg>org.springframework.boot.loader.PropertiesLauncher</arg>
                            </exec>
                            </cmd>
                            <assembly>
                            <mode>dir</mode>
                            <basedir>/</basedir>
                            <inline>
                                <fileSets>
                                <fileSet>
                                    <directory>${project.build.directory}</directory>
                                    <outputDirectory>opt/hono</outputDirectory>
                                    <includes>
                                    <include>${project.artifactId}-${project.version}-${classifier.spring.boot.artifact}.jar</include>
                                    </includes>
                                </fileSet>
                                </fileSets>
                            </inline>
                            </assembly>
                        </build>
                        </image>
                    </images>
                    </configuration>
                </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>docker-push-image</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>io.fabric8</groupId>
                        <artifactId>docker-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>docker-push-image</id>
                                <phase>install</phase>
                                <goals>
                                    <goal>push</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
