<?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>
        <!--
        use wildfly-parent to avoid issues
        with dependencies imported with groupId ${project.groupId}
        -->
        <groupId>org.wildfly</groupId>
        <artifactId>wildfly-parent</artifactId>
        <!--
        Maintain separation between the artifact id and the version to help prevent
        merge conflicts between commits changing the GA and those changing the V.
        -->
        <version>41.0.0.Final</version>
        <relativePath>../../pom.xml</relativePath>
    </parent>

    <groupId>org.wildfly.channels</groupId>
    <artifactId>wildfly-compat-ee-10</artifactId>

    <name>WildFly: Channel for EE 10 compatibility</name>
    <packaging>pom</packaging>

    <properties>
        <full.maven.groupId>${project.parent.groupId}</full.maven.groupId>
    </properties>

    <dependencies>

        <!-- We need the feature-pack built first as that generates the manifest -->
        <dependency>
            <groupId>${full.maven.groupId}</groupId>
            <artifactId>wildfly-galleon-pack</artifactId>
            <type>pom</type>
            <scope>provided</scope>
        </dependency>
        <!-- Depends on the legacy EE feature-pack artifact to ensure
             that this channel is built first as it is required by the channel
             built by this module -->
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>${legacy.ee.channel.artifactId}</artifactId>
            <classifier>manifest</classifier>
            <type>yaml</type>
            <scope>provided</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-deploy-plugin</artifactId>
                <configuration>
                    <!-- This module's artifacts are currently not deployed -->
                    <skip>false</skip>
                </configuration>
            </plugin>
            <!-- Use the assembly plugin to copy and rename the manifest generated by the feature-pack build.
                 (The resources plugin doesn't allow file renaming.)-->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-assembly-plugin</artifactId>
                <executions>
                    <execution>
                        <id>assemble</id>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                        <configuration>
                            <descriptors>
                              <descriptor>${project.basedir}/assembly.xml</descriptor>
                            </descriptors>
                            <finalName>assembly</finalName>
                            <workDirectory>${project.build.directory}/assembly-src/work</workDirectory>
                            <attach>false</attach>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>build-helper-maven-plugin</artifactId>
                <executions>
                    <!-- Attach the manifest.yaml to the build -->
                    <execution>
                        <id>attach-manifest</id>
                        <phase>package</phase>
                        <goals>
                            <goal>attach-artifact</goal>
                        </goals>
                        <configuration>
                            <artifacts>
                                <artifact>
                                    <file>${project.build.directory}/assembly-manifest-rename/assembly/${project.artifactId}-${project.version}-manifest.yaml</file>
                                    <type>yaml</type>
                                    <classifier>manifest</classifier>
                                </artifact>
                            </artifacts>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <!-- change the manifest metadata -->
            <plugin>
                <groupId>org.wildfly</groupId>
                <artifactId>wildfly-channel-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>test</id>
                        <phase>package</phase>
                        <goals>
                            <goal>edit-manifest</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <manifestPath>${project.build.directory}/assembly-manifest-rename/assembly/${project.artifactId}-${project.version}-manifest.yaml</manifestPath>
                    <manifestName>WildFly manifest version ${project.version}</manifestName>
                    <manifestId>${project.groupId}:${project.artifactId}</manifestId>
                    <manifestDescription>Manifest for WildFly feature-pack with Jakarta EE 10 compatibility.</manifestDescription>
                    <manifestLogicalVersion>WildFly ${project.version}</manifestLogicalVersion>
                    <manifestRequirements>
                        <manifestRequirement>
                            <id>${project.groupId}:wildfly-ee-10</id>
                            <groupId>${project.groupId}</groupId>
                            <artifactId>wildfly-ee-10</artifactId>
                            <version>${project.version}</version>
                        </manifestRequirement>
                    </manifestRequirements>
                </configuration>
            </plugin>
        </plugins>
    </build>

</project>
