<?xml version="1.0" encoding="UTF-8"?>
<!--

    Copyright 2020 Red Hat, Inc. and/or its affiliates
    and other contributors as indicated by the @author tags.

    Licensed 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/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>org.wildfly.plugins</groupId>
        <artifactId>wildfly-jar-parent</artifactId>
        <version>7.0.1.Final</version>
    </parent>

    <artifactId>wildfly-jar-maven-plugin</artifactId>
    <packaging>maven-plugin</packaging>

    <name>WildFly Bootable JAR Maven Plugin</name>

    <properties>
        <!-- Galleon -->
        <galleon.fork.embedded>true</galleon.fork.embedded>
        <galleon.log.time>true</galleon.log.time>
        <galleon.offline>false</galleon.offline>
        <jboss.home>${project.build.directory}${file.separator}wildfly</jboss.home>
        <!-- Used in the test module.xml -->
        <test.class.path>${project.build.testOutputDirectory}</test.class.path>
        <test.jvm.args>-Dmaven.repo.local=${settings.localRepository}</test.jvm.args>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.twdata.maven</groupId>
            <artifactId>mojo-executor</artifactId>
        </dependency>
        <dependency>
          <groupId>${project.groupId}</groupId>
          <artifactId>wildfly-jar-cloud-extension</artifactId>
        </dependency>
        <dependency>
            <groupId>org.jboss.galleon</groupId>
            <artifactId>galleon-maven-plugin</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.maven</groupId>
            <artifactId>maven-core</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.maven.plugin-tools</groupId>
            <artifactId>maven-plugin-annotations</artifactId>
            <scope>provided</scope>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.wildfly.core</groupId>
            <artifactId>wildfly-launcher</artifactId>
        </dependency>
        <dependency>
            <groupId>org.wildfly.plugins</groupId>
            <artifactId>wildfly-plugin-core</artifactId>
            <exclusions>
              <exclusion>
                    <groupId>org.jboss.modules</groupId>
                    <artifactId>jboss-modules</artifactId>
              </exclusion>
          </exclusions>
        </dependency>
        <dependency>
            <groupId>org.wildfly.plugins</groupId>
            <artifactId>wildfly-maven-plugin</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>org.apache.maven</groupId>
                    <artifactId>maven-core</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.jboss.modules</groupId>
                    <artifactId>jboss-modules</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.wildfly.core</groupId>
                    <artifactId>wildfly-cli</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.jboss.logmanager</groupId>
                    <artifactId>jboss-logmanager</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <!-- Required by Galleon during provisioning --> 
        <dependency>
            <groupId>org.wildfly.common</groupId>
            <artifactId>wildfly-common</artifactId>
        </dependency>
        <!-- Test dependencies -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <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>
            <!-- 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>test-compile</phase>
                        <goals>
                            <goal>testResources</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-enforcer-plugin</artifactId>
                <version>${version.enforcer.plugin}</version>
                <executions>
                    <execution>
                        <id>ban-bad-dependencies</id>
                        <goals>
                            <goal>enforce</goal>
                        </goals>
                        <configuration>
                            <rules>
                                <bannedDependencies>
                                    <searchTransitive>true</searchTransitive>
                                    <excludes>
                                        <!-- we don't want these in the plugin classpath -->
                                        <exclude>org.jboss.modules:jboss-modules</exclude>
                                        <exclude>org.wildfly.core:wildfly-cli</exclude>
                                        <exclude>org.wildfly.core:wildfly-embedded</exclude>
                                        <exclude>org.wildfly.core:wildfly-patching</exclude>
                                        <exclude>org.jboss.logmanager:jboss-logmanager</exclude>
                                    </excludes>
                                </bannedDependencies>
                            </rules>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-plugin-plugin</artifactId>
                <configuration>
                    <!-- see http://jira.codehaus.org/browse/MNG-5346 -->
                    <!--<skipErrorNoDescriptorsFound>true</skipErrorNoDescriptorsFound>-->
                    <goalPrefix>wildfly-jar</goalPrefix>
                </configuration>

                <executions>
                    <execution>
                        <id>mojo-descriptor</id>
                        <goals>
                            <goal>descriptor</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>help-goal</id>
                        <goals>
                            <goal>helpmojo</goal>
                        </goals>
                        <configuration>
                            <helpPackageName>org.wildfly.plugin.bootablejar.maven.generated</helpPackageName>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <systemPropertyVariables>
                        <jboss.home>${jboss.home}</jboss.home>
                        <test.jvm.args>${test.jvm.args}</test.jvm.args>
                    </systemPropertyVariables>
                    <redirectTestOutputToFile>${surefire.redirect.to.file}</redirectTestOutputToFile>
                </configuration>
            </plugin>
            <!-- Used to test the BootLoggingConfiguration -->
            <plugin>
                <groupId>org.jboss.galleon</groupId>
                <artifactId>galleon-maven-plugin</artifactId>
                <version>${version.org.jboss.galleon}</version>
                <executions>
                    <execution>
                        <id>server-provisioning</id>
                        <goals>
                            <goal>provision</goal>
                        </goals>
                        <configuration>
                            <install-dir>${jboss.home}</install-dir>
                            <skip>${skipTests}</skip>
                            <record-state>false</record-state>
                            <log-time>${galleon.log.time}</log-time>
                            <offline>${galleon.offline}</offline>
                            <plugin-options>
                                <jboss-maven-dist />
                                <jboss-fork-embedded>${galleon.fork.embedded}</jboss-fork-embedded>
                                <optional-packages>passive+</optional-packages>`
                            </plugin-options>
                            <feature-packs>
                                <feature-pack>
                                    <groupId>org.wildfly.core</groupId>
                                    <artifactId>wildfly-core-galleon-pack</artifactId>
                                    <version>${version.org.wildfly.core.wildfly-core}</version>
                                    <inherit-configs>false</inherit-configs>
                                    <inherit-packages>false</inherit-packages>
                                </feature-pack>
                            </feature-packs>
                            <configurations>
                                <config>
                                    <model>standalone</model>
                                    <name>standalone.xml</name>
                                    <layers>
                                        <layer>logging</layer>
                                        <layer>management</layer>
                                    </layers>
                                </config>
                            </configurations>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.wildfly.extras</groupId>
                <artifactId>adoc-maven-plugin-descriptor</artifactId>
                <version>1.0.0.Alpha2</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>asciidoc-descriptor</goal>
                        </goals>
                        <phase>prepare-package</phase>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

</project>
