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

    Copyright 2015-2016 Red Hat, Inc. and/or its affiliates
    and other contributors as indicated by the @author tags.

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

  <parent>
    <groupId>org.hawkular.agent</groupId>
    <artifactId>hawkular-wildfly-agent-itest-parent</artifactId>
    <version>0.16.0.Final</version>
  </parent>
  <artifactId>hawkular-wildfly-agent-itest-feature-pack</artifactId>
  <packaging>pom</packaging>

  <name>Hawkular Agent: WildFly Agent Subsystem Feature Pack</name>
  <description>A feature pack to be able to deploy a Hawkular WildFly Agent in a WildFly server.</description>

  <dependencies>

    <dependency>
      <groupId>org.hawkular.accounts</groupId>
      <artifactId>hawkular-accounts-feature-pack</artifactId>
      <version>${version.org.hawkular.accounts}</version>
      <type>zip</type>
      <exclusions>
        <exclusion>
          <groupId>*</groupId>
          <artifactId>*</artifactId>
        </exclusion>
      </exclusions>
    </dependency>

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

  </dependencies>

  <build>
    <plugins>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
        <executions>
          <execution>
            <id>unpack-deps</id>
            <phase>generate-resources</phase>
            <goals>
              <goal>unpack</goal>
            </goals>
            <configuration>
              <outputDirectory>${project.build.directory}/upstream-subsystem-templates</outputDirectory>
              <includes>subsystem-templates/*.xml</includes>
              <artifactItems>
                <artifactItem>
                  <groupId>org.keycloak</groupId>
                  <artifactId>keycloak-wildfly-server-subsystem</artifactId>
                  <version>${version.org.keycloak}</version>
                </artifactItem>
                <artifactItem>
                  <groupId>org.hawkular.accounts</groupId>
                  <artifactId>hawkular-accounts-feature-pack</artifactId>
                  <version>${version.org.hawkular.accounts}</version>
                  <type>zip</type>
                </artifactItem>
              </artifactItems>
            </configuration>
          </execution>
          <execution>
            <!--
              OK, this is a little bit weird step.
              To make the provisioning plugin realize that we need the subsystems from accounts, we would have to
              declare a module that would include the artifact with the subsystem-templates of accounts. Now inventory
              feature pack does NOT need any such module - we just want to declare the same stuff as accounts.
            -->
            <id>copy-accounts-subsystem-templates</id>
            <phase>prepare-package</phase>
            <goals>
              <goal>unpack</goal>
            </goals>
            <configuration>
              <outputDirectory>${project.build.directory}/${project.artifactId}-${project.version}</outputDirectory>
              <includes>subsystem-templates/*xml</includes>
              <artifactItems>
                <artifactItem>
                  <groupId>org.hawkular.accounts</groupId>
                  <artifactId>hawkular-accounts-feature-pack</artifactId>
                  <version>${version.org.hawkular.accounts}</version>
                  <type>zip</type>
                </artifactItem>
              </artifactItems>
            </configuration>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <groupId>org.wildfly.build</groupId>
        <artifactId>wildfly-feature-pack-build-maven-plugin</artifactId>
        <executions>
          <execution>
            <id>feature-pack-build</id>
            <phase>compile</phase>
            <goals>
              <goal>build</goal>
            </goals>
            <configuration>
              <config-file>feature-pack-build.xml</config-file>
            </configuration>
          </execution>
        </executions>
      </plugin>

      <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>
              <appendAssemblyId>false</appendAssemblyId>
              <tarLongFileMode>gnu</tarLongFileMode>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>
