<?xml version="1.0" encoding="UTF-8"?>
<!--
  ~ Licensed to the Apache Software Foundation (ASF) under one
  ~ or more contributor license agreements. See the NOTICE file
  ~ distributed with this work for additional information
  ~ regarding copyright ownership. The ASF licenses this file
  ~ to you 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/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>org.apache.ws.commons.axiom</groupId>
        <artifactId>systests</artifactId>
        <version>1.4.0</version>
    </parent>

    <artifactId>wildfly-tests</artifactId>
    <packaging>jar</packaging>

    <name>Wildfly Tests</name>

    <properties>
        <wildfly.version>26.1.0.Final</wildfly.version>
        <wildfly.home>${project.build.directory}/wildfly-preview-${wildfly.version}</wildfly.home>
        <wildfly.jigsawArgs>--add-modules java.se</wildfly.jigsawArgs>
    </properties>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.wildfly</groupId>
                <artifactId>wildfly-preview-dist</artifactId>
                <!-- This makes the version manageable with Dependabot  -->
                <version>${wildfly.version}</version>
            </dependency>
        </dependencies>
    </dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>axiom-impl</artifactId>
            <version>${project.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.jboss.arquillian.junit</groupId>
            <artifactId>arquillian-junit-container</artifactId>
            <version>1.6.0.Final</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.wildfly.arquillian</groupId>
            <artifactId>wildfly-arquillian-container-managed</artifactId>
            <version>5.0.0.Alpha2</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <testResources>
            <testResource>
                <directory>src/test/resources</directory>
                <filtering>true</filtering>
            </testResource>
        </testResources>
        <plugins>
            <plugin>
                <groupId>com.github.veithen.maven</groupId>
                <artifactId>hermetic-maven-plugin</artifactId>
                <configuration>
                    <!-- Wildfly/Arquillian doesn't support custom security managers and will instead
                         set up Wildfly's security manager, for which the generated policy isn't
                         appropriate. -->
                    <skip>true</skip>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <skip>true</skip>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <!-- Copy the dependencies that will be included in the WAR deployed
                             to Wildfly. This is necessary because Arquillian's Maven dependency
                             resolution doesn't work correctly if some of the dependencies are
                             snapshots from the current reactor. -->
                        <id>copy-deps</id>
                        <!-- axiom-api and axiom-impl may be part of the reactor. To make sure
                             that the package phase has been executed on these dependencies
                             (which is a requirement to be able to copy them), we need to execute
                             the copy-dependencies goal after the package phase. Note that this
                             implies that we need to execute the tests as integration tests. -->
                        <phase>pre-integration-test</phase>
                        <goals>
                            <goal>copy-dependencies</goal>
                        </goals>
                        <configuration>
                            <includeArtifactIds>axiom-api,axiom-impl,woodstox-core,stax2-api</includeArtifactIds>
                            <outputDirectory>${project.build.directory}/deps</outputDirectory>
                        </configuration>
                    </execution>
                    <execution>
                        <!-- We would prefer using wildfly-server-provisioning-maven-plugin to
                             provision the server, but unfortunately the Wildfly community is still
                             unable to ensure that all required artifacts are available from Maven
                             central and the JBoss Maven repository isn't stable. -->
                        <id>unpack-wildfly</id>
                        <phase>pre-integration-test</phase>
                        <goals>
                            <goal>unpack</goal>
                        </goals>
                        <configuration>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>org.wildfly</groupId>
                                    <artifactId>wildfly-preview-dist</artifactId>
                                    <type>zip</type>
                                    <overWrite>false</overWrite>
                                    <outputDirectory>target</outputDirectory>
                                </artifactItem>
                            </artifactItems>
                        </configuration>
                    </execution>
                </executions>
                <configuration>
                    <skip>${skipTests}</skip>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>build-helper-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>reserve-network-port</id>
                        <goals>
                            <goal>reserve-network-port</goal>
                        </goals>
                        <phase>initialize</phase>
                        <configuration>
                            <portNames>
                                <portName>wildfly.managementPort</portName>
                                <portName>wildfly.httpPort</portName>
                            </portNames>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <artifactId>maven-failsafe-plugin</artifactId>
                <executions>
                    <execution>
                        <goals>
                            <goal>integration-test</goal>
                            <goal>verify</goal>
                        </goals>
                        <configuration>
                            <includes>
                                <include>**/*Test.java</include>
                            </includes>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>
