<?xml version="1.0" encoding="UTF-8"?>
<!--
  ~ Copyright 2019 Red Hat, Inc.
  ~
  ~ 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>
        <artifactId>wildfly-microprofile-graphql-parent</artifactId>
        <groupId>org.wildfly.extras.graphql</groupId>
        <version>2.7.0.Final</version>
    </parent>

    <modelVersion>4.0.0</modelVersion>

    <artifactId>wildfly-microprofile-graphql-build</artifactId>
    <name>WildFly MicroProfile GraphQL - Build</name>

    <packaging>pom</packaging>

    <properties>
        <maven.deploy.skip>true</maven.deploy.skip>
    </properties>

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

    <build>
        <finalName>${server.name}</finalName>
        <plugins>
            <plugin>
                <groupId>org.jboss.galleon</groupId>
                <artifactId>galleon-maven-plugin</artifactId>
                <executions>
                    <!-- Thin Maven distribution of WildFly -->
                    <execution>
                        <id>server-provisioning-thin</id>
                        <goals>
                            <goal>provision</goal>
                        </goals>
                        <phase>prepare-package</phase>
                        <configuration>
                            <install-dir>${project.build.directory}/${project.build.finalName}</install-dir>
                            <record-state>false</record-state>
                            <log-time>${galleon.log.time}</log-time>
                            <offline>true</offline>
                            <feature-packs>
                                <feature-pack>
                                    <transitive>true</transitive>
                                    <groupId>org.wildfly</groupId>
                                    <artifactId>wildfly-galleon-pack</artifactId>
                                    <version>${version.org.wildfly}</version>
                                    <inherit-packages>false</inherit-packages>
                                    <inherit-configs>false</inherit-configs>
                                </feature-pack>
                                <feature-pack>
                                    <groupId>${project.groupId}</groupId>
                                    <artifactId>wildfly-microprofile-graphql-feature-pack</artifactId>
                                    <version>${project.version}</version>
                                    <inherit-packages>false</inherit-packages>
                                    <inherit-configs>false</inherit-configs>
                                </feature-pack>
                            </feature-packs>
                            <configurations>
                                <config>
                                    <model>standalone</model>
                                    <name>standalone.xml</name>
                                    <layers>
                                        <layer>cloud-profile</layer>
                                        <layer>core-tools</layer>
                                        <layer>logging</layer>
                                        <!-- Layers from this FP -->
                                        <layer>microprofile-graphql</layer>
                                    </layers>
                                </config>
                            </configurations>
                            <plugin-options>
                                <jboss-maven-dist/>
                                <jboss-fork-embedded>${galleon.fork.embedded}</jboss-fork-embedded>
                                <optional-packages>passive+</optional-packages>
                            </plugin-options>
                        </configuration>
                    </execution>
                    <!-- Full distribution of WildFly (with JARs included) -->
                    <execution>
                        <id>server-provisioning-full</id>
                        <goals>
                            <goal>provision</goal>
                        </goals>
                        <phase>prepare-package</phase>
                        <configuration>
                            <install-dir>${project.build.directory}/${project.build.finalName}-full</install-dir>
                            <record-state>false</record-state>
                            <log-time>${galleon.log.time}</log-time>
                            <offline>true</offline>
                            <feature-packs>
                                <feature-pack>
                                    <transitive>true</transitive>
                                    <groupId>org.wildfly</groupId>
                                    <artifactId>wildfly-galleon-pack</artifactId>
                                    <version>${version.org.wildfly}</version>
                                    <inherit-packages>false</inherit-packages>
                                    <inherit-configs>false</inherit-configs>
                                </feature-pack>
                                <feature-pack>
                                    <groupId>${project.groupId}</groupId>
                                    <artifactId>wildfly-microprofile-graphql-feature-pack</artifactId>
                                    <version>${project.version}</version>
                                    <inherit-packages>false</inherit-packages>
                                    <inherit-configs>false</inherit-configs>
                                </feature-pack>
                            </feature-packs>
                            <configurations>
                                <config>
                                    <model>standalone</model>
                                    <name>standalone.xml</name>
                                    <layers>
                                        <layer>cloud-profile</layer>
                                        <layer>core-tools</layer>
                                        <!-- Layers from this FP -->
                                        <layer>microprofile-graphql</layer>
                                    </layers>
                                </config>
                            </configurations>
                            <plugin-options>
                                <jboss-fork-embedded>${galleon.fork.embedded}</jboss-fork-embedded>
                                <optional-packages>passive+</optional-packages>
                            </plugin-options>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-assembly-plugin</artifactId>
                <executions>
                    <!-- Create a ZIP of the thin (Maven-based) WildFly distribution -->
                    <execution>
                        <id>assemble-thin</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>
                    <!-- Create a ZIP of the full WildFly distribution (with JARs included) -->
                    <execution>
                        <id>assemble-full</id>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                        <configuration>
                            <descriptors>
                                <descriptor>assembly-full.xml</descriptor>
                            </descriptors>
                            <recompressZippedFiles>true</recompressZippedFiles>
                            <finalName>${project.build.finalName}-full</finalName>
                            <appendAssemblyId>false</appendAssemblyId>
                            <outputDirectory>${project.build.directory}</outputDirectory>
                            <workDirectory>${project.build.directory}/assembly/work</workDirectory>
                            <tarLongFileMode>gnu</tarLongFileMode>
                        </configuration>
                    </execution>
                    <!-- Out of the full WildFly distribution, create a zip overlay -->
                    <execution>
                        <id>assemble-zip-overlay</id>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                        <configuration>
                            <descriptors>
                                <descriptor>assembly-zip-overlay.xml</descriptor>
                            </descriptors>
                            <recompressZippedFiles>true</recompressZippedFiles>
                            <finalName>${project.build.finalName}-overlay</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>

</project>
