<?xml version="1.0" encoding="UTF-8"?>
<!--
  ~ Copyright 2019 Red Hat, Inc. and/or its affiliates.
  ~
  ~ 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.kie</groupId>
    <artifactId>kie-parent</artifactId>
    <version>7.34.0-SNAPSHOT</version>
  </parent>

  <groupId>org.optaweb.vehiclerouting</groupId>
  <artifactId>optaweb-vehicle-routing</artifactId>
  <packaging>pom</packaging>

  <name>OptaWeb Vehicle Routing</name>

  <!-- Modules are sorted in preferred build order. -->
  <modules>
    <module>optaweb-vehicle-routing-backend</module>
    <module>optaweb-vehicle-routing-frontend</module>
    <module>optaweb-vehicle-routing-standalone</module>
    <module>optaweb-vehicle-routing-docs</module>
    <module>optaweb-vehicle-routing-distribution</module>
  </modules>

  <properties>
    <!-- Define JaCoCo agent argLine property to avoid Surefire failure when JaCoCo is not enabled. -->
    <jacoco.agent.argLine/>
    <version.com.h2database>1.4.199</version.com.h2database>
    <version.org.mockito>3.1.0</version.org.mockito>
    <version.org.postgresql>42.2.5</version.org.postgresql>
  </properties>

  <dependencyManagement>
    <dependencies>
      <!-- Internal dependencies -->
      <dependency>
        <groupId>org.optaweb.vehiclerouting</groupId>
        <artifactId>optaweb-vehicle-routing-backend</artifactId>
        <version>${project.version}</version>
      </dependency>
      <dependency>
        <groupId>org.optaweb.vehiclerouting</groupId>
        <artifactId>optaweb-vehicle-routing-docs</artifactId>
        <version>${project.version}</version>
        <type>zip</type>
      </dependency>
      <dependency>
        <groupId>org.optaweb.vehiclerouting</groupId>
        <artifactId>optaweb-vehicle-routing-frontend</artifactId>
        <version>${project.version}</version>
        <type>war</type>
      </dependency>
      <!-- BOM imports -->
      <dependency>
        <groupId>org.optaweb.vehiclerouting</groupId>
        <artifactId>optaweb-vehicle-routing-standalone</artifactId>
        <version>${project.version}</version>
      </dependency>
      <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-dependencies</artifactId>
        <version>${version.org.springframework.boot}</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
      <dependency>
        <groupId>org.optaplanner</groupId>
        <artifactId>optaplanner-bom</artifactId>
        <version>${version.org.optaplanner}</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
      <!-- Dependencies not managed by kie-parent and version overrides -->
      <dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-databind</artifactId>
        <version>2.9.10</version>
      </dependency>
      <dependency>
        <groupId>com.fasterxml.jackson.dataformat</groupId>
        <artifactId>jackson-dataformat-yaml</artifactId>
        <version>2.9.10</version>
      </dependency>
      <dependency>
        <groupId>com.graphhopper</groupId>
        <artifactId>graphhopper-reader-osm</artifactId>
        <version>0.13.0-pre13</version>
      </dependency>
    </dependencies>
  </dependencyManagement>

  <build>
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>org.springframework.boot</groupId>
          <artifactId>spring-boot-maven-plugin</artifactId>
          <version>${version.org.springframework.boot}</version>
        </plugin>
        <plugin>
          <groupId>org.jacoco</groupId>
          <artifactId>jacoco-maven-plugin</artifactId>
          <executions>
            <execution>
              <id>jacoco-prepare-agent</id>
              <goals>
                <goal>prepare-agent</goal>
              </goals>
              <configuration>
                <propertyName>jacoco.agent.argLine</propertyName>
              </configuration>
            </execution>
            <execution>
              <id>jacoco-generate-report</id>
              <goals>
                <goal>report</goal>
              </goals>
            </execution>
          </executions>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-surefire-plugin</artifactId>
          <configuration>
            <!-- Append jacoco.agent.argLine property populated by JaCoCo's prepare-agent goal. -->
            <argLine>@{jacoco.agent.argLine}</argLine>
          </configuration>
        </plugin>
      </plugins>
    </pluginManagement>
  </build>

  <profiles>
    <!-- Skip Sonar plugin execution if SONARCLOUD_TOKEN is not set. -->
    <profile>
      <id>skipSonar</id>
      <activation>
        <property>
          <name>!env.SONARCLOUD_TOKEN</name>
        </property>
      </activation>
      <properties>
        <sonar.skip>true</sonar.skip>
      </properties>
    </profile>
    <profile>
      <id>pullRequestAnalysis-Travis</id>
      <!--
        Only set sonar.pullrequest properties when the Travis build is triggered by a PR.
        When the build is triggered by push to a branch or by cron, the consumed env.TRAVIS properties are empty,
        resulting in invalid sonar.pullrequest properties and the Sonar plugin would fail.
      -->
      <activation>
        <property>
          <name>env.TRAVIS_EVENT_TYPE</name>
          <value>pull_request</value>
        </property>
      </activation>
      <!--
        See https://docs.travis-ci.com/user/environment-variables/ for list of Travis environment variables.
        See https://docs.sonarqube.org/latest/analysis/pull-request/ for properties required by Sonar for PR analysis.
      -->
      <properties>
        <!--suppress UnresolvedMavenProperty -->
        <sonar.pullrequest.branch>${env.TRAVIS_PULL_REQUEST_BRANCH}</sonar.pullrequest.branch>
        <!--suppress UnresolvedMavenProperty -->
        <sonar.pullrequest.key>${env.TRAVIS_PULL_REQUEST}</sonar.pullrequest.key>
        <!--suppress UnresolvedMavenProperty -->
        <sonar.pullrequest.base>${env.TRAVIS_BRANCH}</sonar.pullrequest.base>
      </properties>
    </profile>
    <profile>
      <id>branchAnalysis-Travis</id>
      <activation>
        <property>
          <name>env.TRAVIS_EVENT_TYPE</name>
          <value>!pull_request</value>
        </property>
      </activation>
      <!--
        See https://docs.travis-ci.com/user/environment-variables/ for list of Travis environment variables.
        See https://docs.sonarqube.org/latest/branches/overview/ for properties required by Sonar for branch analysis.
      -->
      <properties>
        <!--suppress UnresolvedMavenProperty -->
        <sonar.branch.name>${env.TRAVIS_BRANCH}</sonar.branch.name>
      </properties>
    </profile>
  </profiles>

  <repositories>
    <!-- Bootstrap repository to locate the parent POM when it has not been built locally. -->
    <repository>
      <id>jboss-public-repository-group</id>
      <name>JBoss Public Repository Group</name>
      <url>https://repository.jboss.org/nexus/content/groups/public/</url>
      <layout>default</layout>
      <releases>
        <enabled>true</enabled>
        <updatePolicy>never</updatePolicy>
      </releases>
      <snapshots>
        <enabled>true</enabled>
        <updatePolicy>daily</updatePolicy>
      </snapshots>
    </repository>
  </repositories>
</project>
