<!--
  ~ JBoss, Home of Professional Open Source.
  ~ Copyright 2011, 2019 Red Hat and individual contributors
  ~ as indicated by the @author tags. See the copyright.txt file in the
  ~ distribution for a full listing of individual contributors.
  ~
  ~ This is free software; you can redistribute it and/or modify it
  ~ under the terms of the GNU Lesser General Public License as
  ~ published by the Free Software Foundation; either version 2.1 of
  ~ the License, or (at your option) any later version.
  ~
  ~ This software is distributed in the hope that it will be useful,
  ~ but WITHOUT ANY WARRANTY; without even the implied warranty of
  ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  ~ Lesser General Public License for more details.
  ~
  ~ You should have received a copy of the GNU Lesser General Public
  ~ License along with this software; if not, write to the Free
  ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  ~ 02110-1301 USA, or see the FSF site: http://www.fsf.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>
    <artifactId>byteman-bmunit5</artifactId>
    <packaging>jar</packaging>
    <description>
        The Byteman bmunit5 jar provides integration of Byteman into JUnit5 tests.
    </description>
    <name>byteman-bmunit5</name>
    <parent>
        <groupId>org.jboss.byteman</groupId>
        <artifactId>byteman-root</artifactId>
        <version>4.0.28</version>
        <relativePath>../../pom.xml</relativePath>
    </parent>
    <build>
        <plugins>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <useSystemClassLoader>true</useSystemClassLoader>
                    <useManifestOnlyJar>true</useManifestOnlyJar>
                    <forkCount>1</forkCount>
                    <reuseForks>false</reuseForks>
                    <systemProperties>
                        <property>
                            <name>org.jboss.byteman.home</name>
                            <value></value>
                        </property>
                    </systemProperties>
                    <argLine>-Djdk.attach.allowAttachSelf</argLine>
                    <environmentVariables>
                        <BYTEMAN_HOME></BYTEMAN_HOME>
                    </environmentVariables>
                </configuration>
                <executions>
                    <!-- the other test classes in this module are named so that the
                         default includes never match them; the configuration lifecycle
                         classes are excluded explicitly instead, because running them
                         one class per fork proves nothing. supplying any exclude
                         replaces the built in exclude list rather than adding to it, so
                         the inner class pattern has to be repeated here. with those two
                         excludes this execution matches no classes at all, which surefire
                         treats as success unless -Dtest is given -->
                    <execution>
                        <id>default-test</id>
                        <phase>test</phase>
                        <goals>
                            <goal>test</goal>
                        </goals>
                        <configuration>
                            <excludes>
                                <exclude>**/ConfigLifecycle*Test.class</exclude>
                                <exclude>**/*$*</exclude>
                            </excludes>
                        </configuration>
                    </execution>

                    <execution>
                        <id>junit</id>
                        <phase>test</phase>
                        <goals>
                            <goal>test</goal>
                        </goals>
                        <configuration>
                            <includes>
                                <include>**/UnitTest5.class</include>
                            </includes>
                        </configuration>
                    </execution>

                    <execution>
                        <id>junitconfig</id>
                        <phase>test</phase>
                        <goals>
                            <goal>test</goal>
                        </goals>
                        <configuration>
                            <includes>
                                <include>**/UnitConfigTest5.class</include>
                            </includes>
                        </configuration>
                    </execution>

                    <!-- the configuration lifecycle classes only mean anything when they
                         share a JVM, so this execution reuses a single fork rather than
                         forking per class like the others. the run order is load bearing
                         for the last link: a leaked configuration trips whichever class
                         runs next whatever the order, but ConfigLifecycleZTest only
                         closes the chain if it runs after all of them -->
                    <execution>
                        <id>junitlifecycle</id>
                        <phase>test</phase>
                        <goals>
                            <goal>test</goal>
                        </goals>
                        <configuration>
                            <reuseForks>true</reuseForks>
                            <runOrder>alphabetical</runOrder>
                            <includes>
                                <include>**/ConfigLifecycle*Test.class</include>
                            </includes>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
    <dependencies>

        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-api</artifactId>
            <version>5.4.0</version>
            <scope>compile</scope>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-params</artifactId>
            <version>5.4.0</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-engine</artifactId>
            <version>5.4.0</version>
            <scope>test</scope>
        </dependency>
        <!-- used to run test containers programmatically, so that a container can
             be started while another container's configuration is installed -->
        <dependency>
            <groupId>org.junit.platform</groupId>
            <artifactId>junit-platform-launcher</artifactId>
            <version>1.4.0</version>
            <scope>test</scope>
        </dependency>


        <dependency>
            <groupId>org.jboss.byteman</groupId>
            <artifactId>byteman-bmunit</artifactId>
        </dependency>

    </dependencies>
    <profiles>
        <!-- the bmunit code uses the VM_Attach API which is available in the JDK tools jar
             in JDK6/7/8. In JDK9 it is always available via the system loader.
        -->
        <profile>
            <id>use-toolsjar-profile</id>
            <activation>
                <jdk>[1.6,1.8]</jdk>
            </activation>
            <dependencies>
                <dependency>
                    <groupId>com.sun</groupId>
                    <artifactId>tools</artifactId>
                    <version>1.6</version>
                    <scope>system</scope>
                    <systemPath>${tools.jar}</systemPath>
                </dependency>
            </dependencies>
        </profile>
    </profiles>
</project>
