<?xml version="1.0" encoding="UTF-8"?>
<!--
  ~ Copyright (c) 2023 Sebastien Vermeille and contributors.
  ~
  ~ Use of this source code is governed by an MIT
  ~ license that can be found in the LICENSE file or at
  ~ https://opensource.org/licenses/MIT.
  -->

<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>dev.cookiecode</groupId>
  <artifactId>rika2mqtt-parent</artifactId>
  <version>1.1.0</version>
  <name>rika2mqtt</name>
  <description>Bridge to control a Rka firenet stove through MQTT</description>
  <packaging>pom</packaging>

  <properties>
    <java.sdk.version>20</java.sdk.version>
    <source.encoding>UTF-8</source.encoding>

    <!-- dependencies version-->
    <lombok.version>1.18.28</lombok.version>
    <flogger.version>0.7.4</flogger.version>
    <hibernate.validator.version>8.0.1.Final</hibernate.validator.version>

    <!-- test dependencies version -->
    <testcontainers.version>1.18.3</testcontainers.version>

    <!--plugins version -->
    <jacoco.maven.plugin.version>0.8.10</jacoco.maven.plugin.version>
    <sonar.maven.plugin.version>3.9.1.2184</sonar.maven.plugin.version>
    <maven.gpg.plugin.version>3.1.0</maven.gpg.plugin.version>

    <!-- sonar analysis -->
    <sonar.organization>sebastienvermeille</sonar.organization>
    <sonar.host.url>https://sonarcloud.io</sonar.host.url>
    <sonar.language>java</sonar.language>
    <project.sonar.root.projectKey>sebastienvermeille_rika2mqtt</project.sonar.root.projectKey>
    <sonar.projectKey>${project.sonar.root.projectKey}</sonar.projectKey>
    <sonar.sources>src/main/java</sonar.sources>
    <sonar.tests>src/test/java</sonar.tests>
    <sonar.links.homepage>https://cookiecode.dev/oss_projects/rika2mqtt</sonar.links.homepage>
    <sonar.links.scm>https://github.com/sebastienvermeille/rika2mqtt</sonar.links.scm>
  </properties>

  <parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>3.1.2</version>
    <relativePath/> <!-- lookup parent from repository -->
  </parent>

  <modules>
    <module>rika-firenet</module>
    <module>bridge</module>
    <module>mqtt</module>
  </modules>

  <dependencies>
    <!-- dependencies shared with all modules -->
    <dependency>
      <artifactId>lombok</artifactId>
      <groupId>org.projectlombok</groupId>
      <optional>true</optional>
      <version>${lombok.version}</version>
    </dependency>
    <dependency>
      <groupId>com.google.flogger</groupId>
      <artifactId>flogger</artifactId>
      <version>${flogger.version}</version>
    </dependency>
    <dependency>
      <artifactId>flogger-slf4j-backend</artifactId>
      <groupId>com.google.flogger</groupId>
      <scope>runtime</scope>
      <version>${flogger.version}</version>
    </dependency>
    <dependency>
      <groupId>org.hibernate.validator</groupId>
      <artifactId>hibernate-validator</artifactId>
      <version>${hibernate.validator.version}</version>
    </dependency>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-quartz</artifactId>
    </dependency>
    <dependency>
      <groupId>com.google.guava</groupId>
      <artifactId>guava</artifactId>
      <version>23.0</version><!--    used for @VisibleForTesting (see if we really need it)-->
    </dependency>
    <!-- test dependencies shared with all modules -->
    <dependency>
      <artifactId>junit-jupiter</artifactId>
      <groupId>org.junit.jupiter</groupId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <artifactId>junit-jupiter-engine</artifactId>
      <groupId>org.junit.jupiter</groupId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.mockito</groupId>
      <artifactId>mockito-junit-jupiter</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.awaitility</groupId>
      <artifactId>awaitility</artifactId>
      <version>3.0.0</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-test</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.testcontainers</groupId>
      <artifactId>junit-jupiter</artifactId>
      <version>${testcontainers.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <artifactId>testcontainers</artifactId>
      <groupId>org.testcontainers</groupId>
      <version>${testcontainers.version}</version>
      <scope>test</scope>
    </dependency>

  </dependencies>

  <profiles>
    <profile>
      <id>release-sign-artifacts</id>
      <activation>
        <property>
          <name>performRelease</name>
          <value>true</value>
        </property>
      </activation>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-gpg-plugin</artifactId>
            <version>${maven.gpg.plugin.version}</version>
            <executions>
              <execution>
                <id>sign-artifacts</id>
                <phase>verify</phase>
                <goals>
                  <goal>sign</goal>
                </goals>
                <configuration>
                  <!-- This is required to make sure the plugin does not stop asking for -->
                  <!-- user input on the passphrase -->
                  <gpgArguments>
                    <arg>--pinentry-mode</arg>
                    <arg>loopback</arg>
                  </gpgArguments>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>

  <build>
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>org.springframework.boot</groupId>
          <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
        <plugin>
          <groupId>org.sonarsource.scanner.maven</groupId>
          <artifactId>sonar-maven-plugin</artifactId>
          <version>${sonar.maven.plugin.version}</version>
        </plugin>

        <plugin>
          <groupId>org.sonatype.plugins</groupId>
          <artifactId>nexus-staging-maven-plugin</artifactId>
          <version>1.6.13</version>
          <extensions>true</extensions>
          <configuration>
            <serverId>ossrh</serverId>
            <nexusUrl>https://s01.oss.sonatype.org/</nexusUrl>
            <autoReleaseAfterClose>true</autoReleaseAfterClose>
          </configuration>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-javadoc-plugin</artifactId>
          <version>3.5.0</version>
          <configuration>
            <additionalOptions>-Xdoclint:none</additionalOptions>
            <failOnError>false</failOnError>
          </configuration>
          <executions>
            <execution>
              <id>attach-javadocs</id>
              <goals>
                <goal>jar</goal>
              </goals>
            </execution>
          </executions>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-source-plugin</artifactId>
          <version>3.3.0</version>
          <executions>
            <execution>
              <id>attach-sources</id>
              <goals>
                <goal>jar-no-fork</goal>
              </goals>
            </execution>
          </executions>
        </plugin>
        <plugin>
          <groupId>org.jacoco</groupId>
          <artifactId>jacoco-maven-plugin</artifactId>
          <version>${jacoco.maven.plugin.version}</version>
          <configuration>
            <formats>
              <format>HTML</format>
              <format>XML</format>
            </formats>
          </configuration>
          <executions>
            <execution>
              <id>agent</id>
              <goals>
                <goal>prepare-agent</goal>
              </goals>
            </execution>
            <execution>
              <id>jacoco-report</id>
              <phase>test</phase>
              <goals>
                <goal>report</goal>
              </goals>
            </execution>
          </executions>
        </plugin>
      </plugins>
    </pluginManagement>

    <plugins>
      <plugin>
        <groupId>org.jacoco</groupId>
        <artifactId>jacoco-maven-plugin</artifactId>
      </plugin>
      <plugin>
        <groupId>org.sonarsource.scanner.maven</groupId>
        <artifactId>sonar-maven-plugin</artifactId>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-source-plugin</artifactId>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-javadoc-plugin</artifactId>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-gpg-plugin</artifactId>
        <version>${maven.gpg.plugin.version}</version>
      </plugin>
      <plugin>
        <groupId>org.sonatype.plugins</groupId>
        <artifactId>nexus-staging-maven-plugin</artifactId>
      </plugin>
    </plugins>
  </build>

  <repositories>
    <repository>
      <id>central</id>
      <url>https://repo1.maven.org/maven2</url>
    </repository>
  </repositories>
  <pluginRepositories>
    <pluginRepository>
      <id>mavencentral</id>
      <name>Maven central</name>
      <url>https://repo.maven.apache.org/maven2</url>
    </pluginRepository>
  </pluginRepositories>

  <distributionManagement>
    <snapshotRepository>
      <id>ossrh</id>
      <url>https://s01.oss.sonatype.org/content/repositories/snapshots</url>
    </snapshotRepository>
  </distributionManagement>
</project>
