<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.expediagroup</groupId>
    <artifactId>eg-oss-parent</artifactId>
    <version>2.4.1</version>
  </parent>

  <artifactId>drone-fly-parent</artifactId>
  <version>0.0.2</version>
  <inceptionYear>2020</inceptionYear>
  <packaging>pom</packaging>

  <modules>
    <module>drone-fly-core</module>
    <module>drone-fly-app</module>
    <module>drone-fly-integration-tests</module>
  </modules>

  <properties>
    <assertj.version>3.12.2</assertj.version>
    <awaitility.version>3.1.6</awaitility.version>
    <junit.jupiter.version>5.6.0</junit.jupiter.version>
    <mockito.version>2.25.1</mockito.version>
    <springframework.boot.version>2.3.3.RELEASE</springframework.boot.version>
    <springframework.version>5.2.8.RELEASE</springframework.version>
    <logback.version>1.2.3</logback.version>
    <maven.shade.plugin.version>3.2.4</maven.shade.plugin.version>
    <jib.maven.plugin.version>2.5.2</jib.maven.plugin.version>
    <docker.from.image>openjdk</docker.from.image>
    <docker.from.tag>8-jdk</docker.from.tag>
    <docker.from.reference>${docker.from.image}:${docker.from.tag}</docker.from.reference>
    <docker.registry>expediagroup</docker.registry>
    <docker.to.image>${project.artifactId}</docker.to.image>
    <docker.to.reference>${dockerhub.url}/${docker.registry}/${docker.to.image}:${docker.to.tag}</docker.to.reference>
    <docker.to.tag>${project.version}</docker.to.tag>
    <dockerhub.url>docker.io</dockerhub.url>
  </properties>

  <scm>
    <connection>scm:git:https://${GIT_USERNAME}:${GIT_PASSWORD}@github.com/ExpediaGroup/drone-fly.git</connection>
    <developerConnection>scm:git:https://${GIT_USERNAME}:${GIT_PASSWORD}@github.com/ExpediaGroup/drone-fly.git</developerConnection>
    <url>https://github.com/ExpediaGroup/drone-fly</url>
    <tag>drone-fly-parent-0.0.2</tag>
  </scm>

  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-core</artifactId>
        <version>${springframework.version}</version>
      </dependency>
      <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
        <version>${springframework.version}</version>
      </dependency>
      <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-beans</artifactId>
        <version>${springframework.version}</version>
      </dependency>
      <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-aop</artifactId>
        <version>${springframework.version}</version>
      </dependency>
      <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-dependencies</artifactId>
        <version>${springframework.boot.version}</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
      <dependency>
        <groupId>ch.qos.logback</groupId>
        <artifactId>logback-core</artifactId>
        <version>${logback.version}</version>
      </dependency>
      <dependency>
        <groupId>org.awaitility</groupId>
        <artifactId>awaitility</artifactId>
        <version>${awaitility.version}</version>
        <scope>test</scope>
      </dependency>
    </dependencies>
  </dependencyManagement>

  <dependencies>
    <dependency>
      <groupId>org.junit.jupiter</groupId>
      <artifactId>junit-jupiter</artifactId>
      <version>${junit.jupiter.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.mockito</groupId>
      <artifactId>mockito-core</artifactId>
      <version>${mockito.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.mockito</groupId>
      <artifactId>mockito-junit-jupiter</artifactId>
      <version>${mockito.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.assertj</groupId>
      <artifactId>assertj-core</artifactId>
      <version>${assertj.version}</version>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <build>
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>com.google.cloud.tools</groupId>
          <artifactId>jib-maven-plugin</artifactId>
          <version>${jib.maven.plugin.version}</version>
          <executions>
            <execution>
              <id>deploy</id>
              <phase>deploy</phase>
              <goals>
                <goal>build</goal>
              </goals>
            </execution>
            <execution>
              <id>package</id>
              <phase>package</phase>
              <goals>
                <goal>dockerBuild</goal>
              </goals>
            </execution>
          </executions>
          <configuration>
            <from>
              <image>${docker.from.reference}</image>
            </from>
            <to>
              <image>${docker.to.reference}</image>
              <auth>
                <username>${DOCKERHUB_USERNAME}</username>
                <password>${DOCKERHUB_PASSWORD}</password>
              </auth>
            </to>
            <container>
              <creationTime>USE_CURRENT_TIMESTAMP</creationTime>
              <!-- The following port does not matter in K8s -->
              <ports>
                <port>${docker.container.port}</port>
              </ports>
            </container>
          </configuration>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-shade-plugin</artifactId>
          <version>${maven.shade.plugin.version}</version>
        </plugin>
        <plugin>
          <groupId>com.mycila</groupId>
          <artifactId>license-maven-plugin</artifactId>
          <version>${license.maven.plugin.version}</version>
          <configuration>
            <!-- excluding files that don't need a header update -->
            <excludes>
              <exclude>src/main/java/com/expediagroup/dataplatform/dronefly/app/service/ListenerCatalog.java</exclude>
            </excludes>
          </configuration>
        </plugin>
        <plugin>
          <groupId>org.springframework.boot</groupId>
          <artifactId>spring-boot-maven-plugin</artifactId>
          <version>${springframework.boot.version}</version>
          <configuration>
            <mainClass>com.expediagroup.dataplatform.dronefly.app.DroneFly</mainClass>
            <layout>ZIP</layout>
            <requiresUnpack>
              <!-- We are hitting an issue introduced in hive-common-2.1.1 and fixed in https://issues.apache.org/jira/browse/HIVE-17155
                The HiveConf class tries loading conf (e.g. hive-site.xml) from the uberjar and fails. Unpacking it with
                this setting fixes that problem.
              -->
              <dependency>
                <groupId>org.apache.hive</groupId>
                <artifactId>hive-common</artifactId>
              </dependency>
            </requiresUnpack>
            <executable>true</executable>
            <classifier>exec</classifier>
            <excludeGroupIds>org.mortbay.jetty,org.eclipse.jetty,org.eclipse.jetty.aggregate,org.eclipse.jetty.orbit
            </excludeGroupIds>
            <excludes>
              <exclude>
                <groupId>org.codehaus.jettison</groupId>
                <artifactId>jettison</artifactId>
              </exclude>
              <exclude>
                <groupId>javax.servlet</groupId>
                <artifactId>servlet-api</artifactId>
              </exclude>
            </excludes>
          </configuration>
          <executions>
            <execution>
              <goals>
                <goal>repackage</goal>
              </goals>
            </execution>
          </executions>
        </plugin>
      </plugins>
    </pluginManagement>
  </build>
</project>
