<?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.tools</groupId>
        <artifactId>wildfly-parent</artifactId>
        <version>1.0.4.Final</version>
    </parent>

    <groupId>org.wildfly.plugins</groupId>
    <artifactId>wildfly-plugin-tools</artifactId>
    <version>1.2.2.Final</version>
    <name>WildFly Plugin Tools</name>

    <description>
        A group of tools for interacting/managing with a WildFly container
    </description>

    <properties>
        <!-- Override the release version -->
        <maven.compiler.release>11</maven.compiler.release>
        <!-- WildFly/JBoss dependencies -->
        <version.org.jboss.logging.jboss-logging>3.6.1.Final</version.org.jboss.logging.jboss-logging>
        <version.org.wildfly.common.wildfly-common>1.7.0.Final</version.org.wildfly.common.wildfly-common>
        <!-- This version property is also retrieved by plugin at runtime to resolve CLI artifact -->
        <version.org.wildfly.core>28.0.0.Final</version.org.wildfly.core>
        <version.org.wildfly.launcher>1.0.2.Final</version.org.wildfly.launcher>
        <!-- Used to override the provisioned version of WildFly. Defaults to empty which is the latest from the channel. -->
        <version.org.wildfly/>

        <!-- Test dependencies -->
        <version.org.junit>5.12.1</version.org.junit>
        <version.org.jboss.shrinkwrap.shrinkwrap>1.2.6</version.org.jboss.shrinkwrap.shrinkwrap>

        <!-- Plugin versions -->
        <version.org.jboss.galleon>6.0.5.Final</version.org.jboss.galleon>
        <version.wildfly-maven-plugin>5.1.2.Final</version.wildfly-maven-plugin>

        <!-- Provisioning properties -->
        <galleon.fork.embedded>true</galleon.fork.embedded>
        <server.test.feature.pack.groupId>org.wildfly</server.test.feature.pack.groupId>
        <server.test.feature.pack.artifactId>wildfly-ee-galleon-pack</server.test.feature.pack.artifactId>

        <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>${version.org.wildfly}</wildfly.channel.manifest.version>

        <!-- checkstyle configuration -->
        <linkXRef>false</linkXRef>

        <wildfly.scm.connection>scm:git://github.com/wildfly/wildfly-plugin-tools.git</wildfly.scm.connection>
        <wildfly.scm.developer.connection>scm:git:git@github.com:wildfly/wildfly-plugin-tools.git
        </wildfly.scm.developer.connection>
        <wildfly.scm.url>https://github.com/wildfly/wildfly-plugin-tools</wildfly.scm.url>

        <!-- Other properties -->
        <maven.test.redirectTestOutputToFile>true</maven.test.redirectTestOutputToFile>

        <jboss.home>${project.build.directory}${file.separator}wildfly</jboss.home>
        <test.class.path>${project.build.testOutputDirectory}</test.class.path>
        <test.jvm.args>-Dmaven.repo.local=${settings.localRepository}</test.jvm.args>
    </properties>
    <url>https://www.wildfly.org</url>

    <issueManagement>
        <system>GitHub</system>
        <url>https://github.com/wildfly/wildfly-plugin-tools/issues</url>
    </issueManagement>

    <scm>
        <connection>${wildfly.scm.connection}</connection>
        <developerConnection>${wildfly.scm.developer.connection}</developerConnection>
        <url>${wildfly.scm.url}</url>
    </scm>

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

    <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>
        <dependency>
            <groupId>org.jboss.logging</groupId>
            <artifactId>jboss-logging</artifactId>
            <version>${version.org.jboss.logging.jboss-logging}</version>
        </dependency>
        <dependency>
            <groupId>org.wildfly.common</groupId>
            <artifactId>wildfly-common</artifactId>
            <version>${version.org.wildfly.common.wildfly-common}</version>
        </dependency>
        <dependency>
            <groupId>org.wildfly.core</groupId>
            <artifactId>wildfly-controller-client</artifactId>
            <version>${version.org.wildfly.core}</version>
        </dependency>
        <dependency>
            <groupId>org.wildfly.launcher</groupId>
            <artifactId>wildfly-launcher</artifactId>
            <version>${version.org.wildfly.launcher}</version>
        </dependency>
        <!-- Seems to be needed as the controller client is transitively bringing it in -->
        <dependency>
            <groupId>org.wildfly.core</groupId>
            <artifactId>wildfly-protocol</artifactId>
            <version>${version.org.wildfly.core}</version>
        </dependency>
        <dependency>
            <groupId>org.jboss.galleon</groupId>
            <artifactId>galleon-api</artifactId>
            <version>${version.org.jboss.galleon}</version>
        </dependency>
        <!-- Test dependencies -->
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.jboss.shrinkwrap</groupId>
            <artifactId>shrinkwrap-api</artifactId>
            <version>${version.org.jboss.shrinkwrap.shrinkwrap}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.jboss.shrinkwrap</groupId>
            <artifactId>shrinkwrap-impl-base</artifactId>
            <version>${version.org.jboss.shrinkwrap.shrinkwrap}</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <testResources>
            <!-- Process default resources -->
            <testResource>
                <directory>src/test/resources</directory>
                <targetPath>${project.build.testOutputDirectory}</targetPath>
            </testResource>
            <!-- Copy the custom modules to the WildFly module directory -->
            <testResource>
                <directory>src/test/modules</directory>
                <filtering>true</filtering>
                <targetPath>${jboss.home}/modules</targetPath>
            </testResource>
        </testResources>
        <plugins>
            <plugin>
                <artifactId>maven-jar-plugin</artifactId>
                <configuration>
                    <archive>
                        <manifestEntries>
                            <Automatic-Module-Name>org.wildfly.plugin.core</Automatic-Module-Name>
                        </manifestEntries>
                    </archive>
                </configuration>
            </plugin>
            <!-- Enable auto-formatting of source files -->
            <plugin>
                <groupId>net.revelc.code.formatter</groupId>
                <artifactId>formatter-maven-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>net.revelc.code</groupId>
                <artifactId>impsort-maven-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.wildfly.plugins</groupId>
                <artifactId>wildfly-maven-plugin</artifactId>
                <version>${version.wildfly-maven-plugin}</version>
                <executions>
                    <execution>
                        <id>server-provisioning</id>
                        <phase>generate-test-resources</phase>
                        <goals>
                            <goal>provision</goal>
                        </goals>
                        <configuration>
                            <provisioning-dir>${jboss.home}</provisioning-dir>
                            <feature-packs>
                                <feature-pack>
                                    <groupId>${server.test.feature.pack.groupId}</groupId>
                                    <artifactId>${server.test.feature.pack.artifactId}</artifactId>
                                    <version>${version.org.wildfly}</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>${galleon.fork.embedded}</jboss-fork-embedded>
                            </galleon-options>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <!-- We need to bind a new execution of this to run after provisioning is done so the module.xml file
                 required for testing is not deleted.
            -->
            <plugin>
                <artifactId>maven-resources-plugin</artifactId>
                <executions>
                    <execution>
                        <id>copy-module</id>
                        <phase>pre-integration-test</phase>
                        <goals>
                            <goal>testResources</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <systemProperties>
                        <test.deployment.dir>${project.build.testOutputDirectory}</test.deployment.dir>
                    </systemProperties>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-failsafe-plugin</artifactId>
                <configuration>
                    <redirectTestOutputToFile>${maven.test.redirectTestOutputToFile}</redirectTestOutputToFile>
                    <systemPropertyVariables>
                        <jboss.home>${jboss.home}</jboss.home>
                        <test.jvm.args>${test.jvm.args}</test.jvm.args>
                    </systemPropertyVariables>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>integration-test</goal>
                            <goal>verify</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>wildfly-34</id>
            <activation>
                <jdk>(,17)</jdk>
            </activation>
            <properties>
                <version.org.wildfly>34.0.1.Final</version.org.wildfly>
            </properties>
        </profile>
        <profile>
            <id>format-check</id>
            <build>
                <plugins>
                    <!-- Validate formatting -->
                    <plugin>
                        <groupId>net.revelc.code.formatter</groupId>
                        <artifactId>formatter-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>validate-format</id>
                                <phase>validate</phase>
                                <goals>
                                    <goal>validate</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>net.revelc.code</groupId>
                        <artifactId>impsort-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>check-import-sort</id>
                                <phase>validate</phase>
                                <goals>
                                    <goal>check</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

    <!-- required when provisioning the server for tests, using Galleon plugin to be removed when WF doesn't require them -->
    <repositories>
        <repository>
            <id>nexus</id>
            <url>https://repository.jboss.org/nexus/content/groups/public</url>
        </repository>
    </repositories>
</project>
