<?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.azure.tools</groupId>
  <artifactId>azure-autorest-parent</artifactId>
  <version>1.0.0-beta.2</version>
  <packaging>pom</packaging>

  <name>Microsoft Azure AutoRest for Java</name>
  <description>This is the parent pom for Microsoft Azure AutoRest for Java.</description>
  <url>https://github.com/Azure/autorest.java</url>

  <licenses>
    <license>
      <name>The MIT License (MIT)</name>
      <url>http://opensource.org/licenses/MIT</url>
      <distribution>repo</distribution>
    </license>
  </licenses>

  <organization>
    <name>Microsoft Corporation</name>
    <url>http://microsoft.com</url>
  </organization>

  <developers>
    <developer>
      <id>microsoft</id>
      <name>Microsoft Corporation</name>
    </developer>
  </developers>

  <scm>
    <url>https://github.com/Azure/autorest.java</url>
    <connection>scm:git:https://github.com/Azure/autorest.java.git</connection>
    <developerConnection/>
    <tag>HEAD</tag>
  </scm>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <packageOutputDirectory>${project.build.directory}</packageOutputDirectory>
    <checkstyle.skip>false</checkstyle.skip>
    <codesnippet.skip>true</codesnippet.skip>

    <!-- This property configures whether PLAYBACK tests are ran in parallel. Default is true. -->
    <parallelizeTests>true</parallelizeTests>
  </properties>

  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>com.github.briandilley.jsonrpc4j</groupId>
        <artifactId>jsonrpc4j</artifactId>
        <version>1.5.3</version>
      </dependency>
    </dependencies>
  </dependencyManagement>

  <build>
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-clean-plugin</artifactId>
          <version>3.2.0</version>
        </plugin>

        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-jar-plugin</artifactId>
          <version>3.2.2</version>
        </plugin>

        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-resources-plugin</artifactId>
          <version>3.2.0</version>
        </plugin>

        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-install-plugin</artifactId>
          <version>3.0.0-M1</version>
        </plugin>

        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-assembly-plugin</artifactId>
          <version>3.3.0</version>
        </plugin>

        <!-- This plugin runs tests -->
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-surefire-plugin</artifactId>
          <version>3.0.0-M5</version>
          <configuration>
            <includes>
              <include>**/*Tests.java</include>
            </includes>
            <runOrder>alphabetical</runOrder>
            <useSystemClassLoader>false</useSystemClassLoader>
            <systemPropertyVariables combine.children="append">
              <jacoco-agent.destfile>${project.build.directory}/jacoco.exec</jacoco-agent.destfile>
              <junit.jupiter.extensions.autodetection.enabled>true</junit.jupiter.extensions.autodetection.enabled>
            </systemPropertyVariables>
            <forkCount>1</forkCount>
            <testFailureIgnore>false</testFailureIgnore>
          </configuration>
          <dependencies>
            <!-- This dependency is required until maven-surefire-plugin updates the version they use. -->
            <!-- The current dependency version doesn't support Java 17. -->
            <dependency>
              <groupId>org.ow2.asm</groupId>
              <artifactId>asm</artifactId>
              <version>9.1</version> <!-- {x-version-update;org.ow2.asm:asm;external_dependency} -->
            </dependency>
          </dependencies>
        </plugin>

        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-compiler-plugin</artifactId>
          <version>3.10.1</version>
          <configuration>
            <source>1.8</source>
            <target>1.8</target>
          </configuration>
        </plugin>

        <plugin>
          <groupId>com.azure.tools</groupId>
          <artifactId>codesnippet-maven-plugin</artifactId>
          <version>1.0.0-beta.7</version>
          <configuration>
            <skip>${codesnippet.skip}</skip>
          </configuration>
        </plugin>

        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-javadoc-plugin</artifactId>
          <version>3.4.0</version>
          <configuration>
            <source>1.8</source>
            <detectJavaApiLink>false</detectJavaApiLink>
            <quiet>true</quiet>
          </configuration>
        </plugin>

        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-checkstyle-plugin</artifactId>
          <version>3.1.2</version>
          <dependencies>
            <dependency>
              <groupId>com.puppycrawl.tools</groupId>
              <artifactId>checkstyle</artifactId>
              <version>9.2</version>
            </dependency>
          </dependencies>
          <configuration>
            <skip>${checkstyle.skip}</skip>
            <configLocation>checkstyle.xml</configLocation>
            <suppressionsLocation>checkstyle-suppressions.xml</suppressionsLocation>
            <propertyExpansion>samedir=</propertyExpansion>
            <encoding>UTF-8</encoding>
            <consoleOutput>true</consoleOutput>
            <includeTestSourceDirectory>true</includeTestSourceDirectory>
            <linkXRef>true</linkXRef>
            <failsOnError>true</failsOnError>
            <failOnViolation>true</failOnViolation>
          </configuration>
        </plugin>
      </plugins>
    </pluginManagement>

    <plugins>
      <plugin>
        <groupId>com.azure.tools</groupId>
        <artifactId>codesnippet-maven-plugin</artifactId>
        <version>1.0.0-beta.7</version>
        <executions>
          <execution>
            <id>update-codesnippets</id>
            <goals>
              <goal>update-codesnippet</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-javadoc-plugin</artifactId>
        <version>3.4.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-checkstyle-plugin</artifactId>
        <version>3.1.2</version>
        <executions>
          <execution>
            <phase>verify</phase>
            <goals>
              <goal>check</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-source-plugin</artifactId>
        <version>3.2.1</version>
        <configuration>
          <outputDirectory>${packageOutputDirectory}</outputDirectory>
        </configuration>
        <executions>
          <execution>
            <id>attach-sources</id>
            <goals>
              <goal>jar</goal>
            </goals>
            <phase>package</phase>
          </execution>
        </executions>
      </plugin>

      <!-- Copy the pom file to output -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-antrun-plugin</artifactId>
        <version>1.8</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>

      <!-- This plugin adds sample code as tests for easier editing in IDEs -->
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>build-helper-maven-plugin</artifactId>
        <version>3.0.0</version>
        <executions>
          <execution>
            <id>compile-samples-source</id>
            <phase>generate-test-sources</phase>
            <goals>
              <goal>add-test-source</goal>
            </goals>
            <configuration>
              <sources>
                <source>src/samples/java</source>
              </sources>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

  <modules>
    <module>./javagen</module>
    <module>./preprocessor</module>
    <module>./postprocessor</module>
    <module>./customization-base</module>
    <module>./customization-tests</module>
    <module>./extension-base</module>
    <module>./fluentgen</module>
    <module>./fluentnamer</module>
    <module>./androidgen</module>
  </modules>

  <profiles>
    <profile>
      <id>local</id>
      <activation>
        <property>
          <name>local</name>
        </property>
      </activation>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>3.0.0-M5</version>
            <configuration>
              <systemPropertyVariables combine.children="append">
                <jacoco-agent.destfile>${project.build.directory}/jacoco.exec</jacoco-agent.destfile>
              </systemPropertyVariables>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
    <profile>
      <id>testProtocol</id>
      <activation>
        <property>
          <name>testProtocol</name>
        </property>
      </activation>
      <modules>
        <module>./protocol-tests</module>
        <module>./protocol-resilience-test</module>
        <module>./partial-update-tests</module>
      </modules>
    </profile>
    <profile>
      <id>testVanilla</id>
      <activation>
        <property>
          <name>testVanilla</name>
        </property>
      </activation>
      <modules>
        <module>./vanilla-tests</module>
      </modules>
    </profile>
    <profile>
      <id>testAzure</id>
      <activation>
        <property>
          <name>testAzure</name>
        </property>
      </activation>
      <modules>
        <module>./azure-tests</module>
      </modules>
    </profile>
    <profile>
      <id>testFluent</id>
      <activation>
        <property>
          <name>testFluent</name>
        </property>
      </activation>
      <modules>
        <module>./fluent-tests</module>
      </modules>
    </profile>
  </profiles>

</project>
