<?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">
    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>org.wildfly</groupId>
        <artifactId>mvc-krazo-parent</artifactId>
        <!--
        Maintain separation between the artifact id and the version to help prevent
        merge conflicts between commits changing the GA and those changing the V.
        -->
        <version>2.0.1.Final</version>
        <relativePath>../../pom.xml</relativePath>
    </parent>

    <artifactId>mvc-krazo-tck-runner</artifactId>
    <packaging>jar</packaging>

    <name>WildFly Jakarta MVC with Krazo -- TCK Runner</name>
    <description>WildFly TCK Runner for Jakarta MVC integration</description>

    <properties>

        <version.org.jboss.arquillian>1.9.5.Final</version.org.jboss.arquillian>
        <version.org.wildfly.arquillian>5.0.1.Final</version.org.wildfly.arquillian>

        <version.jakarta.mvc.tck>${version.jakarta.mvc}</version.jakarta.mvc.tck>

        <surefire.memory.args>-Xmx512m -XX:MetaspaceSize=128m</surefire.memory.args>
        <surefire.jpda.args>-agentlib:jdwp=transport=dt_socket,address=*:${as.debug.port},server=y,suspend=y</surefire.jpda.args>
        <as.debug.port>8787</as.debug.port>
        <surefire.system.args>${surefire.memory.args}</surefire.system.args>
        <server.jvm.args>${surefire.memory.args}</server.jvm.args>
        <server.jboss.args>--stability=preview</server.jboss.args>
        <!-- Feature pack to use to provision mvc-krazo -->
        <krazo.feature.pack.groupId>${project.groupId}</krazo.feature.pack.groupId>
        <krazo.feature.pack.artifactId>wildfly-mvc-krazo-feature-pack</krazo.feature.pack.artifactId>
        <krazo.feature.pack.version>${project.version}</krazo.feature.pack.version>

        <!-- Base feature pack to use for provisioning if the something other
             than the wildfly-mvc-krazo-feature-pack's wildfly-ee dependent is wanted -->
        <base.feature.pack.groupId>org.wildfly</base.feature.pack.groupId>
        <base.feature.pack.artifactId>wildfly-ee-galleon-pack</base.feature.pack.artifactId>
        <base.feature.pack.version>${version.org.wildfly}</base.feature.pack.version>
        <!-- For some reason this needs to be true if base.feature.pack.artifactId=wildfly-galleon-pack
             But make it externally controllable in case someone wants to test with this turned off -->
        <ignore.not.excluded.layers>true</ignore.not.excluded.layers>
    </properties>

    <dependencyManagement>
        <dependencies>
            <!-- Import the arquillian bom before the mvc-tck one, as it declares an old version of the arq bom -->
            <dependency>
                <groupId>org.jboss.arquillian</groupId>
                <artifactId>arquillian-bom</artifactId>
                <version>${version.org.jboss.arquillian}</version>
                <scope>import</scope>
                <type>pom</type>
            </dependency>
            <dependency>
                <groupId>jakarta.mvc.tck</groupId>
                <artifactId>mvc-tck-bom</artifactId>
                <version>${version.jakarta.mvc.tck}</version>
                <scope>import</scope>
                <type>pom</type>
            </dependency>

            <dependency>
                <groupId>org.wildfly.arquillian</groupId>
                <artifactId>wildfly-arquillian-container-managed</artifactId>
                <version>${version.org.wildfly.arquillian}</version>
                <scope>test</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <dependencies>

        <!-- Client side use of Jakarta EE -->
        <dependency>
            <groupId>jakarta.platform</groupId>
            <artifactId>jakarta.jakartaee-web-api</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>jakarta.mvc.tck</groupId>
            <artifactId>mvc-tck-api</artifactId>
        </dependency>

        <dependency>
            <groupId>jakarta.mvc.tck</groupId>
            <artifactId>mvc-tck-tests</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.wildfly.arquillian</groupId>
            <artifactId>wildfly-arquillian-container-managed</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.jboss.shrinkwrap.resolver</groupId>
            <artifactId>shrinkwrap-resolver-depchain</artifactId>
            <scope>compile</scope>
            <type>pom</type>
        </dependency>

    </dependencies>

    <build>
        <plugins>

            <!-- Provision traditional unzipped server installations -->
            <plugin>
                <groupId>org.wildfly.plugins</groupId>
                <artifactId>wildfly-maven-plugin</artifactId>
                <configuration>
                    <log-provisioning-time>${galleon.log.time}</log-provisioning-time>
                    <offline-provisioning>${galleon.offline}</offline-provisioning>
                    <record-provisioning-state>true</record-provisioning-state>
                    <overwrite-provisioned-server>true</overwrite-provisioned-server>
                    <galleon-options>
                        <jboss-fork-embedded>${galleon.fork.embedded}</jboss-fork-embedded>
                        <optional-packages>passive+</optional-packages>
                        <config-stability-level>preview</config-stability-level>
                        <package-stability-level>experimental</package-stability-level>
                    </galleon-options>
                </configuration>
                <executions>
                    <!-- Provision with layers -->
                    <execution>
                        <id>wildfly-layers-provisioning</id>
                        <goals>
                            <goal>provision</goal>
                        </goals>
                        <phase>compile</phase>
                        <configuration>
                            <provisioning-dir>${project.build.directory}/wildfly-layers</provisioning-dir>
                            <layers>
                                <layer>core-server</layer>
                                <layer>mvc-krazo</layer>
                            </layers>
                        </configuration>
                    </execution>
                    <!-- Provision a full installation -->
                    <execution>
                        <id>wildfly-complete-provisioning</id>
                        <goals>
                            <goal>provision</goal>
                        </goals>
                        <phase>compile</phase>
                        <configuration>
                            <provisioning-dir>${project.build.directory}/wildfly-complete</provisioning-dir>
                        </configuration>
                    </execution>
                    <!-- Add the mvc-krazo subsystem to the wildfly-complete dist's standalone.xml -->
                    <execution>
                        <id>configure-mvc-krazo-subsystem</id>
                        <phase>compile</phase>
                        <goals>
                            <goal>execute-commands</goal>
                        </goals>
                        <configuration>
                            <jboss-home>${project.build.directory}/wildfly-complete</jboss-home>
                            <offline>true</offline>
                            <commands>
                                <command>embed-server --stability=preview</command>
                                <command>/extension=org.wildfly.extension.mvc-krazo:add</command>
                                <command>/subsystem=mvc-krazo:add</command>
                                <command>stop-embedded-server</command>
                            </commands>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <dependenciesToScan>jakarta.mvc.tck:mvc-tck-tests</dependenciesToScan>
                    <systemProperties>
                        <arquillian.launch>wildfly</arquillian.launch>
                        <ee.jakarta.tck.mvc.api.BaseArchiveProvider>
                            org.wildfly.extension.mvc.krazo.tck.WildFlyArchiveProvider
                        </ee.jakarta.tck.mvc.api.BaseArchiveProvider>
                        <server.jvm.args>${server.jvm.args}</server.jvm.args>
                        <server.jboss.args>${server.jboss.args}</server.jboss.args>
                    </systemProperties>
                    <argLine>${surefire.system.args}</argLine>
                </configuration>
                <executions>
                    <execution>
                        <id>default-test</id>
                        <phase>none</phase>
                    </execution>
                    <execution>
                        <id>layers-tests</id>
                        <phase>test</phase>
                        <goals>
                            <goal>test</goal>
                        </goals>
                        <configuration>
                            <systemProperties>
                                <jboss.home>${project.build.directory}/wildfly-layers</jboss.home>
                            </systemProperties>
                            <reportNameSuffix>wildfly-layers</reportNameSuffix>
                        </configuration>
                    </execution>
                    <execution>
                        <id>complete-dist-tests</id>
                        <phase>test</phase>
                        <goals>
                            <goal>test</goal>
                        </goals>
                        <configuration>
                            <systemProperties>
                                <jboss.home>${project.build.directory}/wildfly-complete</jboss.home>
                            </systemProperties>
                            <reportNameSuffix>wildfly-complete</reportNameSuffix>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <profiles>

        <!-- Default single feature pack provisioning -->
        <profile>
            <id>default.provisioning.profile</id>
            <activation>
                <property>
                    <name>!base.feature.pack.artifactId</name>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.wildfly.plugins</groupId>
                        <artifactId>wildfly-maven-plugin</artifactId>
                        <configuration>
                            <feature-packs>
                                <feature-pack>
                                    <location>${krazo.feature.pack.groupId}:${krazo.feature.pack.artifactId}:${krazo.feature.pack.version}</location>
                                </feature-pack>
                            </feature-packs>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <!-- mvc-krazo on top of an externally specified base FP provisioning -->
        <profile>
            <id>specified.base.provisioning.profile</id>
            <activation>
                <property>
                    <name>base.feature.pack.version</name>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.wildfly.plugins</groupId>
                        <artifactId>wildfly-maven-plugin</artifactId>
                        <configuration>
                            <galleon-options>
                                <!-- For some reason this needs to be true if base.feature.pack.artifactId=wildfly-galleon-pack -->
                                <ignore-not-excluded-layers>${ignore.not.excluded.layers}</ignore-not-excluded-layers>
                            </galleon-options>
                            <feature-packs>
                                <feature-pack>
                                    <location>${base.feature.pack.groupId}:${base.feature.pack.artifactId}:${base.feature.pack.version}</location>
                                    <inherit-packages>false</inherit-packages>
                                </feature-pack>
                                <feature-pack>
                                    <location>${krazo.feature.pack.groupId}:${krazo.feature.pack.artifactId}:${krazo.feature.pack.version}</location>
                                </feature-pack>
                            </feature-packs>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <!--
          Debugging profiles.
        -->
        <profile>
            <id>debug.profile</id>
            <activation><property><name>debug</name></property></activation>
            <properties>
                <server.jvm.args>${surefire.memory.args} ${surefire.jpda.args}</server.jvm.args>
            </properties>
        </profile>
        <profile>
            <id>debug.client.profile</id>
            <activation><property><name>debug-client</name></property></activation>
            <properties>
                <surefire.system.args>${surefire.memory.args} ${surefire.jpda.args}</surefire.system.args>
            </properties>
        </profile>
    </profiles>

</project>
