<?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.7</version>
  <packaging>pom</packaging>

  <parent>
    <groupId>info.kfgodel</groupId>
    <artifactId>root-pom</artifactId>
    <version>0.2.2</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.22.2</version.plugin.failsafe>
    <version.plugin.surefire>2.22.2</version.plugin.surefire>
    <version.plugin.jacoco>0.8.4</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>28.1-jre</version.guava>
    <version.mockito>3.1.0</version.mockito>
    <version.assertj>3.11.1</version.assertj>

    <version.jspek>1.0.0</version.jspek>
    <version.nary>2.0.7</version.nary>
  </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>@{argLine}</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>@{argLine}</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-coverage-agent</id>
            <goals>
              <goal>prepare-agent</goal>
            </goals>
          </execution>
          <execution>
            <id>generate-coverage-report</id>
            <phase>post-integration-test</phase>
            <goals>
              <goal>report</goal>
            </goals>
          </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>read-get-data</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 uncommitted 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 javadoc jar -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-javadoc-plugin</artifactId>
        <version>${version.plugin.javadoc}</version>
        <executions>
          <execution>
            <id>attach-javadoc</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>info.kfgodel</groupId>
        <artifactId>nary</artifactId>
        <version>${version.nary}</version>
      </dependency>

      <!-- Spec for testing -->
      <dependency>
        <groupId>info.kfgodel</groupId>
        <artifactId>jspek</artifactId>
        <version>${version.jspek}</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 classes 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>
