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

    Copyright (C) 2016 Cognifide Limited

    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:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="http://maven.apache.org/POM/4.0.0"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>io.knotx</groupId>
  <artifactId>knotx-root</artifactId>
  <version>1.2.0</version>
  <packaging>pom</packaging>

  <name>Knot.x</name>
  <description>Knot.x - efficient, high-performance and scalable integration platform for modern
    websites
  </description>
  <url>http://knotx.io</url>

  <inceptionYear>2016</inceptionYear>
  <licenses>
    <license>
      <name>The Apache Software License, Version 2.0</name>
      <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
      <distribution>repo</distribution>
    </license>
  </licenses>

  <developers>
    <developer>
      <name>Tomasz Michalak</name>
      <email>tomasz.michalak@cognifide.com</email>
    </developer>
    <developer>
      <name>Maciej Laskowski</name>
      <email>maciej.laskowski@cognifide.com</email>
    </developer>
    <developer>
      <name>Marcin Czeczko</name>
      <email>marcin.czeczko@cognifide.com</email>
    </developer>
  </developers>

  <modules>
    <module>documentation</module>
    <module>knotx-core</module>
    <module>knotx-junit</module>
    <module>knotx-mocks</module>
    <module>knotx-repository-connector</module>
    <module>knotx-adapter</module>
    <module>knotx-knot</module>
    <module>knotx-server</module>
    <module>knotx-standalone</module>
    <module>knotx-example</module>
    <module>knotx-gateway</module>
  </modules>

  <scm>
    <connection>scm:git:git://github.com/Cognifide/knotx.git</connection>
    <developerConnection>scm:git:ssh://github.com:Cognifide/knotx.git</developerConnection>
    <url>http://github.com/Cognifide/knotx/tree/master</url>
    <tag>HEAD</tag>
  </scm>

  <distributionManagement>
    <snapshotRepository>
      <id>ossrh</id>
      <url>https://oss.sonatype.org/content/repositories/snapshots</url>
    </snapshotRepository>
    <repository>
      <id>ossrh</id>
      <url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
    </repository>
  </distributionManagement>

  <properties>
    <file.encoding>UTF-8</file.encoding>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <java.version>1.8</java.version>

    <!-- Dependency versions -->
    <vertx.version>3.5.0</vertx.version>
    <rxjava.version>2.1.6</rxjava.version>
    <!-- https://github.com/vert-x3/vertx-codegen/issues/143 -->
    <!-- FIXME remove jackson dependency after moving to 3.5.1 -->
    <jackson.version>2.9.0</jackson.version>
    <jsoup.version>1.11.2</jsoup.version>
    <commons-io.version>2.5</commons-io.version>
    <commons-lang3.version>3.5</commons-lang3.version>
    <guava.version>20.0</guava.version>
    <logback-classic.version>1.1.8</logback-classic.version>

    <!-- Test dependencies versions -->
    <junit.version>4.12</junit.version>
    <assertj.version>3.6.1</assertj.version>
    <powermock.version>1.6.6</powermock.version>
    <mockito.version>2.0.2-beta</mockito.version>
    <hamcrest.version>1.3</hamcrest.version>
    <system-rules.version>1.16.1</system-rules.version>

    <!-- plugin version -->
    <maven.clean.plugin.version>3.0.0</maven.clean.plugin.version>
    <maven.compiler.plugin.version>3.6.0</maven.compiler.plugin.version>
    <maven.install.plugin.version>2.5.2</maven.install.plugin.version>
    <maven.deploy.plugin.version>2.8.2</maven.deploy.plugin.version>
    <maven.jar.plugin.version>3.0.2</maven.jar.plugin.version>
    <apache.rat.plugin.version>0.12</apache.rat.plugin.version>
    <maven.shade.plugin.version>2.4.3</maven.shade.plugin.version>
    <maven.surefire.plugin.version>2.19.1</maven.surefire.plugin.version>
    <maven.nexus.staging.plugin.version>1.6.7</maven.nexus.staging.plugin.version>
    <maven.source.plugin.version>2.2.1</maven.source.plugin.version>
    <maven.javadoc.plugin.version>2.9.1</maven.javadoc.plugin.version>
    <maven.gpg.plugin.version>1.5</maven.gpg.plugin.version>
    <jacoco.maven.plugin.version>0.7.7.201606060606</jacoco.maven.plugin.version>

    <generated.dir>${project.basedir}/src/main/generated</generated.dir>
  </properties>

  <dependencyManagement>
    <dependencies>
      <!-- Logger -->
      <dependency>
        <groupId>ch.qos.logback</groupId>
        <artifactId>logback-classic</artifactId>
        <version>${logback-classic.version}</version>
      </dependency>
      <!-- CORE -->
      <dependency>
        <groupId>io.vertx</groupId>
        <artifactId>vertx-core</artifactId>
        <version>${vertx.version}</version>
      </dependency>
      <dependency>
        <groupId>io.vertx</groupId>
        <artifactId>vertx-rx-java2</artifactId>
        <version>${vertx.version}</version>
      </dependency>
      <dependency>
        <groupId>io.vertx</groupId>
        <artifactId>vertx-web</artifactId>
        <version>${vertx.version}</version>
      </dependency>
      <dependency>
        <groupId>io.vertx</groupId>
        <artifactId>vertx-web-client</artifactId>
        <version>${vertx.version}</version>
      </dependency>
      <dependency>
        <groupId>io.vertx</groupId>
        <artifactId>vertx-hazelcast</artifactId>
        <version>${vertx.version}</version>
      </dependency>
      <dependency>
        <groupId>io.vertx</groupId>
        <artifactId>vertx-service-factory</artifactId>
        <version>${vertx.version}</version>
      </dependency>
      <dependency>
        <groupId>io.vertx</groupId>
        <artifactId>vertx-dropwizard-metrics</artifactId>
        <version>${vertx.version}</version>
      </dependency>
      <dependency>
        <groupId>io.vertx</groupId>
        <artifactId>vertx-service-proxy</artifactId>
        <version>${vertx.version}</version>
      </dependency>
      <dependency>
        <groupId>io.vertx</groupId>
        <artifactId>vertx-codegen</artifactId>
        <version>${vertx.version}</version>
        <optional>true</optional>
      </dependency>
      <dependency>
        <groupId>io.reactivex.rxjava2</groupId>
        <artifactId>rxjava</artifactId>
        <version>${rxjava.version}</version>
      </dependency>
      <dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-core</artifactId>
        <version>${jackson.version}</version>
      </dependency>
      <dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-databind</artifactId>
        <version>${jackson.version}</version>
      </dependency>
      <dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-annotations</artifactId>
        <version>${jackson.version}</version>
      </dependency>

      <!-- Vert.x Microservice toolbox -->
      <dependency>
        <groupId>io.vertx</groupId>
        <artifactId>vertx-service-discovery</artifactId>
        <version>${vertx.version}</version>
      </dependency>
      <dependency>
        <groupId>io.vertx</groupId>
        <artifactId>vertx-circuit-breaker</artifactId>
        <version>${vertx.version}</version>
      </dependency>

      <!-- REPOSITORY -->
      <dependency>
        <groupId>org.jsoup</groupId>
        <artifactId>jsoup</artifactId>
        <version>${jsoup.version}</version>
      </dependency>

      <!-- COMMON -->
      <dependency>
        <groupId>com.google.guava</groupId>
        <artifactId>guava</artifactId>
        <version>${guava.version}</version>
      </dependency>
      <dependency>
        <groupId>org.apache.commons</groupId>
        <artifactId>commons-lang3</artifactId>
        <version>${commons-lang3.version}</version>
      </dependency>
      <dependency>
        <groupId>commons-io</groupId>
        <artifactId>commons-io</artifactId>
        <version>${commons-io.version}</version>
      </dependency>

      <!-- Tests -->
      <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>${junit.version}</version>
        <scope>test</scope>
      </dependency>
      <dependency>
        <groupId>org.hamcrest</groupId>
        <artifactId>hamcrest-all</artifactId>
        <version>${hamcrest.version}</version>
        <scope>test</scope>
      </dependency>
      <dependency>
        <groupId>io.vertx</groupId>
        <artifactId>vertx-core</artifactId>
        <version>${vertx.version}</version>
        <type>test-jar</type>
        <scope>test</scope>
      </dependency>
      <dependency>
        <groupId>io.vertx</groupId>
        <artifactId>vertx-unit</artifactId>
        <version>${vertx.version}</version>
        <scope>test</scope>
      </dependency>
      <dependency>
        <groupId>org.assertj</groupId>
        <artifactId>assertj-core</artifactId>
        <version>${assertj.version}</version>
        <scope>test</scope>
      </dependency>
      <dependency>
        <groupId>org.powermock</groupId>
        <artifactId>powermock-api-mockito</artifactId>
        <version>${powermock.version}</version>
        <scope>test</scope>
      </dependency>
      <dependency>
        <groupId>org.powermock</groupId>
        <artifactId>powermock-module-junit4</artifactId>
        <version>${powermock.version}</version>
        <scope>test</scope>
      </dependency>
      <dependency>
        <groupId>org.mockito</groupId>
        <artifactId>mockito-all</artifactId>
        <version>${mockito.version}</version>
        <scope>test</scope>
      </dependency>
      <dependency>
        <groupId>com.googlecode.zohhak</groupId>
        <artifactId>zohhak</artifactId>
        <version>1.1.1</version>
        <scope>test</scope>
      </dependency>
      <dependency>
        <groupId>uk.co.datumedge</groupId>
        <artifactId>hamcrest-json</artifactId>
        <version>0.2</version>
        <scope>test</scope>
      </dependency>
      <dependency>
        <groupId>com.github.stefanbirkner</groupId>
        <artifactId>system-rules</artifactId>
        <version>${system-rules.version}</version>
        <scope>test</scope>
        <!-- junit:junit-dep is deprecated, and junit:junit replaces it. -->
        <exclusions>
          <exclusion>
            <groupId>junit</groupId>
            <artifactId>junit-dep</artifactId>
          </exclusion>
        </exclusions>
      </dependency>
    </dependencies>
  </dependencyManagement>

  <dependencies>
    <dependency>
      <groupId>io.vertx</groupId>
      <artifactId>vertx-codegen</artifactId>
    </dependency>
  </dependencies>

  <build>
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-clean-plugin</artifactId>
          <version>${maven.clean.plugin.version}</version>
          <executions>
            <execution>
              <id>default-clean</id>
              <configuration>
                <filesets>
                  <fileset>
                    <directory>${generated.dir}</directory>
                  </fileset>
                </filesets>
              </configuration>
            </execution>
          </executions>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-compiler-plugin</artifactId>
          <version>${maven.compiler.plugin.version}</version>
          <configuration>
            <source>1.8</source>
            <target>1.8</target>
          </configuration>
          <executions>
            <execution>
              <id>default-compile</id>
              <configuration>
                <annotationProcessors>
                  <annotationProcessor>io.vertx.codegen.CodeGenProcessor</annotationProcessor>
                </annotationProcessors>
                <generatedSourcesDirectory>${generated.dir}</generatedSourcesDirectory>
                <compilerArgs>
                  <arg>-AoutputDirectory=${project.basedir}/src/main</arg>
                </compilerArgs>
              </configuration>
            </execution>
            <execution>
              <id>default-testCompile</id>
              <configuration>
                <annotationProcessors>
                  <annotationProcessor>io.vertx.codegen.CodeGenProcessor</annotationProcessor>
                </annotationProcessors>
                <generatedTestSourcesDirectory>${generated.dir}</generatedTestSourcesDirectory>
                <compilerArgs>
                  <arg>-AoutputDirectory=${project.basedir}/src/test</arg>
                </compilerArgs>
              </configuration>
            </execution>
          </executions>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-install-plugin</artifactId>
          <version>${maven.install.plugin.version}</version>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-deploy-plugin</artifactId>
          <version>${maven.deploy.plugin.version}</version>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-jar-plugin</artifactId>
          <version>${maven.jar.plugin.version}</version>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-source-plugin</artifactId>
          <version>${maven.source.plugin.version}</version>
          <executions>
            <execution>
              <id>attach-sources</id>
              <goals>
                <goal>jar-no-fork</goal>
              </goals>
            </execution>
          </executions>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-javadoc-plugin</artifactId>
          <version>${maven.javadoc.plugin.version}</version>
          <executions>
            <execution>
              <id>attach-javadocs</id>
              <goals>
                <goal>jar</goal>
              </goals>
            </execution>
          </executions>
        </plugin>
        <!-- Attache fat jar to the distribution -->
        <plugin>
          <groupId>org.codehaus.mojo</groupId>
          <artifactId>build-helper-maven-plugin</artifactId>
          <version>1.12</version>
          <configuration>
            <skipAttach>true</skipAttach>
          </configuration>
          <executions>
            <execution>
              <id>attach-distribution</id>
              <phase>package</phase>
              <goals>
                <goal>attach-artifact</goal>
              </goals>
              <configuration>
                <artifacts>
                  <artifact>
                    <file>target/${project.artifactId}-${project.version}-fat.jar</file>
                    <type>fat.jar</type>
                  </artifact>
                  <artifact>
                    <file>src/main/resources/${project.artifactId}.json</file>
                    <type>json</type>
                  </artifact>
                  <artifact>
                    <file>src/main/resources/logback.xml</file>
                    <type>logback.xml</type>
                  </artifact>
                </artifacts>
              </configuration>
            </execution>
          </executions>
        </plugin>
        <!-- plugin for checking if licensing header is present in headers of defined files -->
        <plugin>
          <groupId>org.apache.rat</groupId>
          <artifactId>apache-rat-plugin</artifactId>
          <version>${apache.rat.plugin.version}</version>
          <executions>
            <execution>
              <phase>validate</phase>
              <goals>
                <goal>check</goal>
              </goals>
            </execution>
          </executions>
          <configuration>
            <includes>
              <include>src/main/java/**</include>
              <include>src/test/java/**</include>
              <include>src/main/resources/**</include>
              <include>pom.xml</include>
            </includes>
            <excludes>
              <exclude>**/*.json</exclude>
              <exclude>**/*.MD</exclude>
            </excludes>
          </configuration>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-shade-plugin</artifactId>
          <version>${maven.shade.plugin.version}</version>
          <executions>
            <execution>
              <phase>package</phase>
              <goals>
                <goal>shade</goal>
              </goals>
              <configuration>
                <transformers>
                  <transformer
                      implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                    <manifestEntries>
                      <Main-Class>io.knotx.launcher.LogbackLauncher</Main-Class>
                      <Main-Verticle>io.knotx.launcher.KnotxStarterVerticle
                      </Main-Verticle>
                    </manifestEntries>
                  </transformer>
                  <transformer
                      implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                    <resource>META-INF/services/io.vertx.core.spi.VerticleFactory</resource>
                  </transformer>
                </transformers>
                <artifactSet/>
                <outputFile>
                  ${project.build.directory}/${project.artifactId}-${project.version}-fat.jar
                </outputFile>
              </configuration>
            </execution>
          </executions>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-surefire-plugin</artifactId>
          <version>${maven.surefire.plugin.version}</version>
        </plugin>
        <plugin>
          <groupId>org.sonatype.plugins</groupId>
          <artifactId>nexus-staging-maven-plugin</artifactId>
          <version>${maven.nexus.staging.plugin.version}</version>
          <extensions>true</extensions>
          <configuration>
            <serverId>ossrh</serverId>
            <nexusUrl>https://oss.sonatype.org/</nexusUrl>
            <autoReleaseAfterClose>false</autoReleaseAfterClose>
          </configuration>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-gpg-plugin</artifactId>
          <version>${maven.gpg.plugin.version}</version>
          <executions>
            <execution>
              <id>sign-artifacts</id>
              <phase>verify</phase>
              <goals>
                <goal>sign</goal>
              </goals>
            </execution>
          </executions>
        </plugin>
        <plugin>
          <groupId>org.jacoco</groupId>
          <artifactId>jacoco-maven-plugin</artifactId>
          <version>${jacoco.maven.plugin.version}</version>
          <executions>
            <execution>
              <goals>
                <goal>prepare-agent</goal>
              </goals>
            </execution>
            <execution>
              <id>report</id>
              <phase>test</phase>
              <goals>
                <goal>report</goal>
              </goals>
            </execution>
          </executions>
        </plugin>
      </plugins>
    </pluginManagement>
    <plugins>
      <!-- plugin for checking if licensing header is present in headers of defined files -->
      <plugin>
        <groupId>org.apache.rat</groupId>
        <artifactId>apache-rat-plugin</artifactId>
      </plugin>
      <plugin>
        <groupId>org.jacoco</groupId>
        <artifactId>jacoco-maven-plugin</artifactId>
      </plugin>
    </plugins>
  </build>

  <profiles>
    <profile>
      <id>release</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-source-plugin</artifactId>
          </plugin>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-javadoc-plugin</artifactId>
          </plugin>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-gpg-plugin</artifactId>
            <version>${maven.gpg.plugin.version}</version>
            <executions>
              <execution>
                <id>sign-artifacts</id>
                <phase>verify</phase>
                <goals>
                  <goal>sign</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <groupId>org.sonatype.plugins</groupId>
            <artifactId>nexus-staging-maven-plugin</artifactId>
          </plugin>
        </plugins>
      </build>
    </profile>
    <profile>
      <id>skip-integration-tests</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <configuration>
              <excludes>
                <exclude>**/*SampleApplicationTest.java</exclude>
                <exclude>**/*SampleApplicationHeadersTest.java</exclude>
                <exclude>**/*HttpClientFacadeTest.java</exclude>
                <exclude>**/*HttpServiceAdapterTest.java</exclude>
                <exclude>**/*KnotxServerRoutingTest.java</exclude>
              </excludes>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>
</project>
