<!-- Copyright (c) Microsoft Corporation. All rights reserved.
     Licensed under the MIT 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>
  <groupId>com.azure</groupId>
  <artifactId>azure-client-sdk-parent</artifactId>
  <packaging>pom</packaging>
  <version>1.1.0</version>

  <name>Microsoft Azure SDK for Java - Client Libraries</name>
  <description>Parent POM for Microsoft Azure SDK for Java</description>
  <url>https://github.com/Azure/azure-sdk-for-java</url>
  <organization>
    <name>Microsoft Corporation</name>
    <url>http://microsoft.com</url>
  </organization>

  <parent>
    <groupId>com.azure</groupId>
    <artifactId>azure-sdk-parent</artifactId>
    <version>1.1.0</version>
    <relativePath>./parent/pom.xml</relativePath>
  </parent>

  <licenses>
    <license>
      <name>The MIT License (MIT)</name>
      <url>http://opensource.org/licenses/MIT</url>
      <distribution>repo</distribution>
    </license>
  </licenses>

  <developers>
    <developer>
      <id>microsoft</id>
      <name>Microsoft Corporation</name>
    </developer>
  </developers>

  <!-- Repositories definitions -->
  <repositories>
    <repository>
      <id>ossrh</id>
      <name>Sonatype Snapshots</name>
      <url>https://oss.sonatype.org/content/repositories/snapshots/</url>
      <layout>default</layout>
      <snapshots>
        <enabled>true</enabled>
        <updatePolicy>daily</updatePolicy>
      </snapshots>
    </repository>
  </repositories>

  <pluginRepositories>
    <pluginRepository>
      <id>ossrh</id>
      <name>Sonatype Snapshots</name>
      <url>https://oss.sonatype.org/content/repositories/snapshots/</url>
      <layout>default</layout>
      <snapshots>
        <enabled>true</enabled>
        <updatePolicy>always</updatePolicy>
      </snapshots>
    </pluginRepository>
  </pluginRepositories>

  <distributionManagement>
    <snapshotRepository>
      <id>ossrh</id>
      <name>Sonatype Snapshots</name>
      <url>https://oss.sonatype.org/content/repositories/snapshots/</url>
      <uniqueVersion>true</uniqueVersion>
      <layout>default</layout>
    </snapshotRepository>
    <site>
      <id>azure-java-build-docs</id>
      <url>${site.url}/site/</url>
    </site>
  </distributionManagement>

  <issueManagement>
    <system>GitHub</system>
    <url>${issues.url}</url>
  </issueManagement>

  <scm>
    <url>https://github.com/Azure/azure-sdk-for-java</url>
    <connection>scm:git:https://github.com/Azure/azure-sdk-for-java.git</connection>
    <developerConnection></developerConnection>
    <tag>HEAD</tag>
  </scm>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <packageOutputDirectory>${project.build.directory}</packageOutputDirectory>
    <legal>
      <![CDATA[[INFO] Any downloads listed may be third party software.  Microsoft grants you no rights for third party software.]]></legal>
    <testMode>playback</testMode>
    <playbackServerPort>11080</playbackServerPort>
    <alternativePlaybackServerPort>11081</alternativePlaybackServerPort>

    <site.url>https://azuresdkartifacts.blob.core.windows.net/azure-sdk-for-java</site.url>
    <issues.url>https://github.com/Azure/azure-sdk-for-java/issues</issues.url>
    <build.context>azure-client-sdk-parent</build.context>
  </properties>

  <build>
    <plugins>
      <!-- This plugin scans checkstyle issues in the code -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-checkstyle-plugin</artifactId>
        <dependencies>
          <dependency>
            <groupId>com.azure</groupId>
            <artifactId>sdk-build-tools</artifactId>
            <version>${sdk-build-tools.version}</version>
          </dependency>
          <dependency>
            <groupId>com.puppycrawl.tools</groupId>
            <artifactId>checkstyle</artifactId>
            <version>${checkstyle.version}</version>
          </dependency>
        </dependencies>
        <configuration>
          <configLocation>checkstyle/checkstyle.xml</configLocation>
          <suppressionsLocation>checkstyle/checkstyle-suppressions.xml</suppressionsLocation>
          <headerLocation>checkstyle/java.header</headerLocation>
          <propertyExpansion>samedir=</propertyExpansion>
          <encoding>UTF-8</encoding>
          <consoleOutput>true</consoleOutput>
          <includeTestSourceDirectory>true</includeTestSourceDirectory>
          <linkXRef>true</linkXRef>

          <!-- TODO soon - enable these failure modes -->
          <failsOnError>false</failsOnError>
          <failOnViolation>false</failOnViolation>
        </configuration>
        <executions>
          <execution>
            <phase>verify</phase>
            <goals>
              <goal>check</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

      <!-- This plugin scans reports spotbugs in the code -->
      <plugin>
        <groupId>com.github.spotbugs</groupId>
        <artifactId>spotbugs-maven-plugin</artifactId>
        <version>${spotbugs.version}</version>
        <dependencies>
          <dependency>
            <groupId>com.azure</groupId>
            <artifactId>sdk-build-tools</artifactId>
            <version>${sdk-build-tools.version}</version>
          </dependency>
        </dependencies>
        <configuration>
          <effort>Max</effort>
          <threshold>Low</threshold>
          <xmlOutput>true</xmlOutput>
          <spotbugsXmlOutputDirectory>${project.build.directory}/spotbugs</spotbugsXmlOutputDirectory>
          <excludeFilterFile>spotbugs/spotbugs-exclude.xml</excludeFilterFile>

          <!-- TODO soon - enable this failure mode -->
          <failOnError>false</failOnError>
        </configuration>
        <executions>
          <execution>
            <phase>verify</phase>
            <goals>
              <goal>check</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

      <!-- This plugin exports spotbugs reports in html form -->
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>xml-maven-plugin</artifactId>
        <version>${xml-maven-plugin.version}</version>
        <executions>
          <execution>
            <phase>verify</phase>
            <goals>
              <goal>transform</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <transformationSets>
            <transformationSet>
              <dir>${project.build.directory}/spotbugs</dir>
              <includes><include>spotbugsXml.xml</include></includes>
              <outputDir>${project.build.directory}/spotbugs</outputDir>
              <stylesheet>fancy-hist.xsl</stylesheet>
              <fileMappers>
                <fileMapper implementation="org.codehaus.plexus.components.io.filemappers.FileExtensionMapper">
                  <targetExtension>.html</targetExtension>
                </fileMapper>
              </fileMappers>
            </transformationSet>
          </transformationSets>
        </configuration>
        <dependencies>
          <dependency>
            <groupId>com.github.spotbugs</groupId>
            <artifactId>spotbugs</artifactId>
            <version>${spotbugs.version}</version>
          </dependency>
        </dependencies>
      </plugin>

      <!-- Configure the jar plugin -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>
        <configuration>
          <outputDirectory>${packageOutputDirectory}</outputDirectory>
        </configuration>
      </plugin>

      <!-- Configure the javadoc plugin -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-javadoc-plugin</artifactId>
        <executions>
          <execution>
            <id>attach-javadocs</id>
            <goals>
              <goal>jar</goal>
            </goals>
            <configuration>
              <jarOutputDirectory>${packageOutputDirectory}</jarOutputDirectory>
              <additionalOptions></additionalOptions>
            </configuration>
          </execution>
        </executions>
      </plugin>

      <!-- Configure the source plugin -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-source-plugin</artifactId>
        <executions>
          <execution>
            <id>attach-sources</id>
            <goals>
              <goal>jar</goal>
            </goals>
            <configuration>
              <outputDirectory>${packageOutputDirectory}</outputDirectory>
            </configuration>
          </execution>
        </executions>
      </plugin>

      <!-- Copy the pom file to output -->
      <plugin>
        <artifactId>maven-antrun-plugin</artifactId>
        <version>${maven-antrun-plugin.version}</version>
        <executions>
          <execution>
            <id>copy</id>
            <phase>package</phase>
            <configuration>
              <target>
                <copy file="${project.pomFile}" tofile="${packageOutputDirectory}/${project.build.finalName}.pom"/>
              </target>
            </configuration>
            <goals>
              <goal>run</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.jacoco</groupId>
        <artifactId>jacoco-maven-plugin</artifactId>
        <version>${jacoco-maven-plugin.version}</version>
        <executions>
          <!--
              Prepares the property pointing to the JaCoCo runtime agent which
              is passed as VM argument when Maven the Surefire plugin is executed.
          -->
          <execution>
            <id>pre-unit-test</id>
            <goals>
              <goal>prepare-agent</goal>
            </goals>
            <configuration>
              <!--Sets the name of the property containing the settings for JaCoCo runtime agent.-->
              <propertyName>surefireArgLine</propertyName>
            </configuration>
          </execution>
          <execution>
            <!-- This generates the unit test reports for individual modules.
              jacoco-test-coverage generates aggregate reports for all modules -->
            <id>post-unit-test</id>
            <phase>test</phase>
            <goals>
              <goal>report</goal>
            </goals>
            <configuration>
              <!-- Sets the output directory for the code coverage report. -->
              <outputDirectory>${project.reporting.outputDirectory}/test-coverage</outputDirectory>
            </configuration>
          </execution>
        </executions>
      </plugin>

      <!-- Allows the sample sources to be built during test-compile phase. -->
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>build-helper-maven-plugin</artifactId>
      </plugin>
    </plugins>

    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-javadoc-plugin</artifactId>
          <configuration>
            <source>8</source>
            <doctitle>Azure SDK for Java Reference Documentation</doctitle>
            <windowtitle>Azure SDK for Java Reference Documentation</windowtitle>
            <failOnError>false</failOnError>
            <footer>Visit the &lt;a href="https://docs.microsoft.com/java/azure/"&gt;Azure for Java Developers&lt;/a&gt;site for more Java documentation, including quick starts, tutorials, and code samples.</footer>
            <linksource>false</linksource>
            <excludePackageNames>
              com.microsoft.azure.template:
              *.impl*:
              *.implementation*:
              com.azure.tracing*:
              com.azure.tools.checkstyle*
            </excludePackageNames>
            <groups>
              <group>
                <title>Azure Core</title>
                <packages>com.azure.core:com.azure.core.annotations:com.azure.core.credentials:com.azure.core.exception:com.azure.core.http*:com.azure.core.configuration:com.azure.core.util*</packages>
              </group>
              <group>
                <title>Azure Core - AMQP</title>
                <packages>com.azure.core.amqp*</packages>
              </group>
              <group>
                <title>Azure Core - Authentication</title>
                <packages>com.azure.core.auth*</packages>
              </group>
              <group>
                <title>Azure Core - Management</title>
                <packages>com.azure.core.management*</packages>
              </group>
              <group>
                <title>Azure Core - Test</title>
                <packages>com.azure.core.test*</packages>
              </group>
              <group>
                <title>Azure App Configuration</title>
                <packages>com.azure.data.appconfiguration*</packages>
              </group>
              <group>
                <title>Azure Event Hubs</title>
                <packages>com.azure.messaging.eventhubs*</packages>
              </group>
              <group>
                <title>Azure Identity</title>
                <packages>com.azure.identity*</packages>
              </group>
              <group>
                <title>Azure Key Vault</title>
                <packages>com.azure.security.keyvault*</packages>
              </group>
            </groups>
            <links>
              <link>https://docs.oracle.com/javase/8/docs/api/</link>
              <link>https://projectreactor.io/docs/core/release/api/</link>
              <link>https://netty.io/4.1/api/</link>
              <link>http://reactivex.io/RxJava/javadoc/</link>
            </links>
            <isOffline>false</isOffline>
            <doclet>org.apidesign.javadoc.codesnippet.Doclet</doclet>
            <docletArtifact>
              <groupId>org.apidesign.javadoc</groupId>
              <artifactId>codesnippet-doclet</artifactId>
              <version>${codesnippet4javadoc.version}</version>
            </docletArtifact>
            <additionalOptions>-maxLineLength 120 -snippetpath ${project.basedir}/src/samples/java</additionalOptions>
            <failOnError>true</failOnError>
            <failOnWarnings>true</failOnWarnings>
          </configuration>
        </plugin>

        <plugin>
          <groupId>com.github.spotbugs</groupId>
          <artifactId>spotbugs-maven-plugin</artifactId>
          <version>${spotbugs.version}</version>
          <dependencies>
            <dependency>
              <groupId>com.azure</groupId>
              <artifactId>sdk-build-tools</artifactId>
              <version>${sdk-build-tools.version}</version>
            </dependency>
          </dependencies>
          <configuration>
            <effort>Max</effort>
            <threshold>Low</threshold>
            <xmlOutput>true</xmlOutput>
            <spotbugsXmlOutputDirectory>${project.build.directory}/spotbugs</spotbugsXmlOutputDirectory>
            <excludeFilterFile>spotbugs/spotbugs-exclude.xml</excludeFilterFile>
            <failOnError>true</failOnError>
          </configuration>
        </plugin>

        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-checkstyle-plugin</artifactId>
          <configuration>
            <failsOnError>true</failsOnError>
            <failOnViolation>true</failOnViolation>
          </configuration>
        </plugin>
      </plugins>
    </pluginManagement>

  </build>

  <reporting>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jxr-plugin</artifactId>
        <version>3.0.0</version>
        <reportSets>
          <reportSet>
            <id>aggregate</id>
            <inherited>false</inherited>
            <reports>
              <report>aggregate</report>
            </reports>
          </reportSet>
        </reportSets>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-checkstyle-plugin</artifactId>
        <version>${maven-checkstyle-plugin.version}</version>
        <configuration>
          <configLocation>checkstyle/checkstyle.xml</configLocation>
          <suppressionsLocation>checkstyle/checkstyle-suppressions.xml</suppressionsLocation>
          <headerLocation>checkstyle/java.header</headerLocation>
          <propertyExpansion>samedir=</propertyExpansion>
          <encoding>UTF-8</encoding>
          <consoleOutput>true</consoleOutput>
          <includeTestSourceDirectory>true</includeTestSourceDirectory>
          <linkXRef>true</linkXRef>
        </configuration>
        <reportSets>
          <reportSet>
            <id>non-aggregate</id>
            <reports>
              <report>checkstyle</report>
            </reports>
          </reportSet>
          <reportSet>
            <id>aggregate</id>
            <inherited>false</inherited>
            <reports>
              <report>checkstyle-aggregate</report>
            </reports>
          </reportSet>
        </reportSets>
      </plugin>
      <plugin>
        <groupId>com.github.spotbugs</groupId>
        <artifactId>spotbugs-maven-plugin</artifactId>
        <version>${spotbugs.version}</version>
        <reportSets>
          <reportSet>
            <id>non-aggregate</id>
            <reports>
              <report>spotbugs</report>
            </reports>
          </reportSet>
          <reportSet>
            <id>aggregate</id>
            <inherited>false</inherited>
            <reports>
              <report>spotbugs</report>
            </reports>
          </reportSet>
        </reportSets>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-javadoc-plugin</artifactId>
        <version>${maven-javadoc.version}</version>
        <reportSets>
          <reportSet>
            <id>non-aggregate</id>
            <reports>
              <report>javadoc</report>
            </reports>
          </reportSet>
          <reportSet>
            <id>aggregate</id>
            <inherited>false</inherited>
            <reports>
              <report>aggregate</report>
            </reports>
            <configuration>
              <!-- codesnippets4javadoc does not support scanning sub-directories and doesn't support wildcards for filepaths.
                  So, path for aggregate reports have to be defined relative to parent pom -->
              <additionalOptions>-maxLineLength 120
                -snippetpath ${project.basedir}/applicationconfig/client/src/samples/java
                -snippetpath ${project.basedir}/core/azure-core/src/samples/java
                -snippetpath ${project.basedir}/eventhubs/client/azure-eventhubs/src/samples/java
                -snippetpath ${project.basedir}/keyvault/client/keys/src/samples/java
                -snippetpath ${project.basedir}/keyvault/client/secrets/src/samples/java
              </additionalOptions>
            </configuration>
          </reportSet>
        </reportSets>
        <configuration>
          <!-- Reporting is run for JDK 11 - https://github.com/Azure/azure-sdk-for-java/blob/master/.azure-pipelines/client.yml#L90
               Disabling failOnWarnings for reporting for now due to CodeSnippets4Java issue reported for JDK 9+
               https://github.com/Azure/azure-sdk-for-java/issues/3851 -->
          <failOnWarnings>false</failOnWarnings>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-project-info-reports-plugin</artifactId>
        <version>3.0.0</version>
        <reportSets>
          <reportSet>
            <reports>
              <report>index</report>
              <report>summary</report>
              <report>dependency-info</report>
              <report>dependency-management</report>
              <report>dependency-convergence</report>
              <report>ci-management</report>
              <report>dependencies</report>
              <report>issue-management</report>
              <report>licenses</report>
              <report>scm</report>
              <report>plugins</report>
              <report>plugin-management</report>
              <report>team</report>
            </reports>
          </reportSet>
        </reportSets>
      </plugin>
    </plugins>
  </reporting>
  <profiles>

    <!--
     By default we build against our baseline, Java 8, but we also want to ensure compatibility
     against the latest Java LTS release, currently Java 11. We therefore have two profiles:
       * The default 'java8', which will perform a build using Java 8 as its target.
       * The non-default 'java-lts' profile, which will build against the current LTS release.
   -->
    <profile>
      <id>java8</id>
      <activation>
        <activeByDefault>true</activeByDefault>
        <property>
          <name>!java-lts</name>
        </property>
      </activation>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>${maven-compiler-plugin.version}</version>
            <configuration>
              <source>1.8</source>
              <target>1.8</target>
              <showWarnings>true</showWarnings>
              <showDeprecation>true</showDeprecation>
              <compilerArgument>-Xlint:all</compilerArgument>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>

    <profile>
      <id>java-lts</id>
      <activation>
        <property>
          <name>java-lts</name>
        </property>
      </activation>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>${maven-compiler-plugin.version}</version>
            <configuration>
              <source>11</source>
              <target>11</target>
              <showWarnings>true</showWarnings>
              <showDeprecation>true</showDeprecation>
              <compilerArgument>-Xlint:all</compilerArgument>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>

    <!-- Customise the javadoc plugin to not include module directories in links. We don't
         currently use modules, so search results were being directed to an 'undefined'
         directory (for an 'undefined' module). This no-module-directories flag fixes
         this, but it is only required for JDK 9+ -->
    <profile>
      <id>javadoc-no-modules-fix</id>
      <activation>
        <jdk>[9,11)</jdk>
      </activation>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-javadoc-plugin</artifactId>
            <configuration>
              <additionalJOption>--no-module-directories</additionalJOption>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>

    <profile>
      <id>javadoc-doclet-compatibility</id>
      <activation>
        <jdk>[9,)</jdk>
      </activation>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-javadoc-plugin</artifactId>
            <configuration>

              <!-- Due to the codesnippet4javadoc tool using backward incompatible javadoc classes, build has
              javadoc warnings. Build failures on javadoc warnings are disabled on JDK 9+ for now.
              Here's the github issue - https://github.com/jtulach/codesnippet4javadoc/issues/14 -->
              <failOnWarnings>false</failOnWarnings>

              <!-- For codesnippet4javadoc tool to work with JDK9+, it is recommended to add this additional option
              https://github.com/jtulach/codesnippet4javadoc#use-with-jdk9 -->
              <additionalJOptions>
                <opt>-J--add-opens=jdk.javadoc/com.sun.tools.javadoc.main=ALL-UNNAMED</opt>
              </additionalJOptions>

            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>

    <profile>
      <id>non-shipping-modules</id>
      <activation>
        <property>
          <name>include-non-shipping-modules</name>
        </property>
      </activation>
      <modules>
        <module>./eng/spotbugs-aggregate-report</module>
        <module>./eng/code-quality-reports</module>
        <module>./eng/jacoco-test-coverage</module>
      </modules>
    </profile>

    <profile>
      <id>template-module</id>
      <activation>
        <property>
          <name>include-template</name>
        </property>
      </activation>
      <modules>
        <module>./sdk/template/azure-sdk-template</module>
      </modules>
    </profile>
  </profiles>

  <modules>
    <module>./appconfiguration/client</module>
    <module>./core</module>
    <module>./eventhubs/client</module>
    <module>./keyvault/client</module>
    <module>./tracing</module>
    <module>./identity/client</module>
  </modules>
</project>
