<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.carrotsearch.randomizedtesting</groupId>
    <artifactId>randomizedtesting-parent</artifactId>
    <version>2.8.2</version>
    <relativePath>../pom.xml</relativePath>
  </parent>

  <artifactId>junit4-ant</artifactId>
  <name><![CDATA[RandomizedTesting JUnit4 ANT Task]]></name>

  <properties>
    <proguard.java.home>${java.home}</proguard.java.home>
    <proguard.rt.jar>${proguard.java.home}/lib/rt.jar</proguard.rt.jar>
  </properties>

  <dependencies>
    <dependency>
      <groupId>org.apache.ant</groupId>
      <artifactId>ant</artifactId>
      <scope>provided</scope>
    </dependency>
    
    <dependency>
      <groupId>org.apache.ant</groupId>
      <artifactId>ant-junit</artifactId>
      <scope>provided</scope>
    </dependency>

    <!-- Required at runtime -->

    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <type>jar</type>
      <scope>provided</scope>
    </dependency>

    <!-- Embedded into standalone JAR. -->

    <dependency>
      <groupId>com.google.guava</groupId>
      <artifactId>guava</artifactId>
      <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>org.ow2.asm</groupId>
      <artifactId>asm</artifactId>
      <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>com.carrotsearch.thirdparty</groupId>
      <artifactId>simple-xml-safe</artifactId>
      <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>com.carrotsearch.randomizedtesting</groupId>
      <artifactId>randomizedtesting-runner</artifactId>
      <version>${project.version}</version>
      <scope>provided</scope>
    </dependency>
  </dependencies>

  <build>
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-surefire-plugin</artifactId>
          <version>${version.maven-surefire-plugin}</version>

          <configuration>
            <basedir>${project.build.directory}/test-classes</basedir>
            <!-- only include non-integration tests. -->
            <excludes>
              <exclude>**/tests/**</exclude>
              <exclude>**/it/**</exclude>
            </excludes>
          </configuration>

          <!-- Run in the integration tests phase only. -->
          <executions>
            <execution>
              <id>surefire-it</id>
              <phase>integration-test</phase>
              <goals>
                <goal>test</goal>
              </goals>
              <configuration>
                <includes>
                   <include>**/it/Test*.java</include>
                </includes>
                <excludes>
                  <exclude>**/tests/**</exclude>
                </excludes>
                <classesDirectory>${project.build.directory}/dontinclude</classesDirectory>
                <classpathDependencyExcludes>
                    <classpathDependencyExcludes>com.carrotsearch.randomizedtesting:randomizedtesting-runner</classpathDependencyExcludes>
                    <classpathDependencyExcludes>com.google.guava:guava</classpathDependencyExcludes>
                </classpathDependencyExcludes>
              </configuration>
            </execution>
          </executions>
        </plugin>

        <plugin>
          <groupId>org.eclipse.m2e</groupId>
          <artifactId>lifecycle-mapping</artifactId>
          <version>1.0.0</version>
          <configuration>
            <lifecycleMappingMetadata>
              <pluginExecutions>
                <pluginExecution>
                  <pluginExecutionFilter>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-dependency-plugin</artifactId>
                    <versionRange>[1.0.0,)</versionRange>
                    <goals>
                      <goal>copy-dependencies</goal>
                    </goals>
                  </pluginExecutionFilter>
                  <action>
                    <ignore />
                  </action>
                </pluginExecution>
              </pluginExecutions>
            </lifecycleMappingMetadata>
          </configuration>
        </plugin>

        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-javadoc-plugin</artifactId>
          <version>${version.maven-javadoc-plugin}</version>
          <configuration>
            <overview>${basedir}/src/main/java/com/carrotsearch/ant/tasks/junit4/package.html</overview>
            <groups>
              <group>
                <title>JUnit4 ANT task</title>
                <packages>com.carrotsearch.ant.tasks.junit4*</packages>
              </group>
              <group>
                <title>Listeners and report writers</title>
                <packages>com.carrotsearch.ant.tasks.junit4.listeners*</packages>
              </group>
              <group>
                <title>Load balancers</title>
                <packages>com.carrotsearch.ant.tasks.junit4.balancers*</packages>
              </group>
              <group>
                <title>Events and aggregated events for reports</title>
                <packages>com.carrotsearch.ant.tasks.junit4.events*</packages>
              </group>
            </groups>
            <header><![CDATA[<div id='header'><a class='logo' target='_top' href='https://labs.carrotsearch.com'></a>${project.name} v${project.version} <br>API Documentation</div>]]></header>
            <excludePackageNames>com.carrotsearch.ant.tasks.junit4.forked</excludePackageNames>
          </configuration>
        </plugin>        
      </plugins>          
    </pluginManagement>

    <plugins>
      <plugin>
        <groupId>de.thetaphi</groupId>
        <artifactId>forbiddenapis</artifactId>
      </plugin>
    
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
        <executions>
          <execution>
            <id>copy-dependencies</id>
            <phase>package</phase>
            <goals>
              <goal>copy-dependencies</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <includeGroupIds>com.carrotsearch.randomizedtesting,junit,org.hamcrest,org.ow2.asm</includeGroupIds>
        </configuration>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>
        <configuration>
          <forceCreation>true</forceCreation>
        </configuration>
      </plugin>

      <plugin>
        <groupId>com.pyx4me</groupId>
        <artifactId>proguard-maven-plugin</artifactId>
        <version>2.0.4</version>
        <executions>
          <execution>
            <phase>package</phase>
            <goals>
              <goal>proguard</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <assembly>
            <inclusions>
              <inclusion>
                <groupId>com.google.guava</groupId>
                <artifactId>guava</artifactId>
                <filter>!com/google/common/eventbus/SynchronizedEventHandler.class</filter>
              </inclusion>
              <inclusion>
                <groupId>org.ow2.asm</groupId>
                <artifactId>asm</artifactId>
                <filter>!module-info.class</filter>
              </inclusion>
              <inclusion>
                <groupId>com.carrotsearch.thirdparty</groupId>
                <artifactId>simple-xml-safe</artifactId>
              </inclusion>
              <inclusion>
                <groupId>com.carrotsearch.randomizedtesting</groupId>
                <artifactId>randomizedtesting-runner</artifactId>              
              </inclusion>
            </inclusions>
          </assembly>

          <addMavenDescriptor>true</addMavenDescriptor>
          <attach>true</attach>
          <appendClassifier>false</appendClassifier>
          <obfuscate>true</obfuscate>
          <outputDirectory>${project.build.directory}</outputDirectory>
          <proguardInclude>${basedir}/src/proguard/rules.pro</proguardInclude>
          <options>
            <option>-printusage ${project.build.directory}/proguard_dead.txt</option>
          </options>
          <libs>
            <lib>${proguard.rt.jar}</lib>
          </libs>
        </configuration>
        <dependencies>
          <dependency>
            <groupId>net.sf.proguard</groupId>
            <artifactId>proguard</artifactId>
            <version>4.6-customized</version>
            <scope>system</scope>
            <systemPath>${project.basedir}/lib/proguard.jar</systemPath>
          </dependency>
        </dependencies>
      </plugin>
    </plugins>

    <resources>
        <resource>
            <directory>src/main/resources</directory>
            <excludes>
              <exclude>**/*.jsonp</exclude>
              <exclude>**/ideas.txt</exclude>
            </excludes>
        </resource>
    </resources>
  </build>
  
  <profiles>
    <profile>
      <id>jdk19-compat</id>
      <activation>
        <jdk>[1.9,]</jdk>
      </activation>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-enforcer-plugin</artifactId>
            <version>${version.maven-enforcer-plugin}</version>
            <inherited>false</inherited>
            <executions>
              <execution>
                <id>enforce-proguard-java-home</id>
                <phase>validate</phase>
                <goals>
                  <goal>enforce</goal>
                </goals>
                <configuration>
                  <rules>
                    <requireFilesExist>
                      <files>
                        <file>${proguard.rt.jar}</file>
                      </files>
                     <message>
                     IMPORTANT! You must set proguard.rt.jar or proguard.java.home manually for obfuscation.
                     </message>
                     </requireFilesExist>
                  </rules>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>  
</project>

