<?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.1.0.Final</version>
    </parent>
    <artifactId>hibernate-validator-tck-runner</artifactId>
    <name>Hibernate Validator TCK Runner</name>
    <description>Aggregates dependencies and run's 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-log4j12</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.testng</groupId>
            <artifactId>testng</artifactId>
            <classifier>jdk15</classifier>
        </dependency>
        <dependency>
            <groupId>org.hibernate.jsr303.tck</groupId>
            <artifactId>jsr303-tck</artifactId>
        </dependency>
        <dependency>
            <groupId>org.jboss.test-harness</groupId>
            <artifactId>jboss-test-harness-jboss-as-51</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>org.hibernate</groupId>
                    <artifactId>hibernate-entitymanager</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <!--
        Provided dependencies.
        JAXB is needed when running on Java5. In this environment these dependencies have to be added
        On Java6 jaxb is part of the runtime environment
        -->
        <dependency>
            <groupId>javax.xml.bind</groupId>
            <artifactId>jaxb-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.sun.xml.bind</groupId>
            <artifactId>jaxb-impl</artifactId>
            <scope>provided</scope>
        </dependency>
    </dependencies>

    <properties>
        <jboss.home>/opt/java/jboss-5.1.0.GA</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>
                                <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-log4j12</artifactId>
                                    <overWrite>true</overWrite>
                                    <outputDirectory>${project.build.directory}/dependency/lib</outputDirectory>
                                </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>
                    </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>
            <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>validation.provider</name>
                                    <value>${validation.provider}</value>
                                </property>
                                <property>
                                    <name>org.jboss.testharness.standalone</name>
                                    <value>false</value>
                                </property>
                                <property>
                                    <name>jboss.home</name>
                                    <value>${jboss.home}</value>
                                </property>
                                <property>
                                    <name>org.jboss.testharness.container.javaOpts</name>
                                    <value>-Xms128m -Xmx384m -XX:MaxPermSize=128m -Dorg.jboss.resolver.warning=true
                                        -Dvalidation.provider=${validation.provider} ${remote.debug}
                                    </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>target/dependency/lib</value>
                                </property>
                                <property>
                                    <name>org.jboss.testharness.outputDirectory</name>
                                    <value>target</value>
                                </property>
                            </systemProperties>
                        </configuration>
                    </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>
                            </systemProperties>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
