<?xml version="1.0" encoding="UTF-8"?>
<!--
  ~ JBoss, Home of Professional Open Source
  ~ Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual contributors
  ~ by the @authors tag. See the copyright.txt in the distribution for a
  ~ full listing of individual contributors.
  ~
  ~ Licensed under the Apache License, Version 2.0 (the "License");
  ~ you may not use this file except in compliance with the License.
  ~ You may obtain a copy of the License at
  ~ http://www.apache.org/licenses/LICENSE-2.0
  ~ Unless required by applicable law or agreed to in writing, software
  ~ distributed under the License is distributed on an "AS IS" BASIS,
  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  ~ See the License for the specific language governing permissions and
  ~ limitations under the License.
  -->
<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.3.3.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>

    <properties>
        <jsr303.tck.version>1.0.8.GA</jsr303.tck.version>
        <arquillian.version>1.0.0.CR7</arquillian.version>
        <jbossas.version>7.1.0.Beta1b</jbossas.version>
        <jboss.home>${project.build.directory}/jboss-as-${jbossas.version}</jboss.home>
        <validation.provider>org.hibernate.validator.HibernateValidator</validation.provider>
        <remote.debug />
    </properties>

    <dependencies>
        <dependency>
            <groupId>javax.validation</groupId>
            <artifactId>validation-api</artifactId>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-validator</artifactId>
        </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.jboss.jbossas.as7-cdi-tck</groupId>
            <artifactId>jbossas-container</artifactId>
            <version>1.0.0.Final</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate.jsr303.tck</groupId>
            <artifactId>jsr303-tck</artifactId>
            <version>${jsr303.tck.version}</version>
        </dependency>
        <dependency>
            <groupId>org.jboss.arquillian.core</groupId>
            <artifactId>arquillian-core-spi</artifactId>
            <version>${arquillian.version}</version>
        </dependency>
        <dependency>
            <groupId>org.jboss.arquillian.core</groupId>
            <artifactId>arquillian-core-impl-base</artifactId>
            <version>${arquillian.version}</version>
        </dependency>
        <dependency>
            <groupId>org.jboss.arquillian.container</groupId>
            <artifactId>arquillian-container-impl-base</artifactId>
            <version>${arquillian.version}</version>
        </dependency>
        <dependency>
            <groupId>org.jboss.arquillian.container</groupId>
            <artifactId>arquillian-container-spi</artifactId>
            <version>${arquillian.version}</version>
        </dependency>
        <dependency>
            <groupId>org.jboss.as</groupId>
            <artifactId>jboss-as-arquillian-container-managed</artifactId>
            <version>${jbossas.version}</version>
        </dependency>
        <dependency>
            <groupId>org.jboss.as</groupId>
            <artifactId>jboss-as-arquillian-common</artifactId>
            <version>${jbossas.version}</version>
        </dependency>
        <dependency>
            <groupId>org.jboss.as</groupId>
            <artifactId>jboss-as-arquillian-container-remote</artifactId>
            <version>${jbossas.version}</version>
        </dependency>
        <dependency>
            <groupId>org.jboss.as</groupId>
            <artifactId>jboss-as-controller-client</artifactId>
            <version>${jbossas.version}</version>
        </dependency>
    </dependencies>

    <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>
            <build>
                <plugins>
                    <plugin>
                        <artifactId>maven-dependency-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>unpack</id>
                                <phase>process-test-resources</phase>
                                <goals>
                                    <goal>unpack</goal>
                                </goals>
                                <configuration>
                                    <artifactItems>
                                        <artifactItem>
                                            <groupId>org.jboss.as</groupId>
                                            <artifactId>jboss-as-dist</artifactId>
                                            <version>${jbossas.version}</version>
                                            <type>zip</type>
                                            <overWrite>false</overWrite>
                                            <outputDirectory>${project.build.directory}</outputDirectory>
                                        </artifactItem>
                                    </artifactItems>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <configuration>
                            <argLine>-Xmx1024m -Djava.util.logging.manager=org.jboss.logmanager.LogManager</argLine>
                            <forkMode>once</forkMode>
                            <suiteXmlFiles>
                                <suiteXmlFile>${project.build.directory}/dependency/jsr303-tck-suite.xml</suiteXmlFile>
                            </suiteXmlFiles>
                            <systemPropertyVariables>
                                <!-- TCK test harness related properties -->
                                <java.io.tmpdir>${project.build.outputDirectory}</java.io.tmpdir>
                                <org.jboss.testharness.standalone>false</org.jboss.testharness.standalone>
                                <org.jboss.testharness.container.forceRestart>true</org.jboss.testharness.container.forceRestart>
                                <org.jboss.testharness.runIntegrationTests>true</org.jboss.testharness.runIntegrationTests>
                                <org.jboss.testharness.libraryDirectory>${project.build.directory}/dependency/lib</org.jboss.testharness.libraryDirectory>
                                <org.jboss.testharness.outputDirectory>${project.build.directory}</org.jboss.testharness.outputDirectory>
                                <org.jboss.testharness.spi.Containers>org.jboss.jbossas.cdiTck.container.ArquillianContainerAdaptor</org.jboss.testharness.spi.Containers>
                                <org.jboss.har2arq.container>org.jboss.as.arquillian.container.managed.ManagedDeployableContainer</org.jboss.har2arq.container>

                                <!-- JBOSS container related properties -->
                                <jboss.options>-Xmx1024m -XX:MaxPermSize=512m -enableassertions -Dvalidation.provider=${validation.provider} ${remote.debug}</jboss.options>

                                <!-- The validation provider to use -->
                                <validation.provider>${validation.provider}</validation.provider>
                            </systemPropertyVariables>
                            <environmentVariables>
                                 <JBOSS_HOME>${jboss.home}</JBOSS_HOME>
                            </environmentVariables>
                        </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.jboss.logging</groupId>
                                            <artifactId>jboss-logging</artifactId>
                                            <overWrite>true</overWrite>
                                            <outputDirectory>${project.build.directory}/dependency/lib</outputDirectory>
                                        </artifactItem>
                                        <artifactItem>
                                            <groupId>log4j</groupId>
                                            <artifactId>log4j</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>
