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

     Copyright 2022 Red Hat

     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

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

    <parent>
        <groupId>org.wildfly.extras.grpc</groupId>
        <artifactId>wildfly-grpc-galleon-pack-parent</artifactId>
        <version>0.1.3.Final</version>
        <relativePath>../pom.xml</relativePath>
    </parent>

    <artifactId>wildfly-grpc-feature-pack</artifactId>
    <name>WildFly gRPC :: Feature Pack</name>
    <packaging>pom</packaging>

    <properties>
        <common.resources.directory>${basedir}/../common/src/main/resources</common.resources.directory>
        <license.output.directory>${project.build.directory}/resources/content/docs/licenses</license.output.directory>
        <license.src.directory>${basedir}/src/license</license.src.directory>
    </properties>

    <dependencies>
        <!-- Other feature pack dependencies -->
        <dependency>
            <groupId>org.wildfly</groupId>
            <artifactId>wildfly-galleon-pack</artifactId>
            <version>${version.wildfly}</version>
            <type>zip</type>
        </dependency>

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

    <build>
        <finalName>${server.name}</finalName>
        <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>
                    <execution>
                        <id>copy-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>
                            </resources>
                            <overwrite>true</overwrite>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.wildfly.galleon-plugins</groupId>
                <artifactId>wildfly-galleon-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>wildfly-grpc-feature-pack-build</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>
