<?xml version="1.0" encoding="UTF-8"?>
<!--
The MIT License

Copyright (c) 2004-2009, Sun Microsystems, Inc., Kohsuke Kawaguchi

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-->
<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>org.jenkins-ci.main</groupId>
    <artifactId>pom</artifactId>
    <version>2.56</version>
  </parent>

  <artifactId>test</artifactId>

  <name>Tests for Jenkins core</name>
  <description>Functional tests for Jenkins core</description>

  <properties>
    <concurrency>2</concurrency> <!-- may use e.g. 2C for 2 × (number of cores) -->
    <mavenDebug>false</mavenDebug>
    <jacocoSurefireArgs /><!-- empty by default -->
  </properties>

  <dependencies>
    <dependency>
      <!--
        put hudson.war in the classpath. we can't pull in the war artifact directly
        because Maven excludes all wars from classpath automatically. so we need a jar artifact.
      -->
      <groupId>${project.groupId}</groupId>
      <artifactId>jenkins-war</artifactId>
      <version>${project.version}</version>
      <classifier>war-for-test</classifier>
    </dependency>
    <dependency>
      <groupId>${project.groupId}</groupId>
      <artifactId>jenkins-test-harness</artifactId>
      <version>2.13</version>
      <scope>test</scope>
      <exclusions>
        <exclusion>
          <groupId>${project.groupId}</groupId>
          <artifactId>jenkins-war</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
    <dependency>
      <groupId>${project.groupId}</groupId>
      <artifactId>jenkins-test-harness-tools</artifactId>
      <version>2.0</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>${project.groupId}</groupId>
      <artifactId>maven-plugin</artifactId>
      <version>${maven-plugin.version}</version>
      <exclusions>
        <exclusion> <!-- perhaps unnecessary as of JENKINS-35445? -->
          <groupId>org.apache.httpcomponents</groupId>
          <artifactId>httpclient</artifactId>
        </exclusion>
        <exclusion>
          <groupId>org.apache.httpcomponents</groupId>
          <artifactId>httpcore</artifactId>
        </exclusion>
        <exclusion>
          <!--
            during test, this jar gets loaded at the same level as remoting.jar and can cause conflicts depending on the order.
            the package is also not signed, and it creates package conflicts between the signed package from remoting.jar
          -->
          <groupId>org.jenkins-ci</groupId>
          <artifactId>SECURITY-144-compat</artifactId>
        </exclusion>
        <exclusion>
          <groupId>commons-codec</groupId>
          <artifactId>commons-codec</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
    <dependency> <!-- TODO seems to be used only by PluginManagerTest -->
      <groupId>org.jenkins-ci.plugins</groupId>
      <artifactId>subversion</artifactId>
      <version>1.45</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.jenkins-ci.plugins</groupId>
      <artifactId>matrix-auth</artifactId>
      <version>1.0.2</version>
    </dependency>
    <dependency>
      <groupId>org.jenkins-ci.plugins</groupId>
      <artifactId>antisamy-markup-formatter</artifactId>
      <version>1.0</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.jenkins-ci.plugins</groupId>
      <artifactId>matrix-project</artifactId>
      <version>${matrix-project.version}</version>
    </dependency>
    <dependency>
      <groupId>org.jenkins-ci.plugins</groupId>
      <artifactId>junit</artifactId>
      <version>1.2-beta-4</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.jenkins-ci.plugins</groupId>
      <artifactId>structs</artifactId>
      <version>1.2</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.jvnet.mock-javamail</groupId>
      <artifactId>mock-javamail</artifactId>
      <version>1.7</version>
    </dependency>
    <dependency>
      <groupId>org.hamcrest</groupId>
      <artifactId>hamcrest-core</artifactId>
      <version>1.3</version>
    </dependency>
    <dependency><!-- we exclude this transient dependency from htmlunit, which we actually need in the test -->
      <groupId>xalan</groupId>
      <artifactId>xalan</artifactId>
      <version>2.7.1</version>
      <exclusions>
        <exclusion>
          <groupId>xml-apis</groupId>
          <artifactId>xml-apis</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
    <dependency>
      <!-- for testing JNLP launch. -->
      <groupId>org.jvnet.hudson</groupId>
      <artifactId>netx</artifactId>
      <version>0.5-hudson-2</version>
    </dependency>
    <dependency>
      <groupId>org.easymock</groupId>
      <artifactId>easymock</artifactId>
      <version>2.4</version>
    </dependency>
    <dependency>
      <groupId>org.mockito</groupId>
      <artifactId>mockito-core</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.reflections</groupId>
      <artifactId>reflections</artifactId>
      <version>0.9.9</version>
    </dependency>
    <dependency>
      <groupId>org.codehaus.geb</groupId>
      <artifactId>geb-implicit-assertions</artifactId>
      <version>0.7.2</version>
    </dependency>
    <dependency>
      <groupId>org.javassist</groupId>
      <artifactId>javassist</artifactId>
      <version>3.19.0-GA</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.apache.commons</groupId>
      <artifactId>commons-collections4</artifactId>
      <version>4.0</version>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <plugin>
        <groupId>org.kohsuke.stapler</groupId>
        <artifactId>maven-stapler-plugin</artifactId>
        <!-- version specified in grandparent pom -->
        <extensions>true</extensions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <!-- version specified in grandparent pom -->
        <configuration>
          <argLine>${jacocoSurefireArgs} -Dfile.encoding=UTF-8 -Xmx1g</argLine>
          <systemPropertyVariables>
              <!-- use AntClassLoader that supports predictable file handle release -->
              <hudson.ClassicPluginStrategy.useAntClassLoader>true</hudson.ClassicPluginStrategy.useAntClassLoader>
              <hudson.maven.debug>${mavenDebug}</hudson.maven.debug>
              <buildDirectory>${project.build.directory}</buildDirectory>
          </systemPropertyVariables>
          <reuseForks>false</reuseForks>
          <forkCount>${concurrency}</forkCount>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.codehaus.gmaven</groupId>
        <artifactId>gmaven-plugin</artifactId>
        <!-- version specified in grandparent pom -->
        <executions>
          <execution>
            <id>default</id>
            <!-- compile and process annotations in Groovy test code -->
            <goals>
              <goal>generateTestStubs</goal>
              <goal>testCompile</goal>
            </goals>
          </execution>
        </executions>
        <dependencies>
          <dependency>
            <groupId>org.apache.ant</groupId>
            <artifactId>ant</artifactId>
            <version>1.8.0</version>
          </dependency>
          <!-- Usually a dependency of ant, but some people seem to have an incomplete ant POM. See JENKINS-11416 -->
          <dependency>
            <groupId>org.apache.ant</groupId>
            <artifactId>ant-launcher</artifactId>
            <version>1.8.0</version>
          </dependency>
        </dependencies>
      </plugin>
      <plugin>
        <artifactId>maven-deploy-plugin</artifactId>
        <configuration>
          <skip>true</skip>
        </configuration>
      </plugin>
    </plugins>
  </build>

  <profiles>
    <profile>
      <id>light-test</id>
      <properties>
        <skipTests>true</skipTests>
      </properties>
    </profile>
    <profile>
      <id>all-tests</id>
      <activation>
        <property>
          <name>!test</name>
        </property>
      </activation>
      <properties>
        <maven.test.redirectTestOutputToFile>true</maven.test.redirectTestOutputToFile>
        <surefire.rerunFailingTestsCount>4</surefire.rerunFailingTestsCount>
      </properties>
    </profile>
    <profile>
      <!-- Obtain code coverage report. This is done by running Unit tests on our own and suppressing surefire. -->
      <id>cobertura</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.codehaus.gmaven</groupId>
            <artifactId>gmaven-plugin</artifactId>
            <!-- version specified in grandparent pom -->
            <executions>
              <!-- run unit test -->
              <execution>
                <phase>test</phase>
                <goals>
                  <goal>execute</goal>
                </goals>
                <configuration>
                  <scriptpath>
                    <!-- load helpers from hg core -->
                    <element>${project.basedir}/../core/src/build-script</element>
                  </scriptpath>
                  <source>${project.basedir}/src/build-script/unitTest.groovy</source>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>    
    <profile>
      <id>jacoco</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.jacoco</groupId>
            <artifactId>jacoco-maven-plugin</artifactId>
            <version>0.6.3.201306030806</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 path to the file which contains the execution data. -->
                  <destFile>${project.build.directory}/coverage-reports/jacoco-ut.exec</destFile>
                  <propertyName>jacocoSurefireArgs</propertyName>
                </configuration>
              </execution>
              <!--
                Ensures that the code coverage report for unit tests is created after
                unit tests have been run.
              -->
              <execution>
                <id>post-unit-test</id>
                <phase>test</phase>
                <goals>
                  <goal>report</goal>
                </goals>
                <configuration>
                  <!-- Sets the path to the file which contains the execution data. -->
                  <dataFile>${project.build.directory}/coverage-reports/jacoco-ut.exec</dataFile>
                  <!-- Sets the output directory for the code coverage report. -->
                  <outputDirectory>${project.reporting.outputDirectory}/jacoco-ut</outputDirectory>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>
</project>
