<?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>io.github.aafc-bicoe</groupId>
    <artifactId>dina-base-parent</artifactId>
    <version>0.61</version>
  </parent>

  <artifactId>dina-base-api</artifactId>
  <name>dina-base-api</name>
  <description>Base DINA API package for Java built on SpringBoot and Crnk</description>
  <url>https://github.com/AAFC-BICoE/dina-base-api</url>

  <properties>
    <jcip-annotations.version>1.0</jcip-annotations.version>
    <local-javax-jaxb.version>2.3.0.1</local-javax-jaxb.version>
    <javax.activation.version>1.2.0</javax.activation.version>
    <rsql-jpa.version>2.0.2</rsql-jpa.version>
    <commons.beanutils.version>1.9.4</commons.beanutils.version>
    <jacoco-maven-plugin.version>0.8.5</jacoco-maven-plugin.version>
    <javers.version>6.1.1</javers.version>
    <mybatis.version>2.1.4</mybatis.version>
  </properties>

  <dependencies>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-security</artifactId>
    </dependency>
    <!-- Used by Spotbug annotation -->
    <dependency>
      <groupId>net.jcip</groupId>
      <artifactId>jcip-annotations</artifactId>
      <version>${jcip-annotations.version}</version>
      <scope>provided</scope>
    </dependency>
    <!-- Required for Java >= 9 -->
    <dependency>
      <groupId>com.sun.xml.bind</groupId>
      <artifactId>jaxb-core</artifactId>
      <version>${local-javax-jaxb.version}</version>
    </dependency>
    <dependency>
      <groupId>com.sun.xml.bind</groupId>
      <artifactId>jaxb-impl</artifactId>
      <version>${local-javax-jaxb.version}</version>
    </dependency>
    <dependency>
      <groupId>javax.activation</groupId>
      <artifactId>javax.activation-api</artifactId>
      <version>${javax.activation.version}</version>
    </dependency>
    <!-- crnk -->
    <dependency>
      <groupId>io.crnk</groupId>
      <artifactId>crnk-data-jpa</artifactId>
      <version>${crnk.version}</version>
    </dependency>
    <dependency>
      <groupId>io.crnk</groupId>
      <artifactId>crnk-operations</artifactId>
      <version>${crnk.version}</version>
    </dependency>
    <dependency>
      <groupId>io.crnk</groupId>
      <artifactId>crnk-client</artifactId>
      <version>${crnk.version}</version>
      <scope>test</scope>
    </dependency>
    <!-- RSQL -->
    <dependency>
      <groupId>com.github.tennaito</groupId>
      <artifactId>rsql-jpa</artifactId>
      <version>${rsql-jpa.version}</version>
    </dependency>
    <!-- JaVers auditing -->
    <dependency>
      <groupId>org.javers</groupId>
      <artifactId>javers-spring-boot-starter-sql</artifactId>
      <version>${javers.version}</version>
    </dependency>
    <!--Util-->
    <dependency>
      <groupId>com.fasterxml.jackson.datatype</groupId>
      <artifactId>jackson-datatype-jsr310</artifactId>
    </dependency>
    <dependency>
      <groupId>commons-beanutils</groupId>
      <artifactId>commons-beanutils</artifactId>
      <version>${commons.beanutils.version}</version>
    </dependency>
    <dependency>
      <groupId>javax.validation</groupId>
      <artifactId>validation-api</artifactId>
    </dependency>
    <dependency>
      <groupId>io.github.aafc-bicoe</groupId>
      <artifactId>dina-test-support</artifactId>
      <version>0.61</version>
      <scope>test</scope>
    </dependency>
    <!-- Spring mybatis -->
    <dependency>
      <groupId>org.mybatis.spring.boot</groupId>
      <artifactId>mybatis-spring-boot-starter</artifactId>
      <version>${mybatis.version}</version>
    </dependency>
    <!-- postgresql for testing in the postgresql docker conatiner -->
    <dependency>
      <groupId>org.postgresql</groupId>
      <artifactId>postgresql</artifactId>
      <scope>test</scope>
    </dependency>
  </dependencies>
  <build>
    <plugins>

      <plugin>
        <groupId>org.projectlombok</groupId>
        <artifactId>lombok-maven-plugin</artifactId>
        <configuration>
          <sourceDirectory>src/main/java</sourceDirectory>
          <addOutputDirectory>false</addOutputDirectory>
        </configuration>
        <executions>
          <execution>
            <phase>generate-sources</phase>
            <goals>
              <goal>delombok</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-javadoc-plugin</artifactId>
        <configuration>
          <sourcepath>target/generated-sources/delombok</sourcepath>
        </configuration>
      </plugin>

      <plugin>
        <groupId>org.jacoco</groupId>
        <artifactId>jacoco-maven-plugin</artifactId>
        <version>${jacoco-maven-plugin.version}</version>
        <executions>
          <execution>
            <id>pre-unit-test</id>
            <goals>
              <goal>prepare-agent</goal>
            </goals>
          </execution>
          <execution>
            <id>pre-integration-test</id>
            <goals>
              <goal>prepare-agent-integration</goal>
            </goals>
          </execution>
          <execution>
            <id>post-unit-test</id>
            <goals>
              <goal>report</goal>
            </goals>
          </execution>
          <execution>
            <id>post-integration-test</id>
            <goals>
              <goal>report-integration</goal>
            </goals>
          </execution>
          <!-- Merge jacoco.exec from unit and integrations tests -->
          <execution>
            <id>merge-results</id>
            <phase>verify</phase>
            <goals>
              <goal>merge</goal>
            </goals>
            <configuration>
              <fileSets>
                <fileSet>
                  <directory>${project.build.directory}</directory>
                  <includes>
                    <include>*.exec</include>
                  </includes>
                  <excludes>
                    <exclude>aggregate.exec</exclude>
                  </excludes>
                </fileSet>
              </fileSets>
              <destFile>${project.build.directory}/aggregate.exec</destFile>
            </configuration>
          </execution>
          <!-- Create the aggregated report from aggregate.exec -->
          <execution>
            <id>aggregate-report</id>
            <phase>verify</phase>
            <goals>
              <goal>report</goal>
            </goals>
            <configuration>
              <dataFile>${project.build.directory}/aggregate.exec</dataFile>
              <outputDirectory>${project.reporting.outputDirectory}/jacoco-aggregate</outputDirectory>
            </configuration>
          </execution>
          <execution>
            <id>default-cli</id>
            <phase>none</phase>
            <goals>
              <goal>check</goal>
            </goals>
            <configuration>
              <dataFile>${project.build.directory}/aggregate.exec</dataFile>
              <rules>
                <rule>
                  <element>BUNDLE</element>
                  <limits>
                    <limit>
                      <counter>INSTRUCTION</counter>
                      <value>COVEREDRATIO</value>
                      <minimum>0.8</minimum>
                    </limit>
                  </limits>
                </rule>
              </rules>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
  <licenses>
    <license>
      <name>MIT License</name>
      <url>https://opensource.org/licenses/mit-license</url>
      <distribution>repo</distribution>
    </license>
  </licenses>
</project>
