<!--
  ~ 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/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <parent>
    <groupId>com.azure</groupId>
    <artifactId>azure-client-sdk-parent</artifactId>
    <version>1.7.0</version> <!-- {x-version-update;com.azure:azure-client-sdk-parent;current} -->
    <relativePath>../../parents/azure-client-sdk-parent</relativePath>
  </parent>

  <groupId>com.azure</groupId>
  <artifactId>azure-xml</artifactId>
  <packaging>jar</packaging>
  <version>1.2.0</version> <!-- {x-version-update;com.azure:azure-xml;current} -->

  <name>Microsoft Azure Java XML Library</name>
  <description>This package provides interfaces for reading and writing XML.</description>
  <url>https://github.com/Azure/azure-sdk-for-java</url>

  <licenses>
    <license>
      <name>The MIT License (MIT)</name>
      <url>http://opensource.org/licenses/MIT</url>
      <distribution>repo</distribution>
    </license>
  </licenses>

  <distributionManagement>
    <site>
      <id>azure-java-build-docs</id>
      <url>${site.url}/site/${project.artifactId}</url>
    </site>
  </distributionManagement>

  <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>scm:git:https://github.com/Azure/azure-sdk-for-java.git</developerConnection>
  </scm>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <legal><![CDATA[[INFO] Any downloads listed may be third party software.  Microsoft grants you no rights for third party software.]]></legal>

    <javaModulesSurefireArgLine>
      --add-opens com.azure.xml/com.azure.xml=ALL-UNNAMED
      --add-opens com.azure.xml/com.azure.xml.contract=ALL-UNNAMED
    </javaModulesSurefireArgLine>

    <javadoc.excludePackageNames/>
    <javadoc.sourcepath>${basedir}/src/main/java</javadoc.sourcepath>

    <compiler.failondeprecatedstatus></compiler.failondeprecatedstatus>

    <!-- Ignore shaded code -->
    <checkstyle.excludes>**/aalto/**/*.java,**/stax2/**/*.java</checkstyle.excludes>

    <checkstyle.suppressionsLocation>checkstyle-suppressions.xml</checkstyle.suppressionsLocation>

    <spotbugs.skip>false</spotbugs.skip>
    <spotbugs.excludeFilterFile>spotbugs-exclude.xml</spotbugs.excludeFilterFile>
    <spotbugs.excludes>**/aalto/**/*.java,**/stax2/**/*.java</spotbugs.excludes>
  </properties>

  <developers>
    <developer>
      <id>microsoft</id>
      <name>Microsoft</name>
    </developer>
  </developers>

  <dependencies>
    <dependency>
      <groupId>org.junit.jupiter</groupId>
      <artifactId>junit-jupiter-api</artifactId>
      <version>5.11.2</version> <!-- {x-version-update;org.junit.jupiter:junit-jupiter-api;external_dependency} -->
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.junit.jupiter</groupId>
      <artifactId>junit-jupiter-engine</artifactId>
      <version>5.11.2</version> <!-- {x-version-update;org.junit.jupiter:junit-jupiter-engine;external_dependency} -->
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.junit.jupiter</groupId>
      <artifactId>junit-jupiter-params</artifactId>
      <version>5.11.2</version> <!-- {x-version-update;org.junit.jupiter:junit-jupiter-params;external_dependency} -->
      <scope>test</scope>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <!-- Xml*ContractTests is inherited by tests in azure-xml-* -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>
        <version>3.4.2</version> <!-- {x-version-update;org.apache.maven.plugins:maven-jar-plugin;external_dependency} -->
        <executions>
          <execution>
            <id>test-jar</id>
            <phase>test-compile</phase>
            <goals>
              <goal>test-jar</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>4.8.3.1</version> <!-- {x-version-update;com.github.spotbugs:spotbugs-maven-plugin;external_dependency} -->
        <configuration>
          <plugins>
            <plugin>
              <groupId>com.h3xstream.findsecbugs</groupId>
              <artifactId>findsecbugs-plugin</artifactId>
              <version>1.9.0</version> <!-- {x-version-update;com.h3xstream.findsecbugs:findsecbugs-plugin;external_dependency} -->
            </plugin>
          </plugins>
        </configuration>
      </plugin>

      <plugin>
        <groupId>com.azure.tools</groupId>
        <artifactId>codesnippet-maven-plugin</artifactId>
        <version>1.0.0-beta.10</version> <!-- {x-version-update;com.azure.tools:codesnippet-maven-plugin;external_dependency} -->
        <configuration>
          <additionalCodesnippets>
            <additionalCodesnippet>
              <root>src/test</root>
              <glob>**/*.java</glob>
            </additionalCodesnippet>
          </additionalCodesnippets>
        </configuration>
      </plugin>

      <plugin>
        <groupId>org.jacoco</groupId>
        <artifactId>jacoco-maven-plugin</artifactId>
        <version>0.8.12</version> <!-- {x-version-update;org.jacoco:jacoco-maven-plugin;external_dependency} -->
        <configuration>
          <excludes>
            <exclude>META-INF/**</exclude>
            <exclude>**/com/azure/xml/implementation/aalto/**</exclude>
            <exclude>**/com/azure/xml/implementation/stax2/**</exclude>
          </excludes>
        </configuration>
      </plugin>
    </plugins>
  </build>

  <profiles>
    <!-- This profile is used to generate a sources JAR with stax2-api and aalto-xml shaded into com.azure.xml.implementation.aalto / stax2 -->
    <!-- DO NOT run this profile with release, it is only meant to be run locally when the shaded stax2-api and aalto-xml code needs to be updated. -->
    <!-- -->
    <!-- To update the shaded stax2-api and aalto-xml code, run Maven build with '-Dshade-aalto-xml' included in the command. -->
    <!-- In the target folder, extract the sources azure-xml JAR, the path com/azure/xml/implementation/aalto / stax2 will contain the stax2-api and aalto-xml source code. -->
    <!-- Copy this code into the com.azure.xml.implementation.aalto / stax2 package in the azure-xml project and overwrite the existing files. -->
    <!-- -->
    <!-- After following the steps above the project should be rebuilt with the 'add-license-comment' profile enable to add a comment about the shaded code's license. -->
    <!-- This serves as another way to attribute the shaded code to Stax2 and Aalto XML. -->
    <profile>
      <id>shade-aalto-xml</id>
      <activation>
        <property>
          <name>shade-aalto-xml</name>
        </property>
      </activation>

      <dependencies>
        <dependency>
          <groupId>org.codehaus.woodstox</groupId>
          <artifactId>stax2-api</artifactId>
          <version>4.2.2</version> <!-- {x-version-update;org.codehaus.woodstox:stax2-api;external_dependency} -->
        </dependency>

        <dependency>
          <groupId>com.fasterxml</groupId>
          <artifactId>aalto-xml</artifactId>
          <version>1.3.3</version> <!-- {x-version-update;com.fasterxml:aalto-xml;external_dependency} -->
        </dependency>
      </dependencies>

      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-shade-plugin</artifactId>
            <version>3.6.0</version> <!-- {x-version-update;org.apache.maven.plugins:maven-shade-plugin;external_dependency} -->

            <executions>
              <execution>
                <id>shade</id>
                <phase>package</phase>
                <goals>
                  <goal>shade</goal>
                </goals>
              </execution>
            </executions>

            <configuration>
              <createSourcesJar>true</createSourcesJar>
              <shadeSourcesContent>true</shadeSourcesContent>

              <artifactSet>
                <includes>
                  <include>org.codehaus.woodstox:stax2-api</include>
                  <include>com.fasterxml:aalto-xml</include>
                </includes>
              </artifactSet>

              <relocations>
                <relocation>
                  <pattern>com.fasterxml.aalto</pattern>
                  <shadedPattern>com.azure.xml.implementation.aalto</shadedPattern>
                </relocation>
                <relocation>
                  <pattern>org.codehaus.stax2</pattern>
                  <shadedPattern>com.azure.xml.implementation.stax2</shadedPattern>
                </relocation>
              </relocations>
            </configuration>
          </plugin>

          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-enforcer-plugin</artifactId>
            <version>3.5.0</version> <!-- {x-version-update;org.apache.maven.plugins:maven-enforcer-plugin;external_dependency} -->
            <configuration>
              <rules>
                <bannedDependencies>
                  <includes>
                    <include>org.codehaus.woodstox:stax2-api:[4.2.2]</include> <!-- {x-include-update;org.codehaus.woodstox:stax2-api;external_dependency} -->
                    <include>com.fasterxml:aalto-xml:[1.3.3]</include> <!-- {x-include-update;com.fasterxml:aalto-xml;external_dependency} -->
                  </includes>
                </bannedDependencies>
              </rules>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>

    <!-- This profile runs a script that adds a code comment to each shaded file attributing the shaded code back to the Aalto XML and Stax2 project. -->
    <!-- This profile must be run after every time the 'shade-aalto-xml' profile is ran and the steps to copy the shaded source code is followed. -->
    <profile>
      <id>add-license-comment</id>
      <activation>
        <property>
          <name>add-license-comment</name>
        </property>
      </activation>

      <build>
        <plugins>
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>exec-maven-plugin</artifactId>
            <version>3.4.1</version> <!-- {x-version-update;org.codehaus.mojo:exec-maven-plugin;external_dependency} -->
            <executions>
              <execution>
                <id>add-license-comment</id>
                <phase>process-sources</phase>
                <goals>
                  <goal>exec</goal>
                </goals>
                <configuration>
                  <executable>python</executable>
                  <workingDirectory>${project.basedir}</workingDirectory>
                  <arguments>
                    <argument>${project.basedir}/add-shaded-code-comment.py</argument>
                  </arguments>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>
</project>
