<?xml version="1.0" encoding="UTF-8"?>
<!--
    Copyright 2016 Yahoo Inc.
    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at
        http://www.apache.org/licenses/LICENSE-2.0
    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
-->
<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/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <parent>
    <groupId>com.yahoo.athenz</groupId>
    <artifactId>athenz</artifactId>
    <version>1.10.62</version>
    <relativePath>../../../pom.xml</relativePath>
  </parent>

  <artifactId>athenz-zpe-java-client</artifactId>
  <packaging>jar</packaging>
  <name>athenz-zpe-java-client</name>
  <description>ZPE Client Library (Java)</description>

  <properties>
    <jmh.version>1.21</jmh.version>
    <uberjar.name>benchmarks</uberjar.name>
    <code.coverage.min>0.8590</code.coverage.min>
  </properties>

  <dependencies>
    <dependency>
      <groupId>${project.groupId}</groupId>
      <artifactId>athenz-zts-core</artifactId>
      <version>${project.parent.version}</version>
    </dependency>
    <dependency>
      <groupId>${project.groupId}</groupId>
      <artifactId>athenz-auth-core</artifactId>
      <version>${project.parent.version}</version>
    </dependency>
    <dependency>
      <groupId>${project.groupId}</groupId>
      <artifactId>athenz-client-common</artifactId>
      <version>${project.parent.version}</version>
    </dependency>
    <dependency>
      <groupId>com.fasterxml.jackson.core</groupId>
      <artifactId>jackson-annotations</artifactId>
      <version>${jackson.version}</version>
    </dependency>
    <dependency>
      <groupId>com.fasterxml.jackson.core</groupId>
      <artifactId>jackson-databind</artifactId>
      <version>${jackson-databind.version}</version>
    </dependency>
    <dependency>
      <groupId>com.google.guava</groupId>
      <artifactId>guava</artifactId>
      <version>${guava.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>commons-io</groupId>
      <artifactId>commons-io</artifactId>
      <version>2.11.0</version>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>${maven-surefire-plugin.version}</version>
        <executions>
          <execution>
            <id>default-test</id>
            <goals>
              <goal>test</goal>
            </goals>
            <configuration>
              <runOrder>alphabetical</runOrder>
              <systemPropertyVariables>
                <athenz.zpe.monitor_timeout_secs>1</athenz.zpe.monitor_timeout_secs>
                <athenz.zpe.cleanup_tokens_secs>1</athenz.zpe.cleanup_tokens_secs>
                <athenz.zpe.policy_dir>src/test/resources/pol_dir</athenz.zpe.policy_dir>
                <athenz.athenz_conf>src/test/resources/athenz.conf</athenz.athenz_conf>
              </systemPropertyVariables>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
  <!-- For the performance test: mvn test -Pperformance-test -->
  <!-- For the remote zts test: mvn test -Premote-zts-test -->
  <!-- For the jmh performance test: automatically activated if Performance.java exists -->
  <profiles>
    <profile>
      <id>jmh-performance-test</id>
      <activation>
        <file>
          <exists>src/main/java/com/yahoo/athenz/zpe/Performance.java</exists>
        </file>
      </activation>
      <dependencies>
        <dependency>
          <groupId>org.openjdk.jmh</groupId>
          <artifactId>jmh-core</artifactId>
          <version>${jmh.version}</version>
        </dependency>
        <dependency>
          <groupId>org.openjdk.jmh</groupId>
          <artifactId>jmh-generator-annprocess</artifactId>
          <version>${jmh.version}</version>
        </dependency>
      </dependencies>
      <build>
        <plugins>
          <!-- setup shade plugin for jmh -->
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-shade-plugin</artifactId>
            <version>${maven-shade-plugin.version}</version>
            <executions>
              <execution>
                <phase>package</phase>
                <goals>
                  <goal>shade</goal>
                </goals>
                <configuration>
                  <finalName>${uberjar.name}</finalName>
                  <transformers>
                    <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                      <mainClass>org.openjdk.jmh.Main</mainClass>
                    </transformer>
                  </transformers>
                  <filters>
                    <filter>
                      <artifact>*:*</artifact>
                      <excludes>
                        <exclude>META-INF/*.SF</exclude>
                        <exclude>META-INF/*.DSA</exclude>
                        <exclude>META-INF/*.RSA</exclude>
                      </excludes>
                    </filter>
                  </filters>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
    <profile>
      <id>jdk11</id>
      <activation>
        <jdk>[11,)</jdk>
      </activation>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>${maven-compiler-plugin.version}</version>
            <executions>
              <execution>
                <id>jdk11</id>
                <goals>
                  <goal>compile</goal>
                </goals>
                <configuration>
                  <release>11</release>
                  <compileSourceRoots>
                    <compileSourceRoot>${project.basedir}/src/main/java11</compileSourceRoot>
                  </compileSourceRoots>
                  <outputDirectory>${project.build.outputDirectory}/META-INF/versions/11</outputDirectory>
                </configuration>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jar-plugin</artifactId>
            <version>${maven-jar-plugin.version}</version>
            <executions>
              <execution>
                <id>default-jar</id>
                <configuration>
                  <archive>
                    <manifestEntries>
                      <Multi-Release>true</Multi-Release>
                    </manifestEntries>
                  </archive>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>

</project>
