<?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.3.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>knotx-core</module>

    <module>knotx-mocks</module>
    <module>knotx-adapter</module>
    <module>knotx-knot</module>
    <module>knotx-it-tests</module>

    <module>documentation</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>

  <repositories>
    <repository>
      <id>sonatype-nexus-snapshots</id>
      <name>Sonatype Nexus Snapshots</name>
      <url>https://oss.sonatype.org/content/repositories/snapshots</url>
      <releases>
        <enabled>false</enabled>
      </releases>
      <snapshots>
        <enabled>true</enabled>
      </snapshots>
    </repository>
  </repositories>

  <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>

    <!-- 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>
    <maven.failsafe.plugin.version>2.21.0</maven.failsafe.plugin.version>
    <jacoco.maven.plugin.version>0.7.7.201606060606</jacoco.maven.plugin.version>

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

    <timestamp>${maven.build.timestamp}</timestamp>
    <maven.build.timestamp.format>yyyy-MM-dd HH:mm</maven.build.timestamp.format>
  </properties>

  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>io.knotx</groupId>
        <artifactId>knotx-dependencies</artifactId>
        <version>${project.version}</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
    </dependencies>
  </dependencyManagement>

  <dependencies>
    <dependency>
      <groupId>io.vertx</groupId>
      <artifactId>vertx-codegen</artifactId>
      <scope>provided</scope>
    </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>-Acodegen.output=${project.basedir}/src/main</arg>
                  <arg>
                    -Acodegen.generators=knotx-cheatsheet,data_object_converters,RxJava2,service_proxies
                  </arg>
                </compilerArgs>
              </configuration>
            </execution>
            <execution>
              <id>default-testCompile</id>
              <configuration>
                <annotationProcessors>
                  <annotationProcessor>io.vertx.codegen.CodeGenProcessor</annotationProcessor>
                </annotationProcessors>
                <generatedTestSourcesDirectory>${generated.dir}</generatedTestSourcesDirectory>
                <compilerArgs>
                  <arg>-Acodegen.output=${project.basedir}/src/test</arg>
                  <arg>-Acodegen.generators=data_object_converters,RxJava2,service_proxies</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>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-failsafe-plugin</artifactId>
          <version>${maven.failsafe.plugin.version}</version>
          <executions>
            <execution>
              <id>integration-test</id>
              <goals>
                <goal>integration-test</goal>
              </goals>
              <configuration>
                <systemPropertyVariables>
                  <vertx.logger-delegate-factory-class-name>
                    io.vertx.core.logging.SLF4JLogDelegateFactory
                  </vertx.logger-delegate-factory-class-name>
                </systemPropertyVariables>
              </configuration>
            </execution>
            <execution>
              <id>verify</id>
              <goals>
                <goal>verify</goal>
              </goals>
              <configuration>
                <systemPropertyVariables>
                  <vertx.logger-delegate-factory-class-name>
                    io.vertx.core.logging.SLF4JLogDelegateFactory
                  </vertx.logger-delegate-factory-class-name>
                </systemPropertyVariables>
              </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>
              <exclude>**/*.templ</exclude>
            </excludes>
          </configuration>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-surefire-plugin</artifactId>
          <version>${maven.surefire.plugin.version}</version>
          <configuration>
            <systemPropertyVariables>
              <vertx.logger-delegate-factory-class-name>
                io.vertx.core.logging.SLF4JLogDelegateFactory
              </vertx.logger-delegate-factory-class-name>
            </systemPropertyVariables>
          </configuration>
        </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>**/*HttpClientFacadeTest.java</exclude>
                <exclude>**/*HttpServiceAdapterTest.java</exclude>
                <exclude>**/*KnotxServerRoutingTest.java</exclude>
              </excludes>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>
</project>
