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

<!--
  ~ JBoss, Home of Professional Open Source.
  ~ Copyright 2010, Red Hat, Inc., and individual contributors
  ~ as indicated by the @author tags. See the copyright.txt file in the
  ~ distribution for a full listing of individual contributors.
  ~
  ~ This is free software; you can redistribute it and/or modify it
  ~ under the terms of the GNU Lesser General Public License as
  ~ published by the Free Software Foundation; either version 2.1 of
  ~ the License, or (at your option) any later version.
  ~
  ~ This software is distributed in the hope that it will be useful,
  ~ but WITHOUT ANY WARRANTY; without even the implied warranty of
  ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  ~ Lesser General Public License for more details.
  ~
  ~ You should have received a copy of the GNU Lesser General Public
  ~ License along with this software; if not, write to the Free
  ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  ~ 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  -->

<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</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>23.0.0.Beta1</version>
    </parent>

    <artifactId>wildfly-build-legacy</artifactId>

    <name>WildFly: Legacy Build</name>
    <packaging>pom</packaging>

    <dependencies>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>wildfly-feature-pack</artifactId>
            <type>zip</type>
            <exclusions>
                <exclusion>
                    <groupId>*</groupId>
                    <artifactId>*</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
    </dependencies>

    <profiles>
        <profile>
            <id>legacy-build</id>
            <activation>
                <property>
                    <name>legacyBuild</name>
                </property>
            </activation>
            <build>
                <finalName>${server.output.dir.prefix}-${server.output.dir.version}</finalName>
                <plugins>
                    <plugin>
                        <groupId>org.wildfly.build</groupId>
                        <artifactId>wildfly-server-provisioning-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>server-provisioning</id>
                                <goals>
                                    <goal>build</goal>
                                </goals>
                                <phase>compile</phase>
                                <configuration>
                                    <config-file>server-provisioning.xml</config-file>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-resources-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>distribution-configuration</id>
                                <goals>
                                    <goal>copy-resources</goal>
                                </goals>
                                <phase>process-classes</phase>
                                <configuration>
                                    <overwrite>true</overwrite>
                                    <outputDirectory>${basedir}/target/${project.build.finalName}</outputDirectory>
                                    <resources>
                                        <resource>
                                            <!-- Pull the shared content from dist-legacy -->
                                            <directory>../dist-legacy/src/distribution/resources</directory>
                                            <filtering>true</filtering>
                                        </resource>
                                    </resources>
                                </configuration>
                            </execution>
                            <execution>
                                <id>verifications-configuration</id>
                                <goals>
                                    <goal>copy-resources</goal>
                                </goals>
                                <phase>process-classes</phase>
                                <configuration>
                                    <overwrite>true</overwrite>
                                    <outputDirectory>${basedir}/target/verifier</outputDirectory>
                                    <resources>
                                        <resource>
                                            <directory>src/verifier</directory>
                                            <filtering>true</filtering>
                                        </resource>
                                    </resources>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-verifier-plugin</artifactId>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-antrun-plugin</artifactId>
                        <executions>
                            <execution>
                                <phase>prepare-package</phase>
                                <configuration>
                                    <target>
                                        <filelist id="licenses.xml.list" dir="${basedir}/target/${server.output.dir.prefix}-${server.output.dir.version}/docs/licenses"
                                                  files="full-feature-pack-licenses.xml,servlet-feature-pack-licenses.xml,core-feature-pack-licenses.xml"/>
                                        <!--
                                        <property name="prop.licenses.xml.list" refid="licenses.xml.list"/>
                                        <echo>List of licenses.xml in ${basedir}/target/${server.output.dir.prefix}-${server.output.dir.version}/docs/licenses</echo>
                                        <echo>${prop.licenses.xml.list}</echo>
                                        -->
                                        <pathconvert pathsep="&#xA;" property="license-files-list-items" refid="licenses.xml.list">
                                            <chainedmapper>
                                                <mapper type="flatten"/>
                                                <globmapper from="*" to="&lt;item&gt;*"/>
                                                <globmapper from="*" to="*&lt;/item&gt;"/>
                                            </chainedmapper>
                                        </pathconvert>
                                        <echo file="${basedir}/target/${server.output.dir.prefix}-${server.output.dir.version}/docs/licenses/licenses.xml">&lt;?xml version="1.0" encoding="UTF-8"?&gt;&#xA;&lt;list&gt;&#xA;</echo>
                                        <echo file="${basedir}/target/${server.output.dir.prefix}-${server.output.dir.version}/docs/licenses/licenses.xml" append="true">${license-files-list-items}&#xA;</echo>
                                        <echo file="${basedir}/target/${server.output.dir.prefix}-${server.output.dir.version}/docs/licenses/licenses.xml" append="true">&lt;/list&gt;</echo>
                                    </target>
                                </configuration>
                                <goals>
                                    <goal>run</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>xml-maven-plugin</artifactId>
                        <inherited>false</inherited>
                        <executions>
                            <execution>
                                <id>generate-licenses-html</id>
                                <goals>
                                    <goal>transform</goal>
                                </goals>
                                <phase>prepare-package</phase>
                                <configuration>
                                    <transformationSets>
                                        <transformationSet>
                                            <dir>${basedir}/target/${server.output.dir.prefix}-${server.output.dir.version}/docs/licenses</dir>
                                            <includes>
                                                <include>licenses.xml</include>
                                            </includes>
                                            <stylesheet>${basedir}/target/${server.output.dir.prefix}-${server.output.dir.version}/docs/licenses/licenses-merged.xsl</stylesheet>
                                            <outputDir>${basedir}/target/${server.output.dir.prefix}-${server.output.dir.version}/docs/licenses</outputDir>
                                            <fileMappers>
                                                <fileMapper implementation="org.codehaus.plexus.components.io.filemappers.FileExtensionMapper">
                                                    <targetExtension>.xml</targetExtension>
                                                </fileMapper>
                                            </fileMappers>
                                        </transformationSet>
                                        <transformationSet>
                                            <dir>${basedir}/target/${server.output.dir.prefix}-${server.output.dir.version}/docs/licenses</dir>
                                            <includes>
                                                <include>licenses.xml</include>
                                            </includes>
                                            <stylesheet>${basedir}/target/${server.output.dir.prefix}-${server.output.dir.version}/docs/licenses/licenses.xsl</stylesheet>
                                            <outputDir>${basedir}/target/${server.output.dir.prefix}-${server.output.dir.version}/docs/licenses</outputDir>
                                            <fileMappers>
                                                <fileMapper implementation="org.codehaus.plexus.components.io.filemappers.FileExtensionMapper">
                                                    <targetExtension>.html</targetExtension>
                                                </fileMapper>
                                            </fileMappers>
                                            <parameters>
                                                <parameter>
                                                    <name>version</name>
                                                    <value>${ee.dist.product.release.version}</value>
                                                </parameter>
                                                <parameter>
                                                    <name>product.release.name</name>
                                                    <value>${ee.dist.product.release.name}</value>
                                                </parameter>
                                            </parameters>
                                        </transformationSet>
                                    </transformationSets>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>legacy-release</id>
            <activation>
                <property>
                    <name>legacyRelease</name>
                </property>
            </activation>
            <build>
                <plugins>
                    <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>assembly.xml</descriptor>
                                    </descriptors>
                                    <recompressZippedFiles>true</recompressZippedFiles>
                                    <finalName>${project.build.finalName}</finalName>
                                    <appendAssemblyId>false</appendAssemblyId>
                                    <outputDirectory>${project.build.directory}</outputDirectory>
                                    <workDirectory>${project.build.directory}/assembly/work</workDirectory>
                                    <tarLongFileMode>gnu</tarLongFileMode>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
