<?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>com.groupbyinc</groupId>
    <artifactId>parent</artifactId>
    <version>41</version>
    <relativePath>../pom.xml</relativePath>
  </parent>

  <artifactId>parent-spring</artifactId>
  <version>41</version>
  <packaging>pom</packaging>

  <name>GroupBy - Parent - Spring</name>
  <description>${project.name}</description>

  <properties>
    <spring.boot.version>2.0.4.RELEASE</spring.boot.version>

    <groupbyinc.docker.base.version>1.8</groupbyinc.docker.base.version>
    <groupbyinc.docker.repo>groupbyinc</groupbyinc.docker.repo>
    <groupbyinc.docker.image.name>${groupbyinc.docker.repo}/${project.artifactId}</groupbyinc.docker.image.name>
    <groupbyinc.docker.maintainer>"GroupBy Engineering" &lt;eng@groupbyinc.com&gt;</groupbyinc.docker.maintainer>
    <groupbyinc.docker.java.image>${groupbyinc.docker.repo}/java:${groupbyinc.docker.base.version}</groupbyinc.docker.java.image>

    <repo.upload.retryAttempts>3</repo.upload.retryAttempts>
  </properties>

  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-dependencies</artifactId>
        <version>${spring.boot.version}</version>
        <type>pom</type>
        <scope>import</scope>
        <exclusions>
          <exclusion>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-classic</artifactId>
          </exclusion>
          <exclusion>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-logging</artifactId>
          </exclusion>
        </exclusions>
      </dependency>
    </dependencies>
  </dependencyManagement>

  <dependencies>

    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter</artifactId>
      <exclusions>
        <exclusion>
          <groupId>ch.qos.logback</groupId>
          <artifactId>logback-classic</artifactId>
        </exclusion>
        <exclusion>
          <groupId>org.springframework.boot</groupId>
          <artifactId>spring-boot-starter-logging</artifactId>
        </exclusion>
      </exclusions>
    </dependency>

  </dependencies>

  <build>

    <resources>
      <resource>
        <directory>${basedir}/src/main/resources</directory>
        <filtering>true</filtering>
        <includes>
          <include>**/application*.yml</include>
          <include>**/application*.yaml</include>
          <include>**/application*.properties</include>
        </includes>
      </resource>
      <resource>
        <directory>${basedir}/src/main/resources</directory>
        <excludes>
          <exclude>**/application*.yml</exclude>
          <exclude>**/application*.yaml</exclude>
          <exclude>**/application*.properties</exclude>
        </excludes>
      </resource>
    </resources>

    <pluginManagement>
      <plugins>

        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-deploy-plugin</artifactId>
          <executions>
            <execution>
              <id>default-deploy</id>
              <phase>none</phase>
            </execution>
          </executions>
        </plugin>

        <plugin>
          <groupId>org.springframework.boot</groupId>
          <artifactId>spring-boot-maven-plugin</artifactId>
          <version>${spring.boot.version}</version>
          <executions>
            <execution>
              <goals>
                <goal>repackage</goal>
              </goals>
            </execution>
          </executions>
        </plugin>

        <plugin>
          <groupId>io.fabric8</groupId>
          <artifactId>docker-maven-plugin</artifactId>
          <configuration>
            <verbose>true</verbose>
            <autoPull>always</autoPull>
            <useColor>true</useColor>
            <images>
              <image>
                <name>${groupbyinc.docker.image.name}:${project.version}</name>
                <alias>${project.artifactId}</alias>
                <build>
                  <maintainer>${groupbyinc.docker.maintainer}</maintainer>
                  <from>${groupbyinc.docker.java.image}</from>
                  <assembly>
                    <basedir>/</basedir>
                    <inline>
                      <id>exec-war</id>
                      <files>
                        <file>
                          <source>docker/docker-entrypoint.sh</source>
                          <outputDirectory>/</outputDirectory>
                        </file>
                        <file>
                          <source>${project.build.directory}/${project.build.finalName}.jar</source>
                          <outputDirectory>/</outputDirectory>
                          <destName>${project.artifactId}.jar</destName>
                        </file>
                      </files>
                    </inline>
                  </assembly>
                  <ports>
                    <port>8080</port>
                  </ports>

                  <volumes>
                    <volume>/tmp</volume>
                  </volumes>
                  <cmd>
                    <exec>
                      <arg>/docker-entrypoint.sh</arg>
                    </exec>
                  </cmd>
                </build>
              </image>
            </images>
          </configuration>
        </plugin>


      </plugins>
    </pluginManagement>

    <plugins>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-gpg-plugin</artifactId>
        <inherited>false</inherited>
      </plugin>

      <plugin>
        <groupId>org.sonatype.plugins</groupId>
        <artifactId>nexus-staging-maven-plugin</artifactId>
        <inherited>false</inherited>
      </plugin>

      <plugin>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <configuration>
          <includes>
            <include>**/*Test.java</include>
            <include>**/*IT.java</include>
          </includes>
        </configuration>
      </plugin>
    </plugins>

  </build>

  <profiles>

    <profile>
      <id>build-docker</id>
      <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>
            <executions>
              <execution>
                <id>build-docker-image</id>
                <goals>
                  <goal>build</goal>
                </goals>
                <phase>package</phase>
              </execution>
              <execution>
                <id>push-docker-image</id>
                <goals>
                  <goal>push</goal>
                </goals>
                <phase>deploy</phase>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>

  </profiles>

  <distributionManagement>
    <repository>
      <id>groupby-public</id>
      <name>GroupBy - Public</name>
      <url>https://maven.pkg.github.com/groupby/maven-releases/</url>
    </repository>
    <snapshotRepository>
      <id>groupby-public</id>
      <name>GroupBy - Public</name>
      <url>https://maven.pkg.github.com/groupby/maven-releases/</url>
    </snapshotRepository>
  </distributionManagement>

</project>
