<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
         xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <modelVersion>4.0.0</modelVersion>

  <artifactId>java-pom</artifactId>
  <version>0.1.5</version>
  <packaging>pom</packaging>

  <parent>
    <groupId>info.kfgodel</groupId>
    <artifactId>root-pom</artifactId>
    <version>0.2.1</version>
  </parent>

  <name>Kfodel-Java-pom</name>
  <description>Pom definition for all kfgodel Java projects</description>
  <url>https://github.com/kfgodel/kfgodel-java-pom</url>

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

  <scm>
    <developerConnection>scm:git:ssh://github.com/kfgodel/kfgodel-java-pom.git</developerConnection>
    <connection>${project.scm.developerConnection}</connection>
    <url>${project.url}</url>
  </scm>

  <properties>
    <project.java.source>1.8</project.java.source>
    <project.java.target>1.8</project.java.target>

    <version.plugin.compiler>3.3</version.plugin.compiler>
    <version.plugin.jar>2.6</version.plugin.jar>
    <version.plugin.source>2.4</version.plugin.source>
    <version.plugin.failsafe>2.19.1</version.plugin.failsafe>
    <version.plugin.surefire>2.19.1</version.plugin.surefire>
    <version.plugin.jacoco>0.7.6.201602180812</version.plugin.jacoco>
    <version.plugin.jgit-buildnumber>1.2.9</version.plugin.jgit-buildnumber>
    <version.plugin.buildnumber>1.4</version.plugin.buildnumber>
    <version.plugin.querydsl>1.1.3</version.plugin.querydsl>
    <version.plugin.javadoc>3.0.0</version.plugin.javadoc>

    <version.querydsl>4.0.9</version.querydsl>
    <version.slf4j>1.7.25</version.slf4j>
    <version.logback>1.2.3</version.logback>
    <version.junit>4.12</version.junit>
    <version.guava>27.0.1-jre</version.guava>
    <version.mockito>2.24.0</version.mockito>
    <version.assertj>3.11.1</version.assertj>

    <version.javaspec>2.4.3</version.javaspec>
    <version.nary>2.0.7</version.nary>

    <!-- Location of the JaCoCo output file created by the agent execution during ITs. We want
