<?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>

  <groupId>com.google.cloud.tools</groupId>
  <artifactId>jib-maven-plugin</artifactId>
  <version>1.4.0</version>
  <packaging>maven-plugin</packaging>

  <name>Jib</name>
  <description>A tool for building container images for your Java applications.</description>
  <url>https://github.com/GoogleContainerTools/jib</url>

  <licenses>
    <license>
      <name>The Apache License, Version 2.0</name>
      <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
    </license>
  </licenses>

  <developers>
    <developer>
      <id>coollog</id>
      <name>Qingyang Chen</name>
      <email>qingyangc@google.com</email>
    </developer>
    <developer>
      <id>loosebazooka</id>
      <name>Appu Goundan</name>
      <email>appu@google.com</email>
    </developer>
  </developers>

  <scm>
    <connection>scm:git:https://github.com/GoogleContainerTools/jib.git
    </connection>
    <developerConnection>scm:git:https://github.com/GoogleContainerTools/jib.git
    </developerConnection>
    <url>https://github.com/GoogleContainerTools/jib</url>
  </scm>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <!-- Use <maven.compiler.release> instead when migrating to JDK 11. -->
    <maven.compiler.source>8</maven.compiler.source>
    <maven.compiler.target>8</maven.compiler.target>
  </properties>

  <dependencies>
    <!-- Dependencies from jib-core -->
    <dependency>
      <groupId>com.google.http-client</groupId>
      <artifactId>google-http-client</artifactId>
      <version>1.27.0</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>org.apache.commons</groupId>
      <artifactId>commons-compress</artifactId>
      <version>1.18</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>com.google.guava</groupId>
      <artifactId>guava</artifactId>
      <version>27.0.1-jre</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>com.fasterxml.jackson.core</groupId>
      <artifactId>jackson-databind</artifactId>
      <version>2.9.9</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>org.ow2.asm</groupId>
      <artifactId>asm</artifactId>
      <version>7.0</version>
      <scope>compile</scope>
    </dependency>
    <!-- End dependencies from jib-core -->

    <dependency>
      <groupId>org.apache.maven</groupId>
      <artifactId>maven-plugin-api</artifactId>
      <version>3.5.2</version>
    </dependency>

    <!-- Maven plugin development annotations -->
    <dependency>
      <groupId>org.apache.maven.plugin-tools</groupId>
      <artifactId>maven-plugin-annotations</artifactId>
      <version>3.5</version>
      <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>org.apache.maven</groupId>
      <artifactId>maven-core</artifactId>
      <version>3.5.2</version>
    </dependency>
    <dependency>
      <groupId>org.apache.maven.shared</groupId>
      <artifactId>maven-verifier</artifactId>
      <version>1.6</version>
    </dependency>

    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.12</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.mockito</groupId>
      <artifactId>mockito-core</artifactId>
      <version>2.23.4</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-api</artifactId>
      <version>1.7.25</version>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>org.apache.maven.plugin-testing</groupId>
      <artifactId>maven-plugin-testing-harness</artifactId>
      <version>3.3.0</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.apache.maven</groupId>
      <artifactId>maven-compat</artifactId>
      <version>3.5.4</version>
      <scope>test</scope>
  </dependency>

  </dependencies>

  <profiles>
    <!-- Profile for running integration tests. -->
    <profile>
      <id>integrationTest</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-failsafe-plugin</artifactId>
            <version>2.22.1</version>
            <configuration>
              <classesDirectory>${project.build.directory}/classes</classesDirectory>
              <includes>
                <include>**/*IntegrationTest.java</include>
              </includes>
              <systemPropertyVariables>
                <_JIB_DISABLE_USER_AGENT>true</_JIB_DISABLE_USER_AGENT>
              </systemPropertyVariables>
              <trimStackTrace>false</trimStackTrace>
            </configuration>
            <executions>
              <execution>
                <id>integration-test</id>
                <goals>
                  <goal>integration-test</goal>
                  <goal>verify</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>

    <!-- Profile for releasing. -->
    <profile>
      <id>release</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-javadoc-plugin</artifactId>
            <version>3.0.0</version>
            <executions>
              <execution>
                <id>attach-javadocs</id>
                <goals>
                  <goal>jar</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-source-plugin</artifactId>
            <version>3.0.1</version>
            <executions>
              <execution>
                <id>attach-sources</id>
                <goals>
                  <goal>jar</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>

    <!--
      Using github.com/google/error-prone-javac is required when running on
      JDK 8. Remove when migrating to JDK 11.
    -->
    <profile>
      <id>jdk8</id>
      <activation>
        <jdk>1.8</jdk>
      </activation>
      <properties>
        <javac.version>9+181-r4173-1</javac.version>
      </properties>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
              <fork>true</fork>
              <compilerArgs combine.children="append">
                <arg>-J-Xbootclasspath/p:${settings.localRepository}/com/google/errorprone/javac/${javac.version}/javac-${javac.version}.jar</arg>
              </compilerArgs>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>

  <build>
    <plugins>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>build-helper-maven-plugin</artifactId>
        <version>3.0.0</version>
        <executions>
          <!-- Imports jib-core and jib-plugins-common sources -->
          <execution>
            <id>add-jib-core-sources</id>
            <phase>generate-sources</phase>
            <goals>
              <goal>add-source</goal>
            </goals>
            <configuration>
              <sources>
                <source>${basedir}/../jib-core/src/main/java</source>
                <source>${basedir}/../jib-plugins-common/src/main/java</source>
              </sources>
            </configuration>
          </execution>
          <execution>
            <id>add-jib-core-resources</id>
            <phase>generate-sources</phase>
            <goals>
              <goal>add-resource</goal>
            </goals>
            <configuration>
              <resources>
                <resource>
                  <directory>${basedir}/../jib-core/src/main/resources</directory>
                </resource>
                <resource>
                  <directory>${basedir}/../jib-plugins-common/src/main/resources</directory>
                </resource>
              </resources>
            </configuration>
          </execution>
          <execution>
            <id>add-jib-core-test-sources</id>
            <phase>generate-test-sources</phase>
            <goals>
              <goal>add-test-source</goal>
            </goals>
            <configuration>
              <sources>
                <source>${basedir}/../jib-core/src/test/java</source>
                <source>${basedir}/../jib-plugins-common/src/test/java</source>
              </sources>
            </configuration>
          </execution>
          <execution>
            <id>add-jib-core-test-resources</id>
            <phase>generate-test-sources</phase>
            <goals>
              <goal>add-test-resource</goal>
            </goals>
            <configuration>
              <resources>
                <resource>
                  <directory>${basedir}/../jib-core/src/test/resources</directory>
                </resource>
                <resource>
                  <directory>${basedir}/../jib-plugins-common/src/test/resources</directory>
                </resource>
              </resources>
            </configuration>
          </execution>
          <execution>
            <id>add-jib-core-integration-test-sources</id>
            <phase>generate-test-sources</phase>
            <goals>
              <goal>add-test-source</goal>
            </goals>
            <configuration>
              <sources>
                <source>${basedir}/../jib-core/src/integration-test/java</source>
              </sources>
            </configuration>
          </execution>
          <execution>
            <id>add-jib-core-integration-test-resources</id>
            <phase>generate-test-sources</phase>
            <goals>
              <goal>add-test-resource</goal>
            </goals>
            <configuration>
              <resources>
                <resource>
                  <directory>${basedir}/../jib-core/src/integration-test/resources</directory>
                </resource>
              </resources>
            </configuration>
          </execution>
        </executions>
      </plugin>

      <!-- Error-prone checks -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.8.0</version>
        <executions>
          <execution>
            <id>compile-with-nullaway</id>
            <phase>compile</phase>
            <goals>
              <goal>compile</goal>
            </goals>
            <configuration>
              <!-- Use <release> instead when migrating to JDK 11. -->
              <source>${maven.compiler.source}</source>
              <target>${maven.compiler.target}</target>
              <showDeprecation>true</showDeprecation>
              <showWarnings>true</showWarnings>
              <annotationProcessorPaths>
                <path>
                  <groupId>com.google.errorprone</groupId>
                  <artifactId>error_prone_core</artifactId>
                  <version>2.3.2</version>
                </path>
                <path>
                  <groupId>com.uber.nullaway</groupId>
                  <artifactId>nullaway</artifactId>
                  <version>0.6.4</version>
                </path>
              </annotationProcessorPaths>
              <compilerArgs>
                <arg>-XDcompilePolicy=simple</arg>
                <arg>-Xplugin:ErrorProne -Xep:NullAway:ERROR -XepOpt:NullAway:ExcludedFieldAnnotations=org.apache.maven.plugins.annotations.Component -XepOpt:NullAway:AnnotatedPackages=com.google.cloud.tools</arg>
              </compilerArgs>
            </configuration>
          </execution>
        </executions>
      </plugin>

      <!-- Unit testing -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>2.22.1</version>
        <configuration>
          <excludes>
            <exclude>**/*IntegrationTest.java</exclude>
          </excludes>
          <trimStackTrace>false</trimStackTrace>
        </configuration>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-plugin-plugin</artifactId>
        <version>3.6.0</version>
      </plugin>

      <!-- Google Java Format -->
      <plugin>
        <groupId>com.coveo</groupId>
        <artifactId>fmt-maven-plugin</artifactId>
        <version>2.6.0</version>
        <dependencies>
          <dependency>
            <groupId>com.google.googlejavaformat</groupId>
            <artifactId>google-java-format</artifactId>
            <version>1.6</version>
          </dependency>
        </dependencies>
        <executions>
          <execution>
            <phase>validate</phase>
            <goals>
              <goal>check</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

      <!-- Checkstyle -->
      <plugin>
        <artifactId>maven-checkstyle-plugin</artifactId>
        <version>3.0.0</version>
        <dependencies>
          <dependency>
            <groupId>com.puppycrawl.tools</groupId>
            <artifactId>checkstyle</artifactId>
            <version>8.18</version>
          </dependency>
        </dependencies>
        <configuration>
          <logViolationsToConsole>true</logViolationsToConsole>
          <failOnViolation>true</failOnViolation>
          <violationSeverity>warning</violationSeverity>
          <sourceDirectories>
            <sourceDirectory>{project.build.sourceDirectory}</sourceDirectory>
          </sourceDirectories>
        </configuration>
        <executions>
          <execution>
            <id>google-checks</id>
            <phase>validate</phase>
            <goals>
              <goal>check</goal>
            </goals>
            <configuration>
              <configLocation>config/google-checks-no-indent.xml</configLocation>
            </configuration>
          </execution>
          <execution>
            <id>header-check</id>
            <phase>validate</phase>
            <goals>
              <goal>check</goal>
            </goals>
            <configuration>
              <configLocation>config/checkstyle-header.xml</configLocation>
              <headerLocation>config/header-java.txt</headerLocation>
            </configuration>
          </execution>
        </executions>
      </plugin>

      <!-- Jar -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>
        <version>3.1.0</version>
        <configuration>
          <archive>
            <!-- Necessary for adding version information into the JAR. -->
            <manifest>
              <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
              <addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
            </manifest>
          </archive>
        </configuration>
      </plugin>
    </plugins>
  </build>

</project>
