<?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/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <parent>
    <groupId>org.pentaho</groupId>
    <artifactId>pentaho-ce-parent-pom</artifactId>
    <version>8.0.0.0-28</version>
  </parent>
  
  <groupId>org.pentaho</groupId>
  <artifactId>pentaho-ce-jar-parent-pom</artifactId>
  <version>8.0.0.0-28</version>
  <packaging>pom</packaging>

  <name>Pentaho Community Edition Project Parent POM For Java Projects</name>
  <description>parent pom for Pentaho CE Java projects</description>
  <url>http://wwww.pentaho.org</url>
  
  <licenses>
    <license>
      <name>Apache License, Version 2.0</name>
      <url>http://www.apache.org/licenses/LICENSE-2.0</url>
      <distribution>repo</distribution>
    </license>
  </licenses>
  
  <modules>
    <module>pentaho-ce-bundle-parent-pom</module>
  </modules>

  <properties>
    <!-- VERSIONS -->
    <junit.version>4.11</junit.version>

    <coding-standards.version>8.1.0.0-SNAPSHOT</coding-standards.version>
    <checkstyle.version>8.0</checkstyle.version>

    <!-- http://maven.apache.org/surefire/maven-surefire-plugin/examples/fork-options-and-parallel-execution.html -->
    <maven-surefire-plugin.reuseForks>true</maven-surefire-plugin.reuseForks> <!-- default setting is reuseForks = true -->
    <maven-surefire-plugin.forkCount>1</maven-surefire-plugin.forkCount> <!-- default setting is forkCount = 1 -->
    <maven-surefire-plugin.testFailureIgnore>false</maven-surefire-plugin.testFailureIgnore>
    <maven-failsafe-plugin.reuseForks>true</maven-failsafe-plugin.reuseForks> <!-- default setting is reuseForks = true -->
    <maven-failsafe-plugin.forkCount>1</maven-failsafe-plugin.forkCount> <!-- default setting is forkCount = 1 -->    
    
    <SCM_BRANCH>master</SCM_BRANCH>
    <sonar.project.name>${project.artifactId}</sonar.project.name>
    <sonar.host.url>http://sonar.pentaho.com:9000</sonar.host.url>
    <sonar.language>java</sonar.language>
    <sonar.java.coveragePlugin>jacoco</sonar.java.coveragePlugin>
    <sonar.projectName>${sonar.project.name}</sonar.projectName>
    <sonar.branch>${SCM_BRANCH}</sonar.branch>
    <sonar.jacoco.reportPath>${project.build.directory}/jacoco.exec</sonar.jacoco.reportPath>
    <sonar.jacoco.itReportPath>${project.build.directory}/jacoco-it.exec</sonar.jacoco.itReportPath>
  </properties>

  <build>
    <plugins>
      <plugin>
        <groupId>org.jacoco</groupId>
        <artifactId>jacoco-maven-plugin</artifactId>
        <executions>
          <execution>
            <id>test-unit-jacoco-agent-prep</id>
            <phase>${test-unit-jacoco-agent-prep-phase}</phase>
            <goals>
              <goal>prepare-agent</goal>
            </goals>
            <configuration>
              <propertyName>surefireArgLine</propertyName>
            </configuration>
          </execution>
          <execution>
            <id>test-unit-jacoco-report</id>
            <phase>${test-unit-jacoco-report-phase}</phase>
            <goals>
              <goal>report</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <artifactId>maven-surefire-plugin</artifactId>
        <executions>
          <execution>
            <id>default-test</id>
            <phase>${test-unit-execute-phase}</phase>
            <goals>
              <goal>test</goal>
            </goals>
            <configuration>
              <argLine>${surefireArgLine}</argLine>
              <forkCount>${maven-surefire-plugin.forkCount}</forkCount>
              <reuseForks>${maven-surefire-plugin.reuseForks}</reuseForks>
              <testFailureIgnore>${maven-surefire-plugin.testFailureIgnore}</testFailureIgnore>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <artifactId>maven-source-plugin</artifactId>
        <executions>
          <execution>
            <id>attach-sources</id>
            <phase>${attach-sources-phase}</phase>
            <goals>
              <goal>jar-no-fork</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <artifactId>maven-checkstyle-plugin</artifactId>
        <dependencies>
          <dependency>
            <groupId>com.puppycrawl.tools</groupId>
            <artifactId>checkstyle</artifactId>
            <version>${checkstyle.version}</version>
          </dependency>
          <dependency>
            <groupId>org.pentaho</groupId>
            <artifactId>coding-standards</artifactId>
            <version>${coding-standards.version}</version>
            <type>zip</type>
          </dependency>
        </dependencies>
      </plugin>
    </plugins>
  </build>

  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>${junit.version}</version>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <profiles>
    <profile>
      <id>test-integration</id>
      <activation>
        <property>
          <name>runITs</name>
        </property>
      </activation>
      <properties>
        <integration-test.resources>src/it/resources</integration-test.resources>
        <integration-test.src>src/it/java</integration-test.src>
      </properties>
      <build>
        <plugins>
          <plugin>
            <artifactId>maven-resources-plugin</artifactId>
            <executions>
              <execution>
                <id>test-integration_add-resources</id>
                <phase>${test-integration_add-resources-phase}</phase>
                <goals>
                  <goal>copy-resources</goal>
                </goals>
                <configuration>
                  <outputDirectory>${project.build.directory}/it-classes</outputDirectory>
                  <resources>
                    <resource>
                      <directory>${integration-test.resources}</directory>
                    </resource>
                  </resources>
                </configuration>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>build-helper-maven-plugin</artifactId>
            <executions>
              <execution>
                <id>test-integration_add-source</id>
                <phase>${test-integration_add-source-phase}</phase>
                <goals>
                  <goal>add-test-source</goal>
                </goals>
                <configuration>
                  <sources>
                    <source>${integration-test.src}</source>
                  </sources>
                </configuration>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <groupId>org.jacoco</groupId>
            <artifactId>jacoco-maven-plugin</artifactId>
            <executions>
              <execution>
                <id>test-integration_jacoco-agent-prep</id>
                <phase>${test-integration_jacoco-agent-prep-phase}</phase>
                <goals>
                  <goal>prepare-agent-integration</goal>
                </goals>
                <configuration>
                  <propertyName>failsafeArgLine</propertyName>
                </configuration>
              </execution>
              <execution>
                <id>test-integration_jacoco-report</id>
                <phase>${test-integration_jacoco-report-phase}</phase>
                <goals>
                  <goal>report-integration</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <executions>
              <execution>
                <id>test-integration_compile</id>
                <phase>${test-integration_compile-phase}</phase>
                <goals>
                  <goal>testCompile</goal>
                </goals>
                <configuration>
                  <testExcludes>
                    <testExcludes>**/*Test.java</testExcludes>
                  </testExcludes>
                  <outputDirectory>${project.build.directory}/it-classes</outputDirectory>
                </configuration>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <artifactId>maven-failsafe-plugin</artifactId>
            <executions>
              <execution>
                <id>test-integration_execute</id>
                <phase>${test-integration_execute-phase}</phase>
                <goals>
                  <goal>integration-test</goal>
                </goals>
              </execution>
              <execution>
                <id>test-integration_report</id>
                <phase>${test-integration_report-phase}</phase>
                <goals>
                  <goal>verify</goal>
                </goals>
              </execution>
            </executions>
            <configuration>
              <argLine>${failsafeArgLine}</argLine>
              <forkCount>${maven-failsafe-plugin.forkCount}</forkCount>
              <reuseForks>${maven-failsafe-plugin.reuseForks}</reuseForks>
              <testClassesDirectory>${project.build.directory}/it-classes</testClassesDirectory>
              <reportsDirectory>${project.build.directory}/surefire-reports</reportsDirectory> <!-- SEE https://jira.sonarsource.com/browse/SONARJAVA-45 -->
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>

    <profile>
      <id>reporting</id>
      <activation>
        <property>
          <name>!maven.test.skip</name>
        </property>
      </activation>
      <reporting>
        <plugins>
          <plugin>
            <artifactId>maven-project-info-reports-plugin</artifactId>
            <configuration>
              <dependencyLocationsEnabled>false</dependencyLocationsEnabled>
            </configuration>
          </plugin>
          <plugin>
            <artifactId>maven-jxr-plugin</artifactId>
            <reportSets>
              <reportSet>
                <id>jxr</id>
                <reports>
                  <report>jxr</report>
                </reports>
              </reportSet>
            </reportSets>
            <configuration>
              <linkJavadoc>true</linkJavadoc>
            </configuration>
          </plugin>
          <plugin>
            <artifactId>maven-javadoc-plugin</artifactId>
            <reportSets>
              <reportSet>
                <id>javadoc</id>
                <reports>
                  <report>javadoc</report>
                </reports>
              </reportSet>
            </reportSets>
            <configuration>
              <failOnError>false</failOnError>
            </configuration>
          </plugin>
          <plugin>
            <artifactId>maven-checkstyle-plugin</artifactId>
            <reportSets>
              <reportSet>
                <id>checkstyle</id>
                <reports>
                  <report>checkstyle</report>
                </reports>
              </reportSet>
            </reportSets>
            <configuration>
              <!--  configuration file comes from coding-standards artifact -->
              <configLocation>checkstyle/pentaho_checks.xml</configLocation>
              <linkXRef>true</linkXRef>
              <cacheFile />
            </configuration>
          </plugin>
          <plugin>
            <groupId>org.jacoco</groupId>
            <artifactId>jacoco-maven-plugin</artifactId>
          </plugin>
          <plugin>
            <artifactId>maven-surefire-report-plugin</artifactId>
            <reportSets>
              <reportSet>
                <id>unit-tests</id>
                <reports>
                  <report>report-only</report>
                </reports>
              </reportSet>
              <reportSet>
                <id>integration-tests</id>
                <reports>
                  <report>failsafe-report-only</report>
                </reports>
              </reportSet>
            </reportSets>
            <configuration>
              <linkXRef>true</linkXRef>
            </configuration>
          </plugin>
          <plugin>
            <artifactId>maven-site-plugin</artifactId>
          </plugin>
        </plugins>
      </reporting>
    </profile>

    <profile>
      <id>javadoc</id>
      <activation>
        <property>
          <name>javadoc</name>
        </property>
      </activation>
      <build>
        <plugins>
          <plugin>
            <artifactId>maven-javadoc-plugin</artifactId>
            <executions>
              <execution>
                <id>attach-javadoc</id>
                <phase>package</phase>
                <goals>
                  <goal>jar</goal>
                </goals>
                <configuration>
                  <additionalparam>-Xdoclint:none</additionalparam>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>

    <profile>
      <id>sonar</id>
      <activation>
        <activeByDefault>true</activeByDefault>
      </activation>
      <build>
        <plugins>
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>sonar-maven-plugin</artifactId>
            <version>${sonar-maven-plugin.version}</version>
            <executions>
              <execution>
                <id>sonar_publish</id>
                <configuration>
                  <sonarHostURL>${sonar.host.url}</sonarHostURL>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>
</project>
