<?xml version="1.0" encoding="UTF-8"?>
<!--
  ~ Copyright The WildFly Authors
  ~ SPDX-License-Identifier: Apache-2.0
  -->

<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/xsd/maven-4.0.0.xsd">
    <parent>
        <groupId>org.wildfly.plugins</groupId>
        <artifactId>wildfly-maven-plugin-parent</artifactId>
        <version>5.1.2.Final</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>

    <artifactId>wildfly-maven-plugin-tests</artifactId>
    <packaging>pom</packaging>

    <modules>
        <module>bootable-tests</module>
        <module>standalone-tests</module>
        <module>domain-tests</module>
        <module>shared</module>
    </modules>

    <properties>
        <jboss.home>${project.build.directory}${file.separator}wildfly</jboss.home>

        <wildfly.test.config.dir>${project.build.testOutputDirectory}</wildfly.test.config.dir>

        <wildfly.feature.pack.groupId>org.wildfly</wildfly.feature.pack.groupId>
        <wildfly.feature.pack.artifactId>wildfly-ee-galleon-pack</wildfly.feature.pack.artifactId>

        <wildfly.channel.manifest.groupId>org.wildfly.channels</wildfly.channel.manifest.groupId>
        <wildfly.channel.manifest.artifactId>wildfly-ee</wildfly.channel.manifest.artifactId>
    </properties>

    <build>
        <plugins>
            <plugin>
                <groupId>${project.groupId}</groupId>
                <artifactId>wildfly-maven-plugin</artifactId>
                <version>${project.version}</version>
                <configuration>
                    <feature-packs>
                        <feature-pack>
                            <groupId>${wildfly.feature.pack.groupId}</groupId>
                            <artifactId>${wildfly.feature.pack.artifactId}</artifactId>
                            <version>${version.org.wildfly}</version>
                        </feature-pack>
                    </feature-packs>
                    <provisioning-dir>${project.build.directory}/wildfly</provisioning-dir>
                    <galleon-options>
                        <jboss-fork-embedded>${plugin.fork.embedded}</jboss-fork-embedded>
                    </galleon-options>
                </configuration>
                <executions>
                    <execution>
                        <id>provision-wildfly</id>
                        <phase>generate-test-resources</phase>
                        <goals>
                            <goal>provision</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <systemPropertyVariables>
                        <jboss.home>${jboss.home}</jboss.home>
                        <jboss-as.home>${jboss.home}</jboss-as.home>
                        <wildfly.test.version>${version.org.wildfly}</wildfly.test.version>
                        <wildfly.management.port>10099</wildfly.management.port>
                        <wildfly.test.config.dir>${wildfly.test.config.dir}</wildfly.test.config.dir>
                    </systemPropertyVariables>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>security-manager-required</id>
            <activation>
                <jdk>[24,)</jdk>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <configuration>
                            <excludedGroups>org.wildfly.plugin.categories.SecurityManagerRequired</excludedGroups>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>skip-channel-tests</id>
            <activation>
                <property>
                    <name>skip.channel.tests</name>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <configuration>
                            <excludedGroups>org.wildfly.plugin.categories.ChannelsRequired</excludedGroups>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>wildfly-channels</id>
            <activation>
                <property>
                    <name>!version.org.wildfly</name>
                </property>
            </activation>

            <build>
                <plugins>
                    <plugin>
                        <groupId>${project.groupId}</groupId>
                        <artifactId>wildfly-maven-plugin</artifactId>
                        <version>${project.version}</version>
                        <executions>
                            <execution>
                                <id>provision-wildfly</id>
                                <phase>generate-test-resources</phase>
                                <goals>
                                    <goal>provision</goal>
                                </goals>
                                <configuration>
                                    <channels>
                                        <!-- If the version.org.wildfly is blank the newest version of WildFly will be used. Otherwise, be
                                             explicit.
                                         -->
                                        <channel>
                                            <manifest>
                                                <groupId>${wildfly.channel.manifest.groupId}</groupId>
                                                <artifactId>${wildfly.channel.manifest.artifactId}</artifactId>
                                                <version>${version.org.wildfly}</version>
                                            </manifest>
                                        </channel>
                                    </channels>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

</project>
