<?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.core</groupId>
        <artifactId>wildfly-core-feature-pack-parent</artifactId>
        <version>27.1.10.Final-redhat-00001</version>
    </parent>

    <artifactId>wildfly-core-galleon-pack</artifactId>

    <name>WildFly: Core Galleon Pack</name>
    <packaging>pom</packaging>

    <properties>
        <license.directory>${project.build.directory}/resources/content/docs/licenses</license.directory>
        <common.resources.directory>${basedir}/../common/src/main/resources</common.resources.directory>
        <ee-10-api.resources.directory>${basedir}/../ee-10-api/src/main/resources</ee-10-api.resources.directory>
        <galleon-common.resources.directory>${basedir}/../galleon-common/src/main/resources</galleon-common.resources.directory>
        <galleon-cli-shaded.resources.directory>${basedir}/../../cli/target/resources</galleon-cli-shaded.resources.directory>
        <galleon-elytron-tools-shaded.resources.directory>${basedir}/../../elytron-tool-wrapper/target/resources</galleon-elytron-tools-shaded.resources.directory>
    </properties>

    <dependencies>

        <dependency>
            <groupId>org.wildfly.galleon-plugins</groupId>
            <artifactId>wildfly-galleon-plugins</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.wildfly.galleon-plugins</groupId>
            <artifactId>wildfly-config-gen</artifactId>
            <scope>provided</scope>
        </dependency>

        <!-- module and copy artifact dependencies -->

        <!-- Bring in all the common deps in one go -->
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>wildfly-core-feature-pack-common</artifactId>
            <type>pom</type>
            <scope>provided</scope>
        </dependency>

        <!-- Bring in all the EE 10 API deps in one go -->
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>wildfly-core-feature-pack-ee-10-api</artifactId>
            <type>pom</type>
            <scope>provided</scope>
        </dependency>

        <!-- Add this dependency to make sure that the core model is tested before we build the server -->
        <dependency>
            <groupId>org.wildfly.core</groupId>
            <artifactId>wildfly-core-model-test-framework</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>org.wildfly.core</groupId>
                    <artifactId>wildfly-model-test</artifactId>
                </exclusion>
            </exclusions>
            <scope>provided</scope>
        </dependency>

    </dependencies>

    <build>
        <finalName>${server.output.dir.prefix}-galleon-pack-${project.version}</finalName>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <id>unpack</id>
                        <phase>generate-resources</phase>
                        <goals>
                            <goal>unpack</goal>
                        </goals>
                        <configuration>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>commons-daemon</groupId>
                                    <artifactId>commons-daemon</artifactId>
                                    <version>${version.commons-daemon}</version>
                                    <classifier>bin-windows</classifier>
                                    <type>zip</type>
                                    <overWrite>true</overWrite>
                                    <outputDirectory>${project.build.directory}/resources/content/docs/contrib/scripts/service/</outputDirectory>
                                    <includes>**/*.exe</includes>
                                    <fileMappers>
                                        <org.codehaus.plexus.components.io.filemappers.RegExpFileMapper>
                                          <pattern>prunsrv</pattern>
                                          <replacement>wildfly-service</replacement>
                                        </org.codehaus.plexus.components.io.filemappers.RegExpFileMapper>
                                        <org.codehaus.plexus.components.io.filemappers.RegExpFileMapper>
                                          <pattern>prunmgr</pattern>
                                          <replacement>wildfly-mgr</replacement>
                                        </org.codehaus.plexus.components.io.filemappers.RegExpFileMapper>
                                      </fileMappers>
                                </artifactItem>
                            </artifactItems>
                        </configuration>
                    </execution>
                </executions>
            </plugin>            
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <executions>
                    <execution>
                        <id>copy-common-feature-pack-resources</id>
                        <phase>process-resources</phase>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${basedir}/target/resources</outputDirectory>
                            <escapeString>\</escapeString>
                            <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>
                        </configuration>
                    </execution>
                    <execution>
                        <id>copy-ee8-api-feature-pack-resources</id>
                        <phase>process-resources</phase>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${basedir}/target/resources</outputDirectory>
                            <resources>
                                <resource>
                                    <directory>${ee-10-api.resources.directory}</directory>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                    <execution>
                        <id>copy-galleon-common-feature-pack-resources</id>
                        <phase>process-resources</phase>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${basedir}/target/resources</outputDirectory>
                            <resources>
                                <resource>
                                    <directory>${galleon-common.resources.directory}</directory>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                    <execution>
                        <id>copy-galleon-cli-shaded-resources</id>
                        <phase>process-resources</phase>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${basedir}/target/resources</outputDirectory>
                            <resources>
                                <resource>
                                    <directory>${galleon-cli-shaded.resources.directory}</directory>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                    <execution>
                        <id>copy-galleon-elytron-tools-shaded-resources</id>
                        <phase>process-resources</phase>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${basedir}/target/resources</outputDirectory>
                            <resources>
                                <resource>
                                    <directory>${galleon-elytron-tools-shaded.resources.directory}</directory>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                    <execution>
                        <id>copy-resources</id>
                        <phase>process-resources</phase>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${basedir}/target/resources</outputDirectory>
                            <resources>
                                <resource>
                                    <directory>${basedir}/src/main/resources</directory>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.wildfly.maven.plugins</groupId>
                <artifactId>licenses-plugin</artifactId>
                <inherited>false</inherited>
                <executions>
                    <execution>
                        <id>update-licenses-xml-package</id>
                        <goals>
                            <goal>insert-versions</goal>
                        </goals>
                        <phase>process-resources</phase>
                        <configuration>
                            <sortByGroupIdAndArtifactId>true</sortByGroupIdAndArtifactId>
                            <licensesConfigFiles>
                                <licensesConfigFile>${basedir}/target/resources/license/core-feature-pack-common-licenses.xml</licensesConfigFile>
                                <licensesConfigFile>${basedir}/target/resources/license/core-feature-pack-ee-10-api-licenses.xml</licensesConfigFile>
                            </licensesConfigFiles>
                            <licensesOutputFile>${license.directory}/core-feature-pack-licenses.xml</licensesOutputFile>
                            <excludedGroups>org.wildfly.galleon-plugins</excludedGroups>
                            <excludedArtifacts>wildfly-core-model-test-framework|wildfly-jar-boot|wildfly-core-feature-pack-common|wildfly-core-feature-pack-ee-10-api|wildfly-elytron\z</excludedArtifacts>
                            <excludedScopes>system</excludedScopes>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.wildfly.galleon-plugins</groupId>
                <artifactId>wildfly-galleon-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>feature-pack-build</id>
                        <goals>
                            <goal>build-feature-pack</goal>
                        </goals>
                        <phase>compile</phase>
                        <configuration>
                            <!-- Any dependency to a package that has a stability level
                                 lower than the minimum stability level will break the build.
                                 Note that package dependencies that are only valid for
                                 a minimum stability level are ignored. -->
                            <forbid-lower-stability-level-package-reference>true</forbid-lower-stability-level-package-reference>
                            <release-name>WildFly Core</release-name>
                            <fork-embedded>${galleon.fork.embedded}</fork-embedded>
                            <generate-channel-manifest>true</generate-channel-manifest>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <profiles>

        <profile>
            <id>enforce</id>
            <activation>
                <property>
                    <name>!skip-enforce</name>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-enforcer-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>ban-transitive-deps</id>
                                <goals>
                                    <goal>enforce</goal>
                                </goals>
                                <configuration>
                                    <rules>
                                        <banTransitiveDependencies>
                                            <excludes>
                                                <!-- Ignore the shared resource poms as those we want their
                                                     transitives. Those poms ban transitives at their level -->
                                                <exclude>${project.groupId}:wildfly-core-feature-pack-common</exclude>
                                                <exclude>${project.groupId}:wildfly-core-feature-pack-ee-10-api</exclude>
                                            </excludes>
                                        </banTransitiveDependencies>
                                    </rules>
                                </configuration>
                            </execution>
                        </executions>

                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>enforce-product</id>
            <activation>
                <property>
                    <name>enforce-product</name>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-enforcer-plugin</artifactId>
                        <dependencies>
                            <dependency>
                                <groupId>org.jboss.maven.plugins.enforcer.rules</groupId>
                                <artifactId>version-enforcer-rule</artifactId>
                                <version>1.0.0</version>
                            </dependency>
                        </dependencies>
                        <executions>
                            <execution>
                                <id>ban-non-product-deps</id>
                                <goals>
                                    <goal>enforce</goal>
                                </goals>
                                <configuration>
                                    <rules>
                                        <rule implementation="org.jboss.maven.plugins.enforcer.rules.version.BanVersionDependenciesRule">
                                          <versionPattern>^((?!redhat).)*$</versionPattern>
                                        </rule>
                                    </rules>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>javadocDist</id>
            <properties>
                <javadoc.branding>WildFly public API - ${project.version}</javadoc.branding>
            </properties>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-javadoc-plugin</artifactId>
                        <version>${version.javadoc.plugin}</version>
                        <executions>
                            <execution>
                                <id>javadocs-dist</id>
                                <goals>
                                    <goal>aggregate-jar</goal>
                                </goals>
                                <phase>validate</phase>
                                <configuration>
                                    <debug>true</debug>
                                    <verbose>true</verbose>
                                    <maxmemory>2400m</maxmemory>
                                    <!-- To prevent problems with author names written in non-UTF-8:
                                    -->
                                    <encoding>ISO-8859-1</encoding>

                                    <windowtitle>${javadoc.branding} public API</windowtitle>
                                    <doctitle>${javadoc.branding} public API</doctitle>
                                    <header>${javadoc.branding}</header>
                                    <footer>${javadoc.branding}</footer>

                                    <includeDependencySources>true</includeDependencySources>
                                    <dependencySourceIncludes>
                                        <!-- Filled by a script during creation of Javadoc. -->
                                    </dependencySourceIncludes>

                                    <dependencySourceExcludes>
                                        <!-- Filled by a script during creation of Javadoc. -->
                                    </dependencySourceExcludes>

                                    <groups>
                                        <!-- Filled by a script during creation of Javadoc. -->
                                    </groups>

                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

</project>
