<?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">
  <parent>
    <artifactId>lenskit</artifactId>
    <groupId>org.grouplens.lenskit</groupId>
    <version>2.0.5</version>
    <relativePath>..</relativePath>
  </parent>
  <modelVersion>4.0.0</modelVersion>

  <artifactId>lenskit-integration-tests</artifactId>
  <name>LensKit Integration Tests</name>
  <description>
    End-to-end integration tests for the core LensKit code.
  </description>

  <properties>
    <test.repo.directory>${project.build.directory}/test-repo</test.repo.directory>
    <archetype.test.directory>${project.build.directory}/archetype-test</archetype.test.directory>
    <lenskit.movielens.100k>${basedir}/data/ml-100k</lenskit.movielens.100k>
    <lenskit.eval.threadCount>1</lenskit.eval.threadCount>
    <!-- Specify the location of Rscript.  We need to do this explicitly here, even though Rscript
         is the default, because of how we route properties.  Override this on the commadn line or
         in your settings.xml if you need to specify an alternate location. -->
    <rscript.executable>Rscript</rscript.executable>
  </properties>

  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
    </dependency>
    <dependency>
      <groupId>org.hamcrest</groupId>
      <artifactId>hamcrest-core</artifactId>
    </dependency>
    <dependency>
      <groupId>org.hamcrest</groupId>
      <artifactId>hamcrest-library</artifactId>
    </dependency>
    <dependency>
      <groupId>org.grouplens.lenskit</groupId>
      <artifactId>lenskit-core</artifactId>
      <version>${project.version}</version>
    </dependency>
    <dependency>
      <groupId>org.grouplens.lenskit</groupId>
      <artifactId>lenskit-knn</artifactId>
      <version>${project.version}</version>
    </dependency>
    <dependency>
      <groupId>org.grouplens.lenskit</groupId>
      <artifactId>lenskit-svd</artifactId>
      <version>${project.version}</version>
    </dependency>
    <dependency>
      <groupId>org.grouplens.lenskit</groupId>
      <artifactId>lenskit-eval</artifactId>
      <version>${project.version}</version>
    </dependency>

    <dependency>
      <groupId>org.grouplens.lenskit</groupId>
      <artifactId>lenskit-test</artifactId>
      <version>${project.version}</version>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <!-- Download the MovieLens 100K data set -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-antrun-plugin</artifactId>
        <executions>
          <execution>
            <id>download-ml-data</id>
            <goals><goal>run</goal></goals>
            <phase>pre-integration-test</phase>
            <configuration>
              <target>
                <ant antfile="${basedir}/src/test/ant/get-data.xml" target="fetch-100k">
                  <!--
                   Maven only exports POM value to Ant, not command-line value.
                   re-export here to get the right value.
                   -->
                  <property name="lenskit.movielens.100k" value="${lenskit.movielens.100k}" />
                </ant>
              </target>
            </configuration>
          </execution>
        </executions>
      </plugin>

      <!--
      Disable Surefire. The Maven way is to use the failsafe plugin to run integration
      tests, so they run in the right phase and don't fail the build until the verify
      phase.
       -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>

        <configuration>
          <skip>true</skip>
        </configuration>
      </plugin>

      <!-- Use failsafe to run the tests. -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-failsafe-plugin</artifactId>
        <configuration>
          <systemPropertyVariables combine.children="append">
            <lenskit.movielens.100k>${lenskit.movielens.100k}</lenskit.movielens.100k>
            <buildDirectory>${project.build.directory}</buildDirectory>
            <lenskit.temp.dir>${project.build.directory}/eval.scratch</lenskit.temp.dir>
          </systemPropertyVariables>
          <includes>
            <include>**/Test*.java</include>
          </includes>
        </configuration>
        <executions>
          <execution>
            <goals>
              <goal>integration-test</goal>
              <goal>verify</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-enforcer-plugin</artifactId>
        <executions>
          <!-- Fail-fast if we can't get MovieLens data. -->
          <execution>
            <id>validate-integration-tests</id>
            <phase>validate</phase>
            <goals><goal>enforce</goal></goals>
            <configuration>
              <rules>
                <requireProperty>
                  <property>grouplens.mldata.acknowledge</property>
                  <message>
                    Integration tests require MovieLens 100K data set, which is freely
                    available for non-commercial use. To accept the license terms and
                    automatically download the dataset, set the property
                    'grouplens.mldata.acknowledge' to 'yes'.
                    For more information, see http://lenskit.grouplens.org/ML100K.
                  </message>
                </requireProperty>
              </rules>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>
