<?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/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <artifactId>hibernate-validator-parent</artifactId>
        <groupId>org.hibernate</groupId>
        <version>4.2.1.Final</version>
        <relativePath>../pom.xml</relativePath>
    </parent>
    <artifactId>hibernate-validator-tck-runner</artifactId>
    <name>Hibernate Validator TCK Runner</name>
    <description>Aggregates dependencies and runs the JSR-303 TCK</description>

    <dependencies>
        <dependency>
            <groupId>javax.validation</groupId>
            <artifactId>validation-api</artifactId>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-validator</artifactId>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-simple</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.hibernate.javax.persistence</groupId>
            <artifactId>hibernate-jpa-2.0-api</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.testng</groupId>
            <artifactId>testng</artifactId>
        </dependency>
        <dependency>
            <groupId>org.hibernate.jsr303.tck</groupId>
            <artifactId>jsr303-tck</artifactId>
        </dependency>
        <dependency>
            <groupId>org.jboss.jbossas.as7-cdi-tck</groupId>
            <artifactId>jbossas-container</artifactId>
        </dependency>
    </dependencies>

    <properties>
        <jboss.home>${env.JBOSS_HOME}</jboss.home>
        <validation.provider>org.hibernate.validator.HibernateValidator</validation.provider>
        <remote.debug />
    </properties>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <id>copy</id>
                        <phase>generate-test-sources</phase>
                        <goals>
                            <goal>copy</goal>
                        </goals>
                        <configuration>
                            <stripVersion>true</stripVersion>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>org.hibernate.jsr303.tck</groupId>
                                    <artifactId>jsr303-tck</artifactId>
                                    <type>xml</type>
                                    <classifier>suite</classifier>
                                    <overWrite>false</overWrite>
                                </artifactItem>
                            </artifactItems>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <suiteXmlFiles>
                        <suiteXmlFile>${project.build.directory}/dependency/jsr303-tck-suite.xml</suiteXmlFile>
                    </suiteXmlFiles>
                    <argLine>-Xmx128m</argLine>
                    <forkMode>once</forkMode>
                    <systemProperties>
                        <property>
                            <name>validation.provider</name>
                            <value>${validation.provider}</value>
                        </property>
                        <property>
                            <name>org.jboss.testharness.spi.StandaloneContainers</name>
                            <value>org.hibernate.jsr303.tck.util.StandaloneContainersImpl</value>
                        </property>
                    </systemProperties>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-report-plugin</artifactId>
                <executions>
                    <execution>
                        <id>generate-test-report</id>
                        <phase>test</phase>
                        <goals>
                            <goal>report-only</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <outputDirectory>${project.build.directory}/surefire-reports</outputDirectory>
                    <outputName>test-report</outputName>
                </configuration>
            </plugin>
        </plugins>
    </build>
    <profiles>
        <profile>
            <id>incontainer-debug</id>
            <activation>
                <property>
                    <name>debug</name>
                </property>
            </activation>
            <properties>
                <remote.debug>-Xnoagent -Djava.compiler=NONE -Xdebug
                    -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005
                </remote.debug>
            </properties>
        </profile>
        <profile>
            <id>incontainer</id>
            <activation>
                <property>
                    <name>incontainer</name>
                </property>
            </activation>
            <dependencies>
                <dependency>
                    <groupId>org.jboss.as</groupId>
                    <artifactId>jboss-as-arquillian-container-managed</artifactId>
                    <scope>test</scope>
                </dependency>
            </dependencies>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <configuration>
                            <suiteXmlFiles>
                                <suiteXmlFile>${project.build.directory}/dependency/jsr303-tck-suite.xml</suiteXmlFile>
                            </suiteXmlFiles>
                            <systemProperties>
                                <property>
                                    <name>java.io.tmpdir</name>
                                    <value>${project.build.outputDirectory}</value>
                                </property>
                                <property>
                                    <name>org.jboss.testharness.standalone</name>
                                    <value>false</value>
                                </property>
                                <property>
                                    <name>org.jboss.testharness.container.forceRestart</name>
                                    <value>true</value>
                                </property>
                                <property>
                                    <name>org.jboss.testharness.runIntegrationTests</name>
                                    <value>true</value>
                                </property>
                                <property>
                                    <name>org.jboss.testharness.libraryDirectory</name>
                                    <value>${project.build.directory}/dependency/lib</value>
                                </property>
                                <property>
                                    <name>org.jboss.testharness.outputDirectory</name>
                                    <value>${project.build.directory}</value>
                                </property>
                                <property>
                                    <name>jboss.options</name>
                                    <value>-Xms128m -Xmx512m -XX:MaxPermSize=512m -enableassertions
                                        -Dvalidation.provider=${validation.provider} ${remote.debug}
                                    </value>
                                </property>
                                <property>
                                    <name>org.jboss.testharness.spi.Containers</name>
                                    <value>org.jboss.jbossas.cdiTck.container.ArquillianContainerAdaptor</value>
                                </property>
                                <property>
                                    <name>org.jboss.har2arq.container</name>
                                    <value>org.jboss.as.arquillian.container.managed.JBossAsManagedContainer</value>
                                </property>
                                <property>
                                    <name>jboss.home</name>
                                    <value>${jboss.home}</value>
                                </property>
                                <property>
                                    <name>validation.provider</name>
                                    <value>${validation.provider}</value>
                                </property>
                            </systemProperties>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <!--
                 Enabling this profile will bundle the BV API and Hibernate Validator w/ the deployed war files instead of
                 testing against the AS provided dependencies
            -->
            <id>bundled-dependencies</id>
            <activation>
                <property>
                    <name>bundled-dependencies</name>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-dependency-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>copy</id>
                                <phase>generate-test-sources</phase>
                                <goals>
                                    <goal>copy</goal>
                                </goals>
                                <configuration>
                                    <stripVersion>true</stripVersion>
                                    <artifactItems>
                                        <artifactItem>
                                            <groupId>org.hibernate.jsr303.tck</groupId>
                                            <artifactId>jsr303-tck</artifactId>
                                            <type>xml</type>
                                            <classifier>suite</classifier>
                                            <overWrite>false</overWrite>
                                        </artifactItem>
                                        <artifactItem>
                                            <groupId>javax.validation</groupId>
                                            <artifactId>validation-api</artifactId>
                                            <overWrite>true</overWrite>
                                            <outputDirectory>${project.build.directory}/dependency/lib</outputDirectory>
                                        </artifactItem>
                                        <artifactItem>
                                            <groupId>org.hibernate</groupId>
                                            <artifactId>hibernate-validator</artifactId>
                                            <overWrite>true</overWrite>
                                            <outputDirectory>${project.build.directory}/dependency/lib</outputDirectory>
                                        </artifactItem>
                                        <artifactItem>
                                            <groupId>org.slf4j</groupId>
                                            <artifactId>slf4j-simple</artifactId>
                                            <overWrite>true</overWrite>
                                            <outputDirectory>${project.build.directory}/dependency/lib</outputDirectory>
                                        </artifactItem>
                                        <artifactItem>
                                            <groupId>org.slf4j</groupId>
                                            <artifactId>slf4j-api</artifactId>
                                            <overWrite>true</overWrite>
                                            <outputDirectory>${project.build.directory}/dependency/lib</outputDirectory>
                                        </artifactItem>
                                    </artifactItems>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>write-artifacts-to-disk</id>
            <activation>
                <property>
                    <name>dumpArtifacts</name>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>exec-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>generate-jsr-303-artifacts</id>
                                <phase>test-compile</phase>
                                <goals>
                                    <goal>java</goal>
                                </goals>
                            </execution>
                        </executions>
                        <configuration>
                            <classpathScope>test</classpathScope>
                            <mainClass>org.jboss.testharness.api.TCK</mainClass>
                            <systemProperties>
                                <systemProperty>
                                    <key>dumpArtifacts</key>
                                    <value>true</value>
                                </systemProperty>
                                <systemProperty>
                                    <key>org.jboss.testharness.outputDirectory</key>
                                    <value>target/jsr303-artifacts</value>
                                </systemProperty>
                                <systemProperty>
                                    <key>org.jboss.testharness.libraryDirectory</key>
                                    <value>target/jsr303-artifacts/dependencies</value>
                                </systemProperty>
                                <systemProperty>
                                    <key>org.jboss.testharness.libraryDirectory</key>
                                    <value>${project.build.directory}/dependency/lib</value>
                                </systemProperty>
                                <systemProperty>
                                    <key>org.jboss.testharness.spi.StandaloneContainers</key>
                                    <value>org.hibernate.jsr303.tck.util.StandaloneContainersImpl</value>
                                </systemProperty>
                            </systemProperties>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
