<?xml version="1.0" encoding="UTF-8"?>
<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/maven-v4_0_0.xsd">

  <modelVersion>4.0.0</modelVersion>
  <parent>
    <groupId>org.kie</groupId>
    <artifactId>kie-parent</artifactId>
    <version>7.30.0.Final</version>
  </parent>

  <groupId>org.optaweb.employeerostering</groupId>
  <artifactId>employee-rostering</artifactId>
  <packaging>pom</packaging>

  <name>Employee Rostering as a Service Parent</name>
  <description>
    Employee Rostering as a Service with OptaPlanner on OpenShift 3.
  </description>
  <url>https://www.optaplanner.org</url>
  <inceptionYear>2017</inceptionYear>

  <repositories>
    <!-- Bootstrap repository to locate the parent pom when the parent pom has not been build 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>

  <properties>
    <checkstyle.logViolationsToConsole>true</checkstyle.logViolationsToConsole>
    <checkstyle.header.template><![CDATA[
^\/\*$\n^
\* Copyright \d\d\d\d Red Hat, Inc\. and\/or its affiliates\.$\n^
\*$\n^
\* Licensed under the Apache License, Version 2\.0 \(the &quot;License&quot;\);$\n^
\* you may not use this file except in compliance with the License\.$\n^
\* You may obtain a copy of the License at$\n^
\*$\n^
\*     http:\/\/www\.apache\.org\/licenses\/LICENSE-2\.0$\n^
\*$\n^
\* Unless required by applicable law or agreed to in writing, software$\n^
\* distributed under the License is distributed on an &quot;AS IS&quot; BASIS,$\n^
\* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied\.$\n^
\* See the License for the specific language governing permissions and$\n^
\* limitations under the License\.$\n^
\*\/$
]]>
    </checkstyle.header.template>
    <wildfly.parent>${project.basedir}/local/appserver</wildfly.parent>
    <wildfly.home>${wildfly.parent}/wildfly-${version.org.wildfly}</wildfly.home>
    <wildfly.launchdir>${project.basedir}/local/appserver/wildfly-${version.org.wildfly}</wildfly.launchdir>
    <wildfly.install.skip>false</wildfly.install.skip>
    <deployment.parent>${project.basedir}/employee-rostering-webapp/target</deployment.parent>
    <deployment.name>optaweb-${project.artifactId}-${project.version}</deployment.name>
    <antrun.skip>false</antrun.skip>

    <!-- Maven resource filtering -->
    <org.optaweb.employeerostering.persistence.datasource>java:jboss/datasources/ExampleDS</org.optaweb.employeerostering.persistence.datasource>
    <org.optaweb.employeerostering.persistence.dialect>org.hibernate.dialect.H2Dialect</org.optaweb.employeerostering.persistence.dialect>
    <org.optaweb.employeerostering.persistence.hbm2ddl.auto>create</org.optaweb.employeerostering.persistence.hbm2ddl.auto>

    <version.javax.validation>2.0.1.Final</version.javax.validation>
    <version.org.mockito>2.12.0</version.org.mockito>
    <version.org.postgresql>42.2.6</version.org.postgresql>
    <version.org.springframework.boot>2.1.8.RELEASE</version.org.springframework.boot>
    <version.org.springframework>5.1.9.RELEASE</version.org.springframework>
  </properties>

  <modules>
    <module>employee-rostering-frontend</module>
    <module>employee-rostering-backend</module>
    <module>employee-rostering-benchmark</module>
    <module>employee-rostering-docs</module>
    <module>employee-rostering-distribution</module>
  </modules>

  <dependencyManagement>
    <dependencies>
      <!-- Internal modules -->
      <dependency>
        <groupId>org.optaweb.employeerostering</groupId>
        <artifactId>employee-rostering-frontend</artifactId>
        <type>jar</type>
        <version>${project.version}</version>
      </dependency>
      <dependency>
        <groupId>org.optaweb.employeerostering</groupId>
        <artifactId>employee-rostering-backend</artifactId>
        <type>jar</type>
        <version>${project.version}</version>
      </dependency>
      <dependency>
        <groupId>org.optaweb.employeerostering</groupId>
        <artifactId>employee-rostering-backend</artifactId>
        <classifier>exec</classifier>
        <type>jar</type>
        <version>${project.version}</version>
      </dependency>
      <dependency>
        <groupId>org.optaweb.employeerostering</groupId>
        <artifactId>employee-rostering-docs</artifactId>
        <type>zip</type>
        <version>${project.version}</version>
      </dependency>

      <!-- BOMs -->
      <dependency>
        <groupId>org.optaplanner</groupId>
        <artifactId>optaplanner-bom</artifactId>
        <type>pom</type>
        <version>${version.org.kie}</version>
        <scope>import</scope>
      </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>io.springfox</groupId>
        <artifactId>springfox-swagger2</artifactId>
        <version>2.9.2</version>
      </dependency>
      <dependency>
        <groupId>io.springfox</groupId>
        <artifactId>springfox-swagger-ui</artifactId>
        <version>2.9.2</version>
      </dependency>
    </dependencies>
  </dependencyManagement>

  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-checkstyle-plugin</artifactId>
        <configuration>
          <failOnViolation>true</failOnViolation>
        </configuration>
      </plugin>
    </plugins>

    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>org.springframework.boot</groupId>
          <artifactId>spring-boot-maven-plugin</artifactId>
          <version>${version.org.springframework.boot}</version>
        </plugin>
        <!--
          Disable Jacoco check inherited from kie-parent. Remove this when it's removed from kie-parent
          (but some projects still use the check fail build).
        -->
        <plugin>
          <groupId>org.jacoco</groupId>
          <artifactId>jacoco-maven-plugin</artifactId>
          <executions>
            <execution>
              <id>default-check</id>
              <goals>
                <goal>check</goal>
              </goals>
              <phase>none</phase>
            </execution>
          </executions>
        </plugin>
      </plugins>
    </pluginManagement>
  </build>

  <profiles>
    <profile>
      <!-- Magic profileId that is activated automatically in OpenShift S2I builds -->
      <id>openshift</id>
      <properties>
        <wildfly.install.skip>true</wildfly.install.skip>
        <antrun.skip>true</antrun.skip>
        <cargo.maven.skip>true</cargo.maven.skip>
      </properties>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-failsafe-plugin</artifactId>
            <configuration>
              <!-- Because cargo was skipped -->
              <skipITs>true</skipITs>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
    <profile>
      <!-- To activate use -Dproductized (not -P) -->
      <id>productized</id>
      <activation>
        <property>
          <name>productized</name>
        </property>
      </activation>
      <properties>
        <!-- Maven resource filtering -->
        <dollarSign>$</dollarSign><!-- HACK to escape maven property interpolation -->
        <!-- The productized docker image has EAP <spec-descriptor-property-replacement> set to true -->
        <!-- to dynamically configure the database type (mysql, postgresql, ...). -->
        <org.optaweb.employeerostering.persistence.datasource>${dollarSign}{org.optaweb.employeerostering.persistence.datasource:java:jboss/datasources/ExampleDS}</org.optaweb.employeerostering.persistence.datasource>
        <org.optaweb.employeerostering.persistence.dialect>${dollarSign}{org.optaweb.employeerostering.persistence.dialect:org.hibernate.dialect.H2Dialect}</org.optaweb.employeerostering.persistence.dialect>
        <org.optaweb.employeerostering.persistence.hbm2ddl.auto>${dollarSign}{org.optaweb.employeerostering.persistence.hbm2ddl.auto:update}</org.optaweb.employeerostering.persistence.hbm2ddl.auto>
      </properties>
      <build>
        <pluginManagement>
          <plugins>
            <plugin>
              <groupId>org.codehaus.cargo</groupId>
              <artifactId>cargo-maven2-plugin</artifactId>
              <configuration>
                <configuration>
                  <properties>
                    <cargo.wildfly.script.cli.embedded.descriptor-replacement>${project.build.testOutputDirectory}/descriptor-replacement.cli</cargo.wildfly.script.cli.embedded.descriptor-replacement>
                  </properties>
                </configuration>
              </configuration>
            </plugin>
          </plugins>
        </pluginManagement>
      </build>
    </profile>

    <profile>
      <id>run-code-coverage</id>
      <properties>
        <jacoco.excludes>*Lexer</jacoco.excludes>
        <jacoco.exec.file>${project.build.directory}/jacoco.exec</jacoco.exec.file>
        <jacoco.agent.line>-javaagent:${settings.localRepository}/org/jacoco/org.jacoco.agent/${version.jacoco.plugin}/org.jacoco.agent-${version.jacoco.plugin}-runtime.jar=destfile=${jacoco.exec.file},append=true,excludes=${jacoco.excludes}</jacoco.agent.line>
      </properties>
      <dependencyManagement>
        <dependencies>
          <dependency>
            <groupId>org.jacoco</groupId>
            <artifactId>org.jacoco.agent</artifactId>
            <version>${version.jacoco.plugin}</version>
          </dependency>
        </dependencies>
      </dependencyManagement>
      <dependencies>
        <dependency>
          <groupId>org.jacoco</groupId>
          <artifactId>org.jacoco.agent</artifactId>
          <classifier>runtime</classifier>
          <scope>test</scope>
        </dependency>
      </dependencies>
      <build>
        <pluginManagement>
          <plugins>
            <plugin>
              <groupId>org.jacoco</groupId>
              <artifactId>jacoco-maven-plugin</artifactId>
              <version>${version.jacoco.plugin}</version>
              <configuration>
                <append>true</append>
                <destFile>${jacoco.exec.file}</destFile>
                <excludes>
                  <exclude>${jacoco.excludes}</exclude>
                </excludes>
              </configuration>
              <executions>
                <execution>
                  <id>default-instrument</id>
                  <goals>
                    <goal>instrument</goal>
                  </goals>
                </execution>
                <execution>
                  <id>default-restore-instrumented-classes</id>
                  <goals>
                    <goal>restore-instrumented-classes</goal>
                  </goals>
                </execution>
              </executions>
            </plugin>
            <plugin>
              <groupId>org.codehaus.cargo</groupId>
              <artifactId>cargo-maven2-plugin</artifactId>
              <configuration>
                <configuration>
                  <properties>
                    <cargo.start.jvmargs>${jacoco.agent.line}</cargo.start.jvmargs>
                  </properties>
                </configuration>
              </configuration>
              <dependencies>
                <dependency>
                  <groupId>org.jacoco</groupId>
                  <artifactId>org.jacoco.agent</artifactId>
                  <version>${version.jacoco.plugin}</version>
                </dependency>
              </dependencies>
            </plugin>
            <plugin>
              <artifactId>maven-surefire-plugin</artifactId>
              <configuration>
                <systemPropertyVariables>
                  <jacoco-agent.destfile>${jacoco.exec.file}</jacoco-agent.destfile>
                </systemPropertyVariables>
              </configuration>
            </plugin>
          </plugins>
        </pluginManagement>
        <plugins>
          <plugin>
            <groupId>org.jacoco</groupId>
            <artifactId>jacoco-maven-plugin</artifactId>
          </plugin>
        </plugins>
      </build>
    </profile>

    <profile>
      <!--
        For running the report manually, please refer to travis.yml.
      -->
      <id>report-code-coverage</id>
      <properties>
        <jacoco.master.exec.file>${maven.multiModuleProjectDirectory}/target/jacoco.exec</jacoco.master.exec.file>
        <sonar.jacoco.reportPaths>${jacoco.master.exec.file}</sonar.jacoco.reportPaths>
      </properties>
      <build>
        <pluginManagement>
          <plugins>
            <plugin>
              <groupId>org.jacoco</groupId>
              <artifactId>jacoco-maven-plugin</artifactId>
              <version>${version.jacoco.plugin}</version>
              <configuration>
                <fileSets>
                  <fileSet>
                    <directory>${project.build.directory}</directory>
                    <includes>
                      <include>*.exec</include>
                    </includes>
                  </fileSet>
                </fileSets>
                <destFile>${jacoco.master.exec.file}</destFile>
              </configuration>
            </plugin>
          </plugins>
        </pluginManagement>
      </build>
    </profile>

    <profile>
      <!-- environment-specific profile that should be activated only when running in travis-ci. -->
      <id>travis-ci</id>
      <activation>
        <property>
          <name>env.TRAVIS</name>
          <value>true</value>
        </property>
      </activation>
      <build>
        <pluginManagement>
          <plugins>
            <plugin>
              <groupId>org.codehaus.cargo</groupId>
              <artifactId>cargo-maven2-plugin</artifactId>
              <configuration>
                <container>
                  <systemProperties>
                    <java.net.preferIPv4Stack>true</java.net.preferIPv4Stack>
                    <java.net.preferIPv4Addresses>true</java.net.preferIPv4Addresses>
                  </systemProperties>
                </container>
              </configuration>
            </plugin>
          </plugins>
        </pluginManagement>
      </build>
    </profile>

    <profile>
      <id>sonar</id>
      <properties>
        <sonar.projectKey>optaweb-employee-rostering</sonar.projectKey>
        <sonar.moduleKey>${project.artifactId}</sonar.moduleKey>
        <sonar.organization>kiegroup</sonar.organization>
        <sonar.host.url>https://sonarcloud.io/</sonar.host.url>
        <!--suppress UnresolvedMavenProperty -->
        <sonar.login>${env.SONARCLOUD_TOKEN}</sonar.login>
      </properties>
      <build>
        <plugins>
          <plugin>
            <groupId>org.sonarsource.scanner.maven</groupId>
            <artifactId>sonar-maven-plugin</artifactId>
            <version>3.6.0.1398</version>
            <executions>
              <execution>
                <phase>verify</phase>
                <goals>
                  <goal>sonar</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
    <profile>
      <!-- Skip Sonar plugin execution if SONARCLOUD_TOKEN is not set. -->
      <id>skipSonar</id>
      <activation>
        <property>
          <name>!env.SONARCLOUD_TOKEN</name>
        </property>
      </activation>
      <properties>
        <sonar.skip>true</sonar.skip>
      </properties>
    </profile>
    <profile>
      <id>pullRequestAnalysis</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</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>
</project>