all modules to dump their coverage information into a single file for Sonar to pick up.
Sonar is only going to look for one file so we put the file in target folder of the root of the
project when running a top-down build. session.executionRootDirectory points there if
we run Maven from the top level folder of the project.
If you don't do it this way, you have to define an absolute path to a fixed location
on the server or you have to put a relative path in every child module defining where JaCoCo is
to place its output file. The last solution is error prone so the solution shown here or the use
of a fixed location is recommended. -->
    <jacoco.out.path>${session.executionRootDirectory}/target</jacoco.out.path>
    <jacoco.out.file>jacoco.exec</jacoco.out.file>
    <!-- Location of the JaCoCo IT output file for use on Jenkins. See jacoco.out.path. NOTE: Can't use
    ${session.executionRootDirectory} here because of http://jira.codehaus.org/browse/SONAR-3427.
    env.WORKSPACE is set by Jenkins, which is really the only time sonar:sonar is going to be run in
    most cases. -->
    <sonar.jacoco.itReportPath>${env.WORKSPACE}/target/${jacoco.out.file}</sonar.jacoco.itReportPath>
  </properties>


  <build>
    <plugins>

      <!-- Compiles java binaries -->
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>${version.plugin.compiler}</version>
        <configuration>
          <source>${project.java.source}</source>
          <target>${project.java.target}</target>
          <debug>true</debug>
        </configuration>
      </plugin>

      <!-- Runs only unit tests files *Test -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>${version.plugin.surefire}</version>
        <configuration>
          <!-- Adds the line argument to dump jacoco file where expected -->
          <argLine>${jacoco.agent.arg}</argLine>
        </configuration>
      </plugin>

      <!-- Runs integration tests files *IT -->
      <plugin>
        <artifactId>maven-failsafe-plugin</artifactId>
        <version>${version.plugin.failsafe}</version>
        <executions>
          <execution>
            <goals>
              <goal>integration-test</goal>
              <goal>verify</goal>
            </goals>
            <configuration>
              <!-- Adds the line argument to dump jacoco file where expected -->
              <argLine>${jacoco.agent.arg}</argLine>
            </configuration>
          </execution>
        </executions>
      </plugin>


      <!-- Collects file coverage for all run tests -->
      <plugin>
        <groupId>org.jacoco</groupId>
        <artifactId>jacoco-maven-plugin</artifactId>
        <version>${version.plugin.jacoco}</version>
        <executions>
          <execution>
            <id>prepare-agent</id>
            <goals>
              <goal>prepare-agent</goal>
            </goals>
            <configuration>
              <destFile>${jacoco.out.path}/${jacoco.out.file}</destFile>
              <propertyName>jacoco.agent.arg</propertyName>
            </configuration>
          </execution>
        </executions>
      </plugin>

      <!-- Enables git repo data to be included in build process -->
      <plugin>
        <groupId>ru.concerteza.buildnumber</groupId>
        <artifactId>maven-jgit-buildnumber-plugin</artifactId>
        <version>${version.plugin.jgit-buildnumber}</version>
        <executions>
          <execution>
            <id>git-buildnumber</id>
            <goals>
              <goal>extract-buildnumber</goal>
            </goals>
            <phase>prepare-package</phase>
          </execution>
        </executions>
      </plugin>


      <!-- Generates build version number and other variables to be included on manifest -->
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>buildnumber-maven-plugin</artifactId>
        <version>${version.plugin.buildnumber}</version>
        <executions>
          <execution>
            <phase>validate</phase>
            <goals>
              <goal>create</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <buildNumberPropertiesFileLocation>${basedir}/src/main/resources/buildNumber.properties
          </buildNumberPropertiesFileLocation>
          <!-- Don't validate uncommited changes -->
          <doCheck>false</doCheck>
          <!-- Don't validate un pushed changes -->
          <doUpdate>false</doUpdate>

          <!-- Format of the generated buildNumber combining the declared items -->
          <format>{0}-build_{1,number}-{2,date,yyyyMMdd_HHmmss}</format>
          <items>
            <item>${project.version}</item>
            <item>buildNumber</item>
            <item>timestamp</item>
          </items>
        </configuration>
      </plugin>

      <!-- Jar packager -->
      <plugin>
        <artifactId>maven-jar-plugin</artifactId>
        <version>${version.plugin.jar}</version>
        <configuration>
          <archive>
            <manifest>
              <addClasspath>true</addClasspath>
            </manifest>
            <manifestEntries>
              <Build-JVM>${java.vm.name} - ${java.vm.vendor}</Build-JVM>
              <Build-OS>${os.name} - Version: ${os.version}</Build-OS>
              <Build-Number>${buildNumber}</Build-Number>

              <Application-GroupId>${project.groupId}</Application-GroupId>
              <Application-ArtifactId>${project.artifactId}</Application-ArtifactId>
              <Application-Version>${project.version}</Application-Version>

              <Git-Revision>${git.revision}</Git-Revision>
              <Git-Branch>${git.branch}</Git-Branch>
              <Git-Tag>${git.tag}</Git-Tag>
              <Git-Commits-Count>${git.commitsCount}</Git-Commits-Count>
            </manifestEntries>
          </archive>
        </configuration>
      </plugin>

      <!-- Attach source jars-->
      <plugin>
        <artifactId>maven-source-plugin</artifactId>
        <version>${version.plugin.source}</version>
        <executions>
          <execution>
            <id>attach-source</id>
            <phase>compile</phase>
            <goals>
              <goal>jar-no-fork</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

      <!-- Attach javadocs jar -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-javadoc-plugin</artifactId>
        <version>${version.plugin.javadoc}</version>
        <executions>
          <execution>
            <id>attach-javadocs</id>
            <goals>
              <goal>jar</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

    </plugins>

    <!-- Suggested dependencies (not for all projects) -->
    <pluginManagement>
      <plugins>

        <!-- Generates Queryable types for querydsl -->
        <plugin>
          <groupId>com.mysema.maven</groupId>
          <artifactId>apt-maven-plugin</artifactId>
          <version>${version.plugin.querydsl}</version>
          <executions>
            <execution>
              <goals>
                <goal>process</goal>
              </goals>
              <configuration>
                <outputDirectory>target/generated-sources/java</outputDirectory>
                <processor>com.querydsl.apt.jpa.JPAAnnotationProcessor</processor>
              </configuration>
            </execution>
          </executions>
        </plugin>

      </plugins>
    </pluginManagement>
  </build>

  <dependencyManagement>
    <dependencies>

      <!-- Represent uncertainty for quantities -->
      <dependency>
        <groupId>ar.com.kfgodel</groupId>
        <artifactId>nary</artifactId>
        <version>${version.nary}</version>
      </dependency>

      <!-- Spec for testing -->
      <dependency>
        <groupId>ar.com.dgarcia</groupId>
        <artifactId>java-spec</artifactId>
        <version>${version.javaspec}</version>
        <scope>test</scope>
      </dependency>

      <!-- Slf4j adapters -->
      <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>jcl-over-slf4j</artifactId>
        <version>${version.slf4j}</version>
      </dependency>
      <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>log4j-over-slf4j</artifactId>
        <version>${version.slf4j}</version>
      </dependency>

      <!-- programmatic dsl for queries -->
      <dependency>
        <groupId>com.querydsl</groupId>
        <artifactId>querydsl-apt</artifactId>
        <version>${version.querydsl}</version>
        <scope>provided</scope>
      </dependency>
      <dependency>
        <groupId>com.querydsl</groupId>
        <artifactId>querydsl-jpa</artifactId>
        <version>${version.querydsl}</version>
      </dependency>

    </dependencies>
  </dependencyManagement>

  <dependencies>

    <!--  Some common clases and utility methods -->
    <dependency>
      <groupId>com.google.guava</groupId>
      <artifactId>guava</artifactId>
      <version>${version.guava}</version>
    </dependency>

    <!-- Logging -->
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-api</artifactId>
      <version>${version.slf4j}</version>
    </dependency>
    <dependency>
      <groupId>ch.qos.logback</groupId>
      <artifactId>logback-core</artifactId>
      <version>${version.logback}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>ch.qos.logback</groupId>
      <artifactId>logback-classic</artifactId>
      <version>${version.logback}</version>
      <scope>test</scope>
    </dependency>

    <!-- Testing -->
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>${version.junit}</version>
      <scope>test</scope>
    </dependency>

    <!-- Nice assertions -->


    <dependency>
      <groupId>org.assertj</groupId>
      <artifactId>assertj-core</artifactId>
      <version>${version.assertj}</version>
      <scope>test</scope>
    </dependency>

    <!-- Mock for testing -->
    <dependency>
      <groupId>org.mockito</groupId>
      <artifactId>mockito-core</artifactId>
      <version>${version.mockito}</version>
      <scope>test</scope>
    </dependency>

  </dependencies>

  <developers>
    <developer>
      <id>dlgarcia</id>
      <name>Dario L Garcia</name>
      <email>dario.garcia@10pines.com</email>
      <organization>10Pines SRL</organization>
      <organizationUrl>https://www.10pines.com/</organizationUrl>
      <roles>
        <role>architect</role>
        <role>developer</role>
      </roles>
    </developer>
  </developers>

</project>
