<?xml version="1.0" encoding="UTF-8"?>
<!--
  ~ JBoss, Home of Professional Open Source.
  ~
  ~ Copyright 2021 Red Hat, Inc., and individual 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/xsd/maven-4.0.0.xsd">
    <parent>
        <groupId>org.jboss.resteasy</groupId>
        <artifactId>resteasy-feature-pack</artifactId>
        <version>6.2.6.Final</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>

    <artifactId>galleon-feature-pack</artifactId>
    <name>RESEasy: Galleon Feature Pack</name>

    <properties>
        <common.resources.directory>${basedir}/../common/src/main/resources</common.resources.directory>
    </properties>


    <dependencies>
        <!-- Feature pack dependencies -->
        <dependency>
            <groupId>org.wildfly</groupId>
            <artifactId>wildfly-ee-galleon-pack</artifactId>
            <type>zip</type>
        </dependency>

        <!-- Add the common dependency to inherit default required dependencies -->
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>resteasy-feature-pack-common</artifactId>
            <version>${project.version}</version>
            <type>pom</type>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <!-- Feature pack generation is vulnerable to leftover files in the target
                     folder from previous builds, so always clean even if the clean lifecycle is not invoked -->
                <artifactId>maven-clean-plugin</artifactId>
                <executions>
                    <execution>
                        <id>auto-clean</id>
                        <phase>initialize</phase>
                        <goals>
                            <goal>clean</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <executions>
                    <!-- Copy the common resources -->
                    <execution>
                        <id>copy-common-feature-pack-resources</id>
                        <phase>process-resources</phase>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${basedir}/target/resources</outputDirectory>
                            <resources>
                                <resource>
                                    <directory>${common.resources.directory}</directory>
                                    <excludes>
                                        <exclude>modules/**/module.xml</exclude>
                                    </excludes>
                                </resource>
                                <resource>
                                    <directory>${common.resources.directory}</directory>
                                    <includes>
                                        <include>modules/**/module.xml</include>
                                    </includes>
                                    <filtering>true</filtering>
                                </resource>
                                <resource>
                                    <directory>${common.resources.directory}</directory>
                                    <includes>
                                        <include>configs/**/model.xml</include>
                                    </includes>
                                </resource>
                            </resources>
                            <overwrite>true</overwrite>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.wildfly.galleon-plugins</groupId>
                <artifactId>wildfly-galleon-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>resteasy-galleon-feature-pack</id>
                        <goals>
                            <goal>build-feature-pack</goal>
                        </goals>
                        <phase>prepare-package</phase>
                        <configuration>
                            <fork-embedded>${galleon.fork.embedded}</fork-embedded>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>
