<?xml version="1.0" encoding="UTF-8"?>

<!-- ====================================================================== -->
<!--                                                                        -->
<!-- JBoss, the OpenSource J2EE webOS                                       -->
<!--                                                                        -->
<!-- Distributable under LGPL license.                                      -->
<!-- See terms of license at http://www.gnu.org.                            -->
<!--                                                                        -->
<!-- ====================================================================== -->

<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.jboss.osgi</groupId>
        <artifactId>jboss-osgi</artifactId>
        <version>2.0.0</version>
    </parent>

    <name>JBossOSGi Testsuite</name>

    <groupId>org.jboss.osgi.testsuite</groupId>
    <artifactId>jboss-osgi-testsuite</artifactId>
    <packaging>pom</packaging>

    <!-- Modules -->
    <modules>
        <module>example</module>
        <module>functional</module>
        <module>integration</module>
        <module>performance</module>
    </modules>

    <!-- Properties -->
    <properties>
        <surefire.system.args>-ea -Xmx512m</surefire.system.args>
        <surefire.security.args>-Djava.security.manager -Djava.security.policy=${basedir}/src/test/resources/tst.policy</surefire.security.args>
        <jboss.osgi.framework.properties>jboss-osgi-framework.properties</jboss.osgi.framework.properties>
    </properties>

    <!-- Dependencies -->
    <dependencies>
        <dependency>
            <groupId>org.jboss.osgi.deployment</groupId>
            <artifactId>jbosgi-deployment</artifactId>
        </dependency>
        <dependency>
            <groupId>org.jboss.osgi.metadata</groupId>
            <artifactId>jbosgi-metadata</artifactId>
        </dependency>
        <dependency>
            <groupId>org.jboss.osgi.spi</groupId>
            <artifactId>jbosgi-spi</artifactId>
        </dependency>
        <dependency>
            <groupId>org.osgi</groupId>
            <artifactId>org.osgi.core</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.osgi</groupId>
            <artifactId>org.osgi.enterprise</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.jboss.osgi.provision</groupId>
            <artifactId>jbosgi-provision-core</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.jboss.osgi.provision</groupId>
            <artifactId>jbosgi-provision-bundle</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.jboss.osgi.repository</groupId>
            <artifactId>jbosgi-repository-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.jboss.osgi.resolver</groupId>
            <artifactId>jbosgi-resolver-api</artifactId>
        </dependency>
        <dependency>
            <groupId>org.jboss.osgi.vfs</groupId>
            <artifactId>jbosgi-vfs</artifactId>
        </dependency>
        <dependency>
            <groupId>org.jboss.osgi.vfs</groupId>
            <artifactId>jbosgi-vfs30</artifactId>
        </dependency>
        <!-- add this aggregate last -->
        <dependency>
            <groupId>org.jboss.osgi.repository</groupId>
            <artifactId>jbosgi-repository-bundle</artifactId>
            <scope>provided</scope>
        </dependency>

        <!-- Test Dependencies -->
        <dependency>
            <groupId>org.jboss.arquillian.junit</groupId>
            <artifactId>arquillian-junit-container</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.jboss.logmanager</groupId>
            <artifactId>jboss-logmanager</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-jdk14</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <!-- Build -->
    <build>
        <testResources>
            <testResource>
                <directory>src/test/resources</directory>
                <filtering>true</filtering>
            </testResource>
            <testResource>
                <directory>src/test/java</directory>
                <excludes>
                    <exclude>**/*.java</exclude>
                </excludes>
            </testResource>
        </testResources>
        <plugins>
            <plugin>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <argLine>${surefire.system.args}</argLine>
                    <systemPropertyVariables>
                        <java.io.tmpdir>${project.build.directory}</java.io.tmpdir>
                        <java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
                        <jboss.osgi.framework.properties>${jboss.osgi.framework.properties}</jboss.osgi.framework.properties>
                        <jboss.osgi.vfs.leakDebugging>true</jboss.osgi.vfs.leakDebugging>
                        <test.archive.directory>${project.build.directory}/test-libs</test.archive.directory>
                    </systemPropertyVariables>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <!-- Profiles -->
    <profiles>

        <profile>
            <id>embedded-testing</id>
            <activation>
                <property>
                    <name>!target.container</name>
                </property>
            </activation>
            <dependencies>
                <dependency>
                    <groupId>org.jboss.arquillian.container</groupId>
                    <artifactId>arquillian-osgi-embedded</artifactId>
                    <scope>test</scope>
                </dependency>
            </dependencies>
        </profile>

        <profile>
            <id>remote-testing</id>
            <activation>
                <property>
                    <name>target.container</name>
                </property>
            </activation>
            <dependencies>
                <dependency>
                    <groupId>org.wildfly</groupId>
                    <artifactId>wildfly-arquillian-common</artifactId>
                    <version>${version.wildfly.800}</version>
                    <scope>test</scope>
                </dependency>
            </dependencies>
            <build>
            	<plugins>
                    <plugin>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <configuration>
                            <redirectTestOutputToFile>true</redirectTestOutputToFile>
                        </configuration>
                    </plugin>
            	</plugins>
            </build>
        </profile>

        <profile>
            <id>wildfly800-testing</id>
            <activation>
                <property>
                    <name>target.container</name>
                    <value>wildfly800</value>
                </property>
            </activation>
            <properties>
                <!-- jboss.home>${user.home}/git/wildfly/build/target/wildfly-${version.wildfly.800}</jboss.home-->
                <jboss.home>${project.build.directory}/wildfly-${version.wildfly.800}</jboss.home>
            </properties>
            <dependencies>
                <dependency>
                    <groupId>org.wildfly</groupId>
                    <artifactId>wildfly-arquillian-container-managed</artifactId>
                    <version>${version.wildfly.800}</version>
                    <scope>test</scope>
                </dependency>
            </dependencies>
            <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.wildfly</groupId>
                                            <artifactId>wildfly-dist</artifactId>
                                            <version>${version.wildfly.800}</version>
                                            <type>zip</type>
                                            <overWrite>false</overWrite>
                                            <outputDirectory>${project.build.directory}</outputDirectory>
                                        </artifactItem>
                                    </artifactItems>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
