<?xml version="1.0" encoding="UTF-8"?>
<!--
    Copyright (c) 2021 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">
  <parent>
    <artifactId>hono-services</artifactId>
    <groupId>org.eclipse.hono</groupId>
    <version>1.11.2</version>
    <relativePath>..</relativePath>
  </parent>
  <modelVersion>4.0.0</modelVersion>
  <packaging>pom</packaging>
  <artifactId>hono-services-spring</artifactId>

  <name>Hono Services (Spring)</name>
  <description>Defines common dependencies for Spring-based service implementations</description>

  <dependencies>
    <dependency>
      <groupId>org.eclipse.hono</groupId>
      <artifactId>hono-service-base-spring</artifactId>
    </dependency>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-logging</artifactId>
    </dependency>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-actuator-autoconfigure</artifactId>
    </dependency>
    <dependency>
      <groupId>io.opentracing.contrib</groupId>
      <artifactId>opentracing-tracerresolver</artifactId>
    </dependency>
    <dependency>
      <groupId>org.yaml</groupId>
      <artifactId>snakeyaml</artifactId>
    </dependency>
    <dependency>
      <groupId>ch.qos.logback</groupId>
      <artifactId>logback-classic</artifactId>
    </dependency>
    <dependency>
      <groupId>io.netty</groupId>
      <artifactId>netty-transport-native-epoll</artifactId>
      <classifier>linux-x86_64</classifier>
      <scope>runtime</scope>
    </dependency>
    <dependency>
      <groupId>io.netty</groupId>
      <artifactId>netty-transport-native-kqueue</artifactId>
      <classifier>osx-x86_64</classifier>
      <scope>runtime</scope>
    </dependency>
  </dependencies>

  <profiles>
    <profile>
      <id>build-docker-image</id>
      <build>
        <pluginManagement>
          <plugins>
            <plugin>
              <groupId>org.apache.maven.plugins</groupId>
              <artifactId>maven-dependency-plugin</artifactId>
              <executions>
                <execution>
                  <id>copy_libs</id>
                  <phase>prepare-package</phase>
                  <goals>
                    <goal>copy-dependencies</goal>
                  </goals>
                  <configuration>
                    <silent>true</silent>
                    <includeScope>runtime</includeScope>
                    <outputDirectory>${project.build.directory}/rt-libs</outputDirectory>
                  </configuration>
                </execution>
              </executions>
            </plugin>
            <plugin>
              <groupId>io.fabric8</groupId>
              <artifactId>docker-maven-plugin</artifactId>
              <configuration>
                <images>
                  <image>
                    <build>
                      <env>
                        <JAVA_MAJOR_VERSION>${maven.compiler.release}</JAVA_MAJOR_VERSION>
                        <JAVA_APP_NAME>${project.artifactId}</JAVA_APP_NAME>
                        <JAVA_LIB_DIR>/opt/hono/extensions/*</JAVA_LIB_DIR>
                        <!-- use Base64 encoder/decoder that is compatible with vert.x 3 -->
                        <JAVA_OPTIONS>-Dvertx.json.base64=legacy</JAVA_OPTIONS>
                      </env>
                      <entryPoint>
                        <arg>/opt/hono/run-java.sh</arg>
                      </entryPoint>
                      <assembly>
                        <mode>dir</mode>
                        <basedir>/</basedir>
                        <inline>
                          <fileSets>
                            <fileSet>
                              <directory>${project.build.directory}/docker-extra/run-java</directory>
                              <outputDirectory>opt/hono</outputDirectory>
                              <includes>
                                <include>run-java.sh</include>
                              </includes>
                              <fileMode>755</fileMode>
                            </fileSet>
                            <fileSet>
                              <directory>${project.build.directory}/rt-libs</directory>
                              <outputDirectory>opt/hono</outputDirectory>
                              <includes>
                                <include>*.jar</include>
                              </includes>
                            </fileSet>
                            <fileSet>
                              <directory>${project.build.directory}</directory>
                              <outputDirectory>opt/hono</outputDirectory>
                              <includes>
                                <include>${project.artifactId}-${project.version}.jar</include>
                              </includes>
                            </fileSet>
                          </fileSets>
                        </inline>
                      </assembly>
                    </build>
                  </image>
                </images>
              </configuration>
            </plugin>
          </plugins>
        </pluginManagement>
      </build>
    </profile>

  </profiles>
</project>

