<?xml version="1.0" encoding="UTF-8"?>
<!--
  ~
  ~     Copyright [ 2020 - 2023 ] [Matthew Buckton]
  ~
  ~     Licensed under the Apache License, Version 2.0 (the "License");
  ~     you may not use this file except in compliance with the License.
  ~     You may obtain a copy of the License at
  ~
  ~         http://www.apache.org/licenses/LICENSE-2.0
  ~
  ~     Unless required by applicable law or agreed to in writing, software
  ~     distributed under the License is distributed on an "AS IS" BASIS,
  ~     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  ~     See the License for the specific language governing permissions and
  ~     limitations under the License.
  -->

<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xmlns="http://maven.apache.org/POM/4.0.0"
         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.mapsmessaging</groupId>
  <artifactId>Device_Library</artifactId>
  <version>1.0.5</version>
  <packaging>jar</packaging>

  <name>Device Integration</name>
  <description>Provides a plugable Device integration and access</description>
  <url>http://www.mapsmessaging.io</url>

  <developers>
    <developer>
      <id>mbuckton</id>
      <name>Matthew Buckton</name>
      <organization>Maps Messaging</organization>
      <organizationUrl>http://mapsmessaging.io/</organizationUrl>
      <roles>
        <role>founder</role>
      </roles>
      <timezone>Australia/Sydney</timezone>
    </developer>
  </developers>

  <licenses>
    <license>
      <distribution>repo</distribution>
      <name>Mozilla Public License Version 2.0</name>
      <url>https://www.mozilla.org/en-US/MPL/2.0/</url>
    </license>
    <license>
      <distribution>repo</distribution>
      <name>CommonsClause</name>
      <url>https://commonsclause.com/</url>
    </license>
  </licenses>

  <scm>
    <url>https://github.com/Maps-Messaging/device_integration</url>
  </scm>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

    <maven.compiler.source>11</maven.compiler.source>
    <maven.compiler.target>11</maven.compiler.target>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <gpg.keyname>matthew.buckton@mapsmessaging.io</gpg.keyname>

    <runSuite>**/*Suite.class</runSuite>
    <!-- Below property indicates the pattern of the test suite -->
    <sonar.c.file.suffixes>-</sonar.c.file.suffixes>
    <sonar.coverage.jacoco.xmlReportPaths>target/site/jacoco</sonar.coverage.jacoco.xmlReportPaths>

    <!-- Sonar-JaCoCo properties -->
    <sonar.cpp.file.suffixes>-</sonar.cpp.file.suffixes>
    <sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis>
    <sonar.java.coveragePlugin>jacoco</sonar.java.coveragePlugin>

    <sonar.language>java</sonar.language>
    <sonar.objc.file.suffixes>-</sonar.objc.file.suffixes>

    <sonar.host.url>https://sonarcloud.io</sonar.host.url>
    <sonar.organization>maps-messaging</sonar.organization>
    <sonar.projectKey>deviceLibrary</sonar.projectKey>

    <sonar.sources>src/main</sonar.sources>
    <pi4j.version>2.3.0</pi4j.version>
    <sonar.test.exclusions>
      **/*Test.*,**/*IT.*, **.*JMH.*
    </sonar.test.exclusions>
  </properties>

  <distributionManagement>
    <snapshotRepository>
      <id>mapsmessaging.io</id>
      <url>https://s01.oss.sonatype.org/content/repositories/snapshots</url>
    </snapshotRepository>
    <repository>
      <id>mapsmessaging.io</id>
      <url>https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/</url>
    </repository>
  </distributionManagement>

  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-gpg-plugin</artifactId>
        <version>3.0.1</version>
        <executions>
          <execution>
            <id>sign-artifacts</id>
            <phase>verify</phase>
            <goals>
              <goal>sign</goal>
            </goals>
            <configuration>
              <keyname>${gpg.keyname}</keyname>
              <passphraseServerId>${gpg.keyname}</passphraseServerId>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.sonatype.plugins</groupId>
        <artifactId>nexus-staging-maven-plugin</artifactId>
        <version>1.6.8</version>
        <extensions>true</extensions>
        <configuration>
          <serverId>mapsmessaging.io</serverId>
          <nexusUrl>https://s01.oss.sonatype.org/</nexusUrl>
          <autoReleaseAfterClose>true</autoReleaseAfterClose>
        </configuration>
      </plugin>

      <!-- Allow JDKs greater than 1.8 to be used by maven -->
      <!-- build the source jar as well -->
      <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-no-fork</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

      <!-- Setup code coverage by jacoco for our tests -->
      <plugin>
        <artifactId>jacoco-maven-plugin</artifactId>
        <configuration>
          <excludes>
            <!-- test code, lets not track the testing -->
            <exclude>**/*Test.*</exclude>
            <exclude>**/Test*.*</exclude>
          </excludes>
        </configuration>
        <executions>
          <execution>
            <goals>
              <goal>prepare-agent</goal>
            </goals>
          </execution>
          <!-- attached to Maven test phase -->
          <execution>
            <goals>
              <goal>report</goal>
            </goals>
            <id>report</id>
            <phase>test</phase>
          </execution>
        </executions>
        <groupId>org.jacoco</groupId>
        <version>0.8.8</version>
      </plugin>

      <!-- Setup the JUnit tests runner -->
      <plugin>
        <artifactId>maven-surefire-plugin</artifactId>
        <configuration>
          <argLine>@{argLine}</argLine>
          <includes>
            <include>**/*Test.java</include>
            <include>**/Test*.java</include>
            <include>**/*IT.java</include>
          </includes>
        </configuration>
        <groupId>org.apache.maven.plugins</groupId>
        <version>2.22.2</version>
      </plugin>

      <!-- JavaDoc -->
      <plugin>
        <artifactId>maven-javadoc-plugin</artifactId>
        <configuration>
          <charset>UTF-8</charset>
          <encoding>UTF-8</encoding>
          <javadocExecutable>${java.home}/bin/javadoc</javadocExecutable>
          <reportOutputDirectory>${project.build.directory}/site/docs</reportOutputDirectory>
          <show>public</show>
          <sourceFileExcludes>
            <sourceFileExclude>**/*Test.java</sourceFileExclude>
            <sourceFileExclude>**/Test*.java</sourceFileExclude>
            <sourceFileExclude>**/*IT.java</sourceFileExclude>
          </sourceFileExcludes>
        </configuration>
        <executions>
          <execution>
            <goals>
              <goal>jar</goal>
            </goals>
            <id>attach-javadocs</id>
          </execution>
        </executions>
        <groupId>org.apache.maven.plugins</groupId>
        <version>3.5.0</version>
      </plugin>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>build-helper-maven-plugin</artifactId>
        <version>3.3.0</version>
        <executions>
          <execution>
            <id>add-test-sources</id>
            <phase>generate-sources</phase>
            <goals>
              <goal>add-test-source</goal>
            </goals>
            <configuration>
              <sources>
                <source>${basedir}/target/generated-test-sources</source>
              </sources>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.11.0</version>
        <configuration>
          <source>11</source>
          <target>11</target>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>
        <version>3.2.0</version>
        <configuration>
          <excludes>
            <!-- Exclude example source code from the build jar -->
            <exclude>examples/**</exclude>
          </excludes>
        </configuration>
      </plugin>
    </plugins>
  </build>

  <profiles>
    <!-- Profile for the main project (excluding example dependencies) -->
    <profile>
      <id>main</id>
      <activation>
        <activeByDefault>true</activeByDefault>
      </activation>
      <dependencies>
        <dependency>
          <groupId>io.mapsmessaging</groupId>
          <artifactId>Simple_Logging</artifactId>
          <version>2.0.9</version>
        </dependency>

        <dependency>
          <groupId>io.mapsmessaging</groupId>
          <artifactId>Schemas</artifactId>
          <version>2.1.2</version>
        </dependency>

        <dependency>
          <groupId>com.pi4j</groupId>
          <artifactId>pi4j-core</artifactId>
          <version>${pi4j.version}</version>
        </dependency>

        <dependency>
          <groupId>com.pi4j</groupId>
          <artifactId>pi4j-plugin-raspberrypi</artifactId>
          <version>${pi4j.version}</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/com.pi4j/pi4j-plugin-linuxfs -->
        <dependency>
          <groupId>com.pi4j</groupId>
          <artifactId>pi4j-plugin-linuxfs</artifactId>
          <version>${pi4j.version}</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/com.pi4j/pi4j-library-linuxfs -->
        <dependency>
          <groupId>com.pi4j</groupId>
          <artifactId>pi4j-library-linuxfs</artifactId>
          <version>${pi4j.version}</version>
        </dependency>

        <dependency>
          <groupId>com.pi4j</groupId>
          <artifactId>pi4j-plugin-pigpio</artifactId>
          <version>${pi4j.version}</version>
        </dependency>

        <dependency>
          <groupId>org.slf4j</groupId>
          <artifactId>slf4j-simple</artifactId>
          <version>2.0.7</version>
        </dependency>

        <dependency>
          <groupId>com.fasterxml.jackson.core</groupId>
          <artifactId>jackson-databind</artifactId>
          <version>2.13.0</version>  <!-- use the latest version available -->
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.json/json -->
        <dependency>
          <groupId>org.json</groupId>
          <artifactId>json</artifactId>
          <version>20230227</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.everit.json/org.everit.json.schema -->
        <dependency>
          <groupId>org.everit.json</groupId>
          <artifactId>org.everit.json.schema</artifactId>
          <version>1.5.1</version>
        </dependency>

        <!-- Junit5 -->
        <dependency>
          <artifactId>junit-jupiter-engine</artifactId>
          <groupId>org.junit.jupiter</groupId>
          <scope>test</scope>
          <version>5.9.2</version>
        </dependency>


      </dependencies>
    </profile>

    <!-- Profile for the examples (with additional dependencies) -->
    <profile>
      <id>examples</id>
      <dependencies>
        <dependency>
          <groupId>io.javalin</groupId>
          <artifactId>javalin</artifactId>
          <version>5.6.0</version>
        </dependency>
      </dependencies>
    </profile>
  </profiles>

</project>
