<?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>jbosgi</artifactId>
        <version>2.3.1.Final</version>
    </parent>

    <name>JBossOSGi Testsuite</name>

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

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

    <!-- Properties -->
    <properties>
        <surefire.system.args>-ea -Xmx512m -XX:MaxPermSize=512m</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>jbosgi-framework.properties</jboss.osgi.framework.properties>
    </properties>

    <!-- Dependencies -->
    <dependencies>
        <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-core</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.jboss.osgi.resolver</groupId>
            <artifactId>jbosgi-resolver-api</artifactId>
            <scope>provided</scope>
        </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.container</groupId>
            <artifactId>arquillian-container-osgi</artifactId>
        </dependency>
        <dependency>
            <groupId>org.jboss.arquillian.junit</groupId>
            <artifactId>arquillian-junit-container</artifactId>
        </dependency>
        <dependency>
            <groupId>org.jacoco</groupId>
            <artifactId>org.jacoco.core</artifactId>
        </dependency>

        <dependency>
            <groupId>org.jboss.logmanager</groupId>
            <artifactId>jboss-logmanager</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.jboss.shrinkwrap</groupId>
            <artifactId>shrinkwrap-impl-base</artifactId>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-jdk14</artifactId>
        </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>
    </build>

    <!-- Profiles -->
    <profiles>

        <profile>
            <id>embedded-testing</id>
            <activation>
                <property>
                    <name>embedded</name>
                </property>
            </activation>
            <dependencies>
                <dependency>
                    <groupId>org.jboss.arquillian.container</groupId>
                    <artifactId>arquillian-container-jbosgi-embedded</artifactId>
                    <scope>test</scope>
                </dependency>
            </dependencies>
            <build>
                <plugins>
                    <plugin>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <configuration>
                            <argLine>@{jacocoArgLine} @{surefire.system.args}</argLine>
                            <systemPropertyVariables>
                                <jboss.home>${jboss.home}</jboss.home>
                                <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>
        </profile>

        <profile>
            <id>wildfly-testing</id>
            <activation>
                <property>
                    <name>!embedded</name>
                </property>
            </activation>
            <properties>
                <project.root.dir>${basedir}/..</project.root.dir>
                <jboss.home>${project.build.directory}/wildfly-${version.jboss.wildfly}</jboss.home>
            </properties>
            <dependencies>
                <dependency>
                    <groupId>org.wildfly</groupId>
                    <artifactId>wildfly-arquillian-container-managed</artifactId>
                    <scope>test</scope>
                </dependency>
                <dependency>
                    <groupId>org.jboss.osgi.wildfly</groupId>
                    <artifactId>jbosgi-wildfly-build</artifactId>
                    <version>${project.version}</version>
                    <type>pom</type>
                </dependency>
            </dependencies>
            <build>
                <plugins>
                    <plugin>
                        <artifactId>maven-dependency-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>unpack-wildfly-patch</id>
                                <phase>process-test-resources</phase>
                                <goals>
                                    <goal>unpack</goal>
                                </goals>
                                <configuration>
                                    <artifactItems>
                                        <artifactItem>
                                            <groupId>org.jboss.osgi.wildfly</groupId>
                                            <artifactId>jbosgi-wildfly-build</artifactId>
                                            <version>${project.version}</version>
                                            <classifier>patch</classifier>
                                            <type>tar.gz</type>
                                            <outputDirectory>${jboss.home}</outputDirectory>
                                        </artifactItem>
                                    </artifactItems>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <configuration>
                            <systemPropertyVariables>
                                <jboss.home>${jboss.home}</jboss.home>
                            </systemPropertyVariables>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
            <modules>
                <module>integration</module>
            </modules>
        </profile>
        <profile>
            <id>wildfly-stable</id>
            <activation>
                <property>
                    <name>!wfsnap</name>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <artifactId>maven-dependency-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>unpack-wildfly</id>
                                <phase>process-test-resources</phase>
                                <goals>
                                    <goal>unpack</goal>
                                </goals>
                                <configuration>
                                    <artifactItems>
                                        <artifactItem>
                                            <groupId>org.wildfly</groupId>
                                            <artifactId>wildfly-dist</artifactId>
                                            <version>${version.jboss.wildfly}</version>
                                            <type>tar.gz</type>
                                            <overWrite>false</overWrite>
                                            <outputDirectory>${project.build.directory}</outputDirectory>
                                        </artifactItem>
                                    </artifactItems>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>wildfly-snapshot</id>
            <activation>
                <property>
                    <name>wfsnap</name>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <artifactId>maven-antrun-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>modular-config</id>
                                <goals>
                                    <goal>run</goal>
                                </goals>
                                <phase>process-test-resources</phase>
                                <configuration>
                                    <target>
                                        <mkdir dir="${jboss.home}/standalone/deployments" />
                                        <copy todir="${jboss.home}" failonerror="false" overwrite="true">
                                            <fileset dir="${wildfly.dist.dir}">
                                                <include name="bin/**" />
                                                <include name="modules/**" />
                                                <include name="standalone/configuration/**" />
                                                <include name="standalone/lib/**" />
                                                <include name="jboss-modules.jar" />
                                            </fileset>
                                        </copy>
                                        <chmod dir="${jboss.home}/bin" includes="*.sh" perm="+x" />
                                    </target>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
