<?xml version="1.0" encoding="UTF-8"?>
<!--
  ~  Copyright (c) 2011-2015 The original author or authors
  ~
  ~  All rights reserved. This program and the accompanying materials
  ~  are made available under the terms of the Eclipse Public License v1.0
  ~  and Apache License v2.0 which accompanies this distribution.
  ~
  ~       The Eclipse Public License is available at
  ~       http://www.eclipse.org/legal/epl-v10.html
  ~
  ~       The Apache License v2.0 is available at
  ~       http://www.opensource.org/licenses/apache2.0.php
  ~
  ~  You may elect to redistribute this code under either of these licenses.
  -->

<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>io.vertx</groupId>
    <artifactId>vertx-stack</artifactId>
    <version>3.5.0</version>
  </parent>

  <artifactId>vertx-stack-manager</artifactId>
  <name>Vert.x Stack - Stack Manager</name>

  <properties>
    <aether.version>1.1.0</aether.version>
    <vertx.version>${project.version}</vertx.version>
    <finalName>vert.x-${project.version}</finalName>
  </properties>

  <dependencies>

    <!-- These dependencies must match the SLF4J version used by Vert.x -->
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-api</artifactId>
      <version>1.7.16</version>
    </dependency>
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>jcl-over-slf4j</artifactId>
      <version>1.7.16</version>
    </dependency>
    <dependency>
      <groupId>io.vertx</groupId>
      <artifactId>vertx-core</artifactId>
    </dependency>
    <dependency>
      <groupId>io.vertx</groupId>
      <artifactId>vertx-hazelcast</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.apache.maven</groupId>
      <artifactId>maven-aether-provider</artifactId>
      <version>3.3.9</version>
      <exclusions>
        <exclusion>
          <groupId>org.eclipse.sisu</groupId>
          <artifactId>org.eclipse.sisu.plexus</artifactId>
        </exclusion>
        <exclusion>
          <groupId>org.codehaus.plexus</groupId>
          <artifactId>plexus-component-annotations</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
    <dependency>
      <groupId>org.eclipse.aether</groupId>
      <artifactId>aether-api</artifactId>
      <version>${aether.version}</version>
    </dependency>
    <dependency>
      <groupId>org.eclipse.aether</groupId>
      <artifactId>aether-connector-basic</artifactId>
      <version>${aether.version}</version>
    </dependency>
    <dependency>
      <groupId>org.eclipse.aether</groupId>
      <artifactId>aether-transport-file</artifactId>
      <version>${aether.version}</version>
    </dependency>
    <dependency>
      <groupId>org.eclipse.aether</groupId>
      <artifactId>aether-transport-http</artifactId>
      <version>${aether.version}</version>
      <exclusions>
        <exclusion>
          <groupId>org.slf4j</groupId>
          <artifactId>slf4j-api</artifactId>
        </exclusion>
        <exclusion>
          <groupId>org.slf4j</groupId>
          <artifactId>jcl-over-slf4j</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
    <dependency>
      <groupId>org.eclipse.aether</groupId>
      <artifactId>aether-spi</artifactId>
      <version>${aether.version}</version>
    </dependency>
    <dependency>
      <groupId>org.eclipse.aether</groupId>
      <artifactId>aether-impl</artifactId>
      <version>${aether.version}</version>
    </dependency>
    <dependency>
      <groupId>org.eclipse.aether</groupId>
      <artifactId>aether-util</artifactId>
      <version>${aether.version}</version>
    </dependency>
    <dependency>
      <!-- required by aether -->
      <groupId>com.google.guava</groupId>
      <artifactId>guava</artifactId>
      <version>19.0</version>
    </dependency>
    <dependency>
      <groupId>com.jayway.awaitility</groupId>
      <artifactId>awaitility</artifactId>
      <version>1.7.0</version>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>io.vertx</groupId>
      <artifactId>vertx-docgen</artifactId>
    </dependency>

    <dependency>
      <groupId>org.assertj</groupId>
      <artifactId>assertj-core</artifactId>
      <version>3.3.0</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.12</version>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <plugin>
        <artifactId>maven-resources-plugin</artifactId>
        <version>2.7</version>
        <executions>
          <execution>
            <id>copy-resources</id>
            <phase>process-resources</phase>
            <goals>
              <goal>copy-resources</goal>
            </goals>
            <configuration>
              <escapeString>\</escapeString>
              <outputDirectory>${basedir}/target/vertx-stack</outputDirectory>
              <resources>
                <resource>
                  <directory>src/main/descriptor</directory>
                  <filtering>true</filtering>
                </resource>
              </resources>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>exec-maven-plugin</artifactId>
        <version>1.4.0</version>
        <executions>
          <execution>
            <id>build-minimal-stack</id>
            <phase>prepare-package</phase>
            <goals>
              <goal>java</goal>
            </goals>
            <configuration>
              <mainClass>io.vertx.core.Launcher</mainClass>
              <arguments>
                <argument>resolve</argument>
                <argument>${project.basedir}/target/vertx-stack/vertx-stack.json</argument>
                <argument>--dir=${project.basedir}/target/min-lib</argument>
                <argument>--no-cache</argument>
              </arguments>
            </configuration>
          </execution>
          <execution>
            <id>build-full-stack</id>
            <phase>prepare-package</phase>
            <goals>
              <goal>java</goal>
            </goals>
            <configuration>
              <mainClass>io.vertx.core.Launcher</mainClass>
              <arguments>
                <argument>resolve</argument>
                <argument>${project.basedir}/target/vertx-stack/vertx-stack-full.json</argument>
                <argument>--dir=${project.basedir}/target/full-lib</argument>
                <argument>--no-cache</argument>
              </arguments>
            </configuration>
          </execution>
	  <execution>
            <id>build-scala-stack</id>
            <phase>prepare-package</phase>
            <goals>
              <goal>java</goal>
            </goals>
            <configuration>
              <mainClass>io.vertx.core.Launcher</mainClass>
              <arguments>
                <argument>resolve</argument>
                <argument>${project.basedir}/target/vertx-stack/vertx-stack-scala.json</argument>
                <argument>--dir=${project.basedir}/target/scala-lib</argument>
                <argument>--no-cache</argument>
              </arguments>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-shade-plugin</artifactId>
        <version>2.4.3</version>
        <executions>
          <execution>
            <phase>package</phase>
            <goals>
              <goal>shade</goal>
            </goals>
            <configuration>
              <createDependencyReducedPom>false</createDependencyReducedPom>
              <artifactSet>
                <excludes>
                  <exclude>io.vertx:vertx-core</exclude>
                  <exclude>io.vertx:vertx-docgen</exclude>
                  <exclude>io.netty:*</exclude>
                  <exclude>com.fasterxml.jackson.core:*</exclude>
                </excludes>
              </artifactSet>
              <relocations>
                <relocation>
                  <pattern>org.apache</pattern>
                  <shadedPattern>shaded.org.apache</shadedPattern>
                </relocation>
                <relocation>
                  <pattern>org.eclipse.aether</pattern>
                  <shadedPattern>shaded.org.eclipse.aether</shadedPattern>
                </relocation>
                <relocation>
                  <pattern>com.google.common</pattern>
                  <shadedPattern>shaded.com.google.common</shadedPattern>
                </relocation>
                <relocation>
                  <pattern>org.codehaus.plexus</pattern>
                  <shadedPattern>shaded.org.codehaus.plexus</shadedPattern>
                </relocation>
                <relocation>
                  <pattern>org.slf4j</pattern>
                  <shadedPattern>shaded.org.slf4j</shadedPattern>
                </relocation>
              </relocations>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <artifactId>maven-assembly-plugin</artifactId>
        <version>2.6</version>
        <executions>
          <execution>
            <id>vertx-stack</id>
            <goals>
              <goal>single</goal>
            </goals>
            <configuration>
              <finalName>${finalName}</finalName>
              <appendAssemblyId>false</appendAssemblyId>
              <descriptors>
                <descriptor>src/main/assembly/stack.xml</descriptor>
              </descriptors>
            </configuration>
            <phase>package</phase>
          </execution>

          <execution>
            <id>vertx-stack-full</id>
            <goals>
              <goal>single</goal>
            </goals>
            <configuration>
              <finalName>${finalName}</finalName>
              <appendAssemblyId>true</appendAssemblyId>
              <descriptors>
                <descriptor>src/main/assembly/stack-full.xml</descriptor>
              </descriptors>
            </configuration>
            <phase>package</phase>
          </execution>

          <execution>
            <id>vertx-stack-scala</id>
            <goals>
              <goal>single</goal>
            </goals>
            <configuration>
              <finalName>${finalName}</finalName>
              <appendAssemblyId>true</appendAssemblyId>
              <descriptors>
                <descriptor>src/main/assembly/stack-scala.xml</descriptor>
              </descriptors>
            </configuration>
            <phase>package</phase>
          </execution>

          <execution>
            <id>doc</id>
            <phase>package</phase>
            <goals>
              <goal>single</goal>
            </goals>
            <configuration>
              <attach>true</attach>
              <descriptors>
                <descriptor>${basedir}/src/main/assembly/docs.xml</descriptor>
              </descriptors>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.3</version>
        <configuration>
          <target>1.8</target>
          <source>1.8</source>
            <annotationProcessors>
              <annotationProcessor>io.vertx.docgen.JavaDocGenProcessor</annotationProcessor>
            </annotationProcessors>
            <generatedSourcesDirectory>${project.basedir}/src/main/generated</generatedSourcesDirectory>
            <compilerArgs>
              <arg>-Adocgen.output=${asciidoc.dir}/stack-manager</arg>
              <arg>-AoutputDirectory=${project.basedir}/src/main</arg>
            </compilerArgs>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.asciidoctor</groupId>
        <artifactId>asciidoctor-maven-plugin</artifactId>
        <executions>
          <execution>
            <goals>
              <goal>process-asciidoc</goal>
            </goals>
            <phase>package</phase>
          </execution>
        </executions>
      </plugin>
    </plugins>

  </build>
</project>
