<?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>

  <groupId>io.jexxa</groupId>
  <artifactId>Jexxa</artifactId>
  <version>1.4</version>

  <!-- Project Information -->
  <name>Jexxa</name>
  <url>https://github.com/repplix/Jexxa</url>
  <description>Jexxa - A Ports and Adapters Framework for Java</description>
  <licenses>
    <license>
      <name>The Apache Software License, Version 2.0</name>
      <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
      <distribution>repo</distribution>
    </license>
  </licenses>
  <developers>
    <developer>
      <name>Michael Repplinger</name>
    </developer>
  </developers>

  <scm>
    <connection>scm:git:https://github.com/repplix/Jexxa.git</connection>
    <url>http://github.com/repplix/Jexxa</url>
    <developerConnection>scm:git:https://github.com/repplix/Jexxa.git</developerConnection>
    <tag>Jexxa-1.4</tag>
  </scm>
  
  <properties>
    <!-- version of compile dependencies -->
    <classgraph.version>4.8.75</classgraph.version>
    <commons.lang.version>2.6</commons.lang.version>
    <gson.version>2.8.6</gson.version>
    <javalin.version>3.8.0</javalin.version>
    <javax.jms.version>2.0.1</javax.jms.version>
    <jackson.databind.version>2.10.1</jackson.databind.version>

    <!-- version of test dependencies -->
    <activemq.client.version>5.15.12</activemq.client.version>
    <postgres.version>42.2.12</postgres.version>
    <unirest.java.version>3.7.02</unirest.java.version>
    <junit.platform.launcher.version>1.6.2</junit.platform.launcher.version>
    <junit.jupiter.engine.version>5.6.2</junit.jupiter.engine.version>
    <junit.jupiter.params.version>5.6.2</junit.jupiter.params.version>
    <slf4j.simple.version>1.7.28</slf4j.simple.version>

    <!--version of  maven plugins  -->
    <gpg.plugin.version>1.6</gpg.plugin.version>

    <!-- target/compiler configuration  -->
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.release>11</maven.compiler.release>
    <maven.compiler.source>11</maven.compiler.source>
    <maven.compiler.target>11</maven.compiler.target>

    <!-- sonar configuration  -->
    <sonar.projectKey>repplix_Jexxa</sonar.projectKey>
    <sonar.organization>repplix</sonar.organization>
    <sonar.host.url>https://sonarcloud.io</sonar.host.url>
    <sonar.login>${sonar-login}</sonar.login>
    <sonar.coverage.jacoco.xmlReportPaths>target/site/jacoco-ut/jacoco.xml,target/site/jacoco-it/jacoco.xml </sonar.coverage.jacoco.xmlReportPaths>
    <argLine>-Xmx2048m -Xms1024m</argLine>

  </properties>

  <dependencies>
    <!-- dependencies for Jexxa core -->
    <dependency>
      <groupId>io.github.classgraph</groupId>
      <artifactId>classgraph</artifactId>
      <version>${classgraph.version}</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>com.google.code.gson</groupId>
      <artifactId>gson</artifactId>
      <version>${gson.version}</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>commons-lang</groupId>
      <artifactId>commons-lang</artifactId>
      <version>${commons.lang.version}</version>
      <scope>compile</scope>
    </dependency>
    
    <!-- dependencies for RESTulRPCAdapter -->
    <dependency>
      <groupId>io.javalin</groupId>
      <artifactId>javalin</artifactId>
      <version>${javalin.version}</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>com.fasterxml.jackson.core</groupId>
      <artifactId>jackson-databind</artifactId>
      <version>${jackson.databind.version}</version>
      <scope>compile</scope>
    </dependency>

    <!-- dependencies for JMSAdapter -->
    <dependency>
      <groupId>javax.jms</groupId>
      <artifactId>javax.jms-api</artifactId>
      <version>${javax.jms.version}</version>
      <scope>compile</scope>
     </dependency>

    <!-- dependencies for tests with ActiveMQ -->
    <dependency>
      <groupId>org.apache.activemq</groupId>
      <artifactId>activemq-client</artifactId>
      <version>${activemq.client.version}</version>
      <scope>test</scope>
    </dependency>

    <!-- dependencies for tests with JDBCAdapter -->
    <dependency>
      <groupId>org.postgresql</groupId>
      <artifactId>postgresql</artifactId>
      <version>${postgres.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>com.konghq</groupId>
      <artifactId>unirest-java</artifactId>
      <version>${unirest.java.version}</version>
      <scope>test</scope>
    </dependency>

    <!-- dependencies for tests -->
    <dependency>
      <groupId>org.junit.platform</groupId>
      <artifactId>junit-platform-launcher</artifactId>
      <version>${junit.platform.launcher.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.junit.jupiter</groupId>
      <artifactId>junit-jupiter-engine</artifactId>
      <version>${junit.jupiter.engine.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.junit.jupiter</groupId>
      <artifactId>junit-jupiter-params</artifactId>
      <version>${junit.jupiter.params.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-simple</artifactId>
      <version>${slf4j.simple.version}</version>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <build>
    <pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
      <plugins>
        <!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle -->
        <plugin>
          <artifactId>maven-clean-plugin</artifactId>
          <version>3.1.0</version>
        </plugin>
        <!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
        <plugin>
          <artifactId>maven-resources-plugin</artifactId>
          <version>3.0.2</version>
        </plugin>
        <plugin>
          <artifactId>maven-compiler-plugin</artifactId>
          <version>3.8.0</version>
        </plugin>
        <plugin>
          <artifactId>maven-failsafe-plugin</artifactId>
          <version>2.22.1</version>
        </plugin>
        <plugin>
          <artifactId>maven-surefire-plugin</artifactId>
          <version>2.22.1</version>
        </plugin>
        <plugin>
          <artifactId>maven-jar-plugin</artifactId>
          <version>3.0.2</version>
        </plugin>
        <plugin>
          <artifactId>maven-install-plugin</artifactId>
          <version>2.5.2</version>
        </plugin>
        <!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle -->
        <plugin>
          <artifactId>maven-site-plugin</artifactId>
          <version>3.7.1</version>
        </plugin>
        <plugin>
          <groupId>org.jacoco</groupId>
          <artifactId>jacoco-maven-plugin</artifactId>
          <version>0.8.5</version>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-gpg-plugin</artifactId>
          <version>${gpg.plugin.version}</version>
        </plugin>
        <plugin>
          <!-- explicitly define maven-deploy-plugin after other to force exec order -->
          <artifactId>maven-deploy-plugin</artifactId>
          <version>2.8.2</version>
          <executions>
            <execution>
              <id>deploy</id>
              <phase>deploy</phase>
              <goals><goal>deploy</goal></goals>
            </execution>
          </executions>
        </plugin>
      </plugins>
    </pluginManagement>

    <!-- Plugin specific configuration -->
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-failsafe-plugin</artifactId>
        <configuration>
          <!--suppress UnresolvedMavenProperty -->
          <!-- Property failsafeArgLine is set from failsafe plugin-->
          <argLine>${failsafeArgLine}</argLine>
        </configuration>
        <executions>
          <execution>
            <id>integration-tests</id>
            <goals>
              <goal>integration-test</goal>
              <goal>verify</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <artifactId>maven-surefire-plugin</artifactId>
        <configuration>
          <!--suppress UnresolvedMavenProperty -->
          <!-- Property surefireArgLine wird vom maven-surefire-plugin gesetzt-->
          <argLine>${surefireArgLine}</argLine>
        </configuration>
      </plugin>

      <plugin>
        <artifactId>maven-release-plugin</artifactId>
        <configuration>
          <releaseProfiles>sign-artifacts</releaseProfiles>
          <arguments>-Psign-artifacts</arguments>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-javadoc-plugin</artifactId>
        <version>3.2.0</version>
        <executions>
          <execution>
            <id>attach-javadocs</id>
            <goals>
              <goal>jar</goal>
              <goal>javadoc-no-fork</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-source-plugin</artifactId>
        <version>3.2.1</version>
        <executions>
          <execution>
            <id>attach-sources</id>
            <goals>
              <goal>jar</goal>
              <goal>jar-no-fork</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>


    <testResources>
      <testResource>
        <directory>${project.basedir}/src/test/resources</directory>
        <filtering>true</filtering>
      </testResource>
    </testResources>
    
  </build>

  <reporting>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-javadoc-plugin</artifactId>
        <version>3.2.0</version>
        <configuration>
          <show>public</show>
        </configuration>
      </plugin>
    </plugins>
  </reporting>
  
  <profiles>
    <profile>
      <id>jacoco</id>
      <activation>
        <activeByDefault>true</activeByDefault>
      </activation>
      <build>
        <plugins>
          <plugin>
            <groupId>org.jacoco</groupId>
            <artifactId>jacoco-maven-plugin</artifactId>
            <executions>
              <!--
                  Prepares the property pointing to the JaCoCo runtime agent which
                  is passed as VM argument when Maven the Surefire plugin is executed.
              -->
              <execution>
                <id>pre-unit-test</id>
                <goals>
                  <goal>prepare-agent</goal>
                </goals>
                <configuration>
                  <!-- Sets the path to the file which contains the execution data. -->
                  <destFile>${project.build.directory}/coverage-reports/jacoco-ut.exec</destFile>
                  <!--
                      Sets the name of the property containing the settings
                      for JaCoCo runtime agent.
                  -->
                  <propertyName>surefireArgLine</propertyName>
                </configuration>
              </execution>
              <!--
                  Ensures that the code coverage report for unit tests is created after
                  unit tests have been run.
              -->
              <execution>
                <id>post-unit-test</id>
                <phase>test</phase>
                <goals>
                  <goal>report</goal>
                </goals>
                <configuration>
                  <!-- Sets the path to the file which contains the execution data. -->
                  <dataFile>${project.build.directory}/coverage-reports/jacoco-ut.exec</dataFile>
                  <!-- Sets the output directory for the code coverage report. -->
                  <outputDirectory>${project.reporting.outputDirectory}/jacoco-ut</outputDirectory>
                </configuration>
              </execution>

              <execution>
                <id>pre-integration-test</id>
                <phase>pre-integration-test</phase>
                <goals>
                  <goal>prepare-agent</goal>
                </goals>
                <configuration>
                  <!-- Sets the path to the file which contains the execution data. -->
                  <destFile>${project.build.directory}/coverage-reports/jacoco-it.exec</destFile>
                  <!--
                      Sets the name of the property containing the settings
                      for JaCoCo runtime agent.
                  -->
                  <propertyName>failsafeArgLine</propertyName>
                </configuration>
              </execution>
              <!--
                  Ensures that the code coverage report for integration tests after
                  integration tests have been run.
              -->
              <execution>
                <id>post-integration-test</id>
                <phase>post-integration-test</phase>
                <goals>
                  <goal>report</goal>
                </goals>
                <configuration>
                  <!-- Sets the path to the file which contains the execution data. -->
                  <dataFile>${project.build.directory}/coverage-reports/jacoco-it.exec</dataFile>
                  <!-- Sets the output directory for the code coverage report. -->
                  <outputDirectory>${project.reporting.outputDirectory}/jacoco-it</outputDirectory>
                </configuration>
              </execution>
              <execution>
                <id>merge-results</id>
                <phase>verify</phase>
                <goals>
                  <goal>merge</goal>
                </goals>
                <configuration>
                  <fileSets>
                    <fileSet>
                      <directory>${project.build.directory}/coverage-reports</directory>
                      <includes>
                        <include>*.exec</include>
                      </includes>
                    </fileSet>
                  </fileSets>
                  <destFile>${project.build.directory}/coverage-reports/jacoco-aggregate.exec</destFile>
                </configuration>
              </execution>
              <execution>
                <id>post-merge-report</id>
                <phase>verify</phase>
                <goals>
                  <goal>report</goal>
                </goals>
                <configuration>
                  <dataFile>${project.build.directory}/coverage-reports/jacoco-aggregate.exec</dataFile>
                  <outputDirectory>${project.reporting.outputDirectory}/jacoco-aggregate</outputDirectory>
                </configuration>
              </execution>
            </executions>
          </plugin>

        </plugins>
      </build>
    </profile>

    <profile>
      <id>sign-artifacts</id>
      <activation>
        <property>
          <name>sign</name>
          <value>true</value>
        </property>
      </activation>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-gpg-plugin</artifactId>
            <version>${gpg.plugin.version}</version>
            <executions>
              <execution>
                <id>sign-artifacts</id>
                <phase>verify</phase>
                <goals>
                  <goal>sign</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>


  <distributionManagement>
    <snapshotRepository>
      <id>oss.sonatype.org</id>
      <name>Jexxa snapshot</name>
      <url>https://oss.sonatype.org/content/repositories/snapshots</url>
      <uniqueVersion>true</uniqueVersion>
    </snapshotRepository>
    <repository>
      <id>oss.sonatype.org</id>
      <name>Jexxa Maven Packages</name>
      <url>https://oss.sonatype.org/service/local/staging/deploy/maven2</url>
      <uniqueVersion>true</uniqueVersion>
    </repository>
  </distributionManagement>

</project>
