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

<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xmlns="http://maven.apache.org/POM/4.0.0"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>org.jboss</groupId>
        <artifactId>jboss-parent</artifactId>
        <version>47</version>
    </parent>

    <groupId>org.wildfly.launcher</groupId>
    <artifactId>wildfly-launcher</artifactId>
    <version>1.0.0.Final</version>

    <name>WildFly: Launcher API</name>
    <description>Tooling for launching WildFly technology stack processes.</description>

    <licenses>
        <license>
            <name>Apache License 2.0</name>
            <url>https://repository.jboss.org/licenses/apache-2.0.txt</url>
            <distribution>repo</distribution>
        </license>
    </licenses>

    <scm>
        <connection>scm:git:${wildfly.launcher.scm.connection}</connection>
        <developerConnection>scm:git:${wildfly.launcher.scm.connection}</developerConnection>
        <url>${wildfly.launcher.scm.url}</url>
    </scm>
    <url>https://wildfly.org</url>

    <properties>
        <wildfly.launcher.scm.connection>git@github.com:wildfly/wildfly-launcher.git</wildfly.launcher.scm.connection>
        <wildfly.launcher.scm.url>https://github.com/wildfly/wildfly-launcher</wildfly.launcher.scm.url>

        <wildfly.bootable.jar.name>wildfly-bootable.jar</wildfly.bootable.jar.name>
        <wildfly.launcher.bootable.jar>${basedir}/target/${wildfly.bootable.jar.name}</wildfly.launcher.bootable.jar>

        <!-- Base on SE 11. -->
        <maven.compiler.release>11</maven.compiler.release>
        <maven.compiler.source>${maven.compiler.release}</maven.compiler.source>
        <maven.compiler.target>${maven.compiler.release}</maven.compiler.target>

        <!-- Dependency versions -->

        <!-- Non-default maven plugin versions and configuration -->
        <version.org.wildfly.checkstyle-config>1.0.8.Final</version.org.wildfly.checkstyle-config>
        <version.org.wildfly.plugins.wildfly-maven-plugin>5.1.0.Beta2</version.org.wildfly.plugins.wildfly-maven-plugin>

        <!-- Production/build time dependencies-->
        <version.org.jboss.logging.jboss-logging>3.6.1.Final</version.org.jboss.logging.jboss-logging>
        <version.org.jboss.logging.jboss-logging-tools>3.0.3.Final</version.org.jboss.logging.jboss-logging-tools>
        <!-- Test dependencies -->
        <version.org.jboss.modules.jboss-modules>2.1.6.Final</version.org.jboss.modules.jboss-modules>
        <version.org.junit>5.11.3</version.org.junit>

        <!-- Test properties -->
        <maven.test.redirectTestOutputToFile>true</maven.test.redirectTestOutputToFile>
        <test.modules.path>${project.build.directory}/test-modules</test.modules.path>

        <!-- Provisioning properties for tests -->
        <jboss.home>${project.build.directory}/server</jboss.home>

        <wildfly.feature.pack.groupId>org.wildfly</wildfly.feature.pack.groupId>
        <wildfly.feature.pack.artifactId>wildfly-ee-galleon-pack</wildfly.feature.pack.artifactId>
        <!-- Keep default at WildFly 34 as WildFly 35+ requires Java 17. Once this project requires Java 17, this
             property should be set to an empty property.
         -->
        <wildfly.feature.pack.version>34.0.0.Final</wildfly.feature.pack.version>

        <wildfly.channel.manifest.groupId>org.wildfly.channels</wildfly.channel.manifest.groupId>
        <wildfly.channel.manifest.artifactId>wildfly-ee</wildfly.channel.manifest.artifactId>
        <wildfly.channel.manifest.version>${wildfly.feature.pack.version}</wildfly.channel.manifest.version>
    </properties>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.junit</groupId>
                <artifactId>junit-bom</artifactId>
                <version>${version.org.junit}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <dependencies>
        <!-- This dependency is only needed at compile time and requires no runtime dependencies -->
        <dependency>
            <groupId>org.jboss.logging</groupId>
            <artifactId>jboss-logging-annotations</artifactId>
            <version>${version.org.jboss.logging.jboss-logging-tools}</version>
            <!-- This is a compile-time dependency of this project, but is not needed at compile or runtime by other
                  projects that depend on this project.-->
            <scope>provided</scope>
            <optional>true</optional>
        </dependency>

        <!-- Test dependencies -->
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.jboss.modules</groupId>
            <artifactId>jboss-modules</artifactId>
            <version>${version.org.jboss.modules.jboss-modules}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.wildfly.plugins</groupId>
            <artifactId>wildfly-plugin-tools</artifactId>
            <version>1.2.0.Beta2</version>
            <scope>test</scope>
            <exclusions>
                <!-- Use this launcher API -->
                <exclusion>
                    <groupId>org.wildfly.launcher</groupId>
                    <artifactId>wildfly-launcher</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

    </dependencies>

    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <configuration>
                        <annotationProcessorPaths>
                            <path>
                                <groupId>org.jboss.logging</groupId>
                                <artifactId>jboss-logging-processor</artifactId>
                                <version>${version.org.jboss.logging.jboss-logging-tools}</version>
                            </path>
                        </annotationProcessorPaths>
                    </configuration>
                </plugin>
                <plugin>
                    <artifactId>maven-jar-plugin</artifactId>
                    <configuration>
                        <!-- Do not package the generated logging properties as the generated binaries will be packaged -->
                        <!-- These files are not required at runtime -->
                        <excludes>
                            <exclude>**/*.i18n.properties</exclude>
                            <exclude>**/*.i18n_*.properties</exclude>
                        </excludes>
                    </configuration>
                </plugin>
                <!-- Checkstyle -->
                <plugin>
                    <artifactId>maven-checkstyle-plugin</artifactId>
                    <executions>
                        <execution>
                            <id>check-style</id>
                            <phase>compile</phase>
                            <goals>
                                <goal>checkstyle</goal>
                            </goals>
                        </execution>
                    </executions>
                    <dependencies>
                        <dependency>
                            <groupId>org.wildfly.checkstyle</groupId>
                            <artifactId>wildfly-checkstyle-config</artifactId>
                            <version>${version.org.wildfly.checkstyle-config}</version>
                        </dependency>
                    </dependencies>
                    <configuration>
                        <configLocation>wildfly-checkstyle/checkstyle.xml</configLocation>
                        <consoleOutput>true</consoleOutput>
                        <failsOnError>true</failsOnError>
                        <suppressionsLocation>checkstyle-suppressions.xml</suppressionsLocation>
                        <includeTestSourceDirectory>true</includeTestSourceDirectory>
                        <excludes>**/*$logger.java,**/*$bundle.java,**/module-info.java</excludes>
                    </configuration>
                </plugin>

                <!-- Require Java 11 for deploying -->
                <plugin>
                    <artifactId>maven-enforcer-plugin</artifactId>
                    <executions>
                        <execution>
                            <id>require-java11</id>
                            <goals>
                                <goal>enforce</goal>
                            </goals>
                            <phase>deploy</phase>
                            <configuration>
                                <rules>
                                    <requireJavaVersion>
                                        <version>[11,12)</version>
                                    </requireJavaVersion>
                                </rules>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </pluginManagement>
        <plugins>
            <plugin>
                <artifactId>maven-checkstyle-plugin</artifactId>
            </plugin>
            <!-- Create a fake WildFly directory -->
            <plugin>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <id>copy-deps</id>
                        <phase>test-compile</phase>
                        <goals>
                            <goal>copy</goal>
                        </goals>
                        <configuration>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>org.jboss.modules</groupId>
                                    <artifactId>jboss-modules</artifactId>
                                    <type>jar</type>
                                    <overWrite>true</overWrite>
                                    <outputDirectory>${test.modules.path}</outputDirectory>
                                    <destFileName>jboss-modules.jar</destFileName>
                                </artifactItem>
                            </artifactItems>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <artifactId>maven-javadoc-plugin</artifactId>
                <configuration>
                    <source>${maven.compiler.release}</source>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <systemPropertyVariables>
                        <jboss.home>${jboss.home}</jboss.home>
                        <wildfly.launcher.home>${test.modules.path}</wildfly.launcher.home>
                        <wildfly.launcher.bootable.jar>${wildfly.launcher.bootable.jar}</wildfly.launcher.bootable.jar>
                    </systemPropertyVariables>
                </configuration>
                <executions>
                    <execution>
                        <id>default-test</id>
                        <phase>test</phase>
                        <goals>
                            <goal>test</goal>
                        </goals>
                        <configuration>
                            <excludedGroups>new-jvm,non-modular</excludedGroups>
                        </configuration>
                    </execution>
                    <execution>
                        <id>new-jvm</id>
                        <phase>test</phase>
                        <goals>
                            <goal>test</goal>
                        </goals>
                        <configuration>
                            <groups>new-jvm</groups>
                            <reuseForks>false</reuseForks>
                        </configuration>
                    </execution>
                    <execution>
                        <id>non-modular-tests</id>
                        <phase>test</phase>
                        <goals>
                            <goal>test</goal>
                        </goals>
                        <configuration>
                            <groups>non-modular</groups>
                            <useModulePath>false</useModulePath>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.wildfly.plugins</groupId>
                <artifactId>wildfly-maven-plugin</artifactId>
                <version>${version.org.wildfly.plugins.wildfly-maven-plugin}</version>
                <configuration>
                    <jboss-home>${jboss.home}</jboss-home>
                    <provisioning-dir>${jboss.home}</provisioning-dir>
                    <feature-packs>
                        <feature-pack>
                            <groupId>${wildfly.feature.pack.groupId}</groupId>
                            <artifactId>${wildfly.feature.pack.artifactId}</artifactId>
                            <version>${wildfly.feature.pack.version}</version>
                        </feature-pack>
                    </feature-packs>
                    <channels>
                        <!-- If the server.version 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>${wildfly.channel.manifest.version}</version>
                            </manifest>
                        </channel>
                    </channels>
                    <galleon-options>
                        <jboss-maven-dist/>
                        <jboss-fork-embedded>true</jboss-fork-embedded>
                    </galleon-options>
                </configuration>
                <executions>
                    <execution>
                        <id>provision-test-server</id>
                        <phase>process-test-classes</phase>
                        <goals>
                            <goal>provision</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>provision-bootable-jar</id>
                        <phase>process-test-classes</phase>
                        <goals>
                            <goal>package</goal>
                        </goals>
                        <configuration>
                            <provisioning-dir>${project.build.directory}/bootable-jar-working</provisioning-dir>
                            <bootable-jar>true</bootable-jar>
                            <bootable-jar-name>${wildfly.bootable.jar.name}</bootable-jar-name>
                            <skipDeployment>true</skipDeployment>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>

    </build>

</project>
