<?xml version="1.0"?>

<!--
  ~ Energy readers and parsers toolkit
  ~ Copyright (C) 2019-2023 Niels Basjes
  ~
  ~ This work is licensed under the Creative Commons
  ~ Attribution-NonCommercial-NoDerivatives 4.0 International License.
  ~
  ~ You may not use this file except in compliance with the License.
  ~ You may obtain a copy of the License at
  ~
  ~    https://creativecommons.org/licenses/by-nc-nd/4.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.
  -->

<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>nl.basjes.energy</groupId>
  <artifactId>energy-parent</artifactId>
  <version>0.0.2</version>

  <packaging>pom</packaging>

  <name>Energy : </name>
  <description>A library to read Modbus based energy systems.</description>

<!--  <prerequisites>-->
<!--    <maven>3.3</maven>-->
<!--  </prerequisites>-->

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

    <!-- In order for everything to work correctly we need at least this version of maven. -->
    <maven.minimal.version>3.5.2</maven.minimal.version>

    <log4j2.version>2.23.1</log4j2.version>

    <!-- https://github.com/steveohara/j2mod -->
    <j2mod.version>3.1.1</j2mod.version>
    <!-- ============================================== -->
    <!-- ================ UDF Versions ================ -->
    <!-- ============================================== -->
    <!-- Apache Nifi -->
    <nifi.version>1.27.0</nifi.version>

    <!-- ============================================== -->

    <checkstyle-plugin.version>3.4.0</checkstyle-plugin.version>
    <checkstyle.version>10.17.0</checkstyle.version>
    <slf4j.version>2.0.13</slf4j.version>
    <rat.version>0.16.1</rat.version>
    <jacoco.version>0.8.12</jacoco.version>
    <junit5.version>5.10.3</junit5.version>

    <!-- See http://www.eclemma.org/jacoco/trunk/doc/prepare-agent-mojo.html-->
    <jacoco.surefireArgLine />
    <argLine>@{jacoco.surefireArgLine} -Xmx2048m</argLine>

    <sonar.language>java</sonar.language>
    <sonar.java.coveragePlugin>jacoco</sonar.java.coveragePlugin>
    <sonar.core.codeCoveragePlugin>jacoco</sonar.core.codeCoveragePlugin>
    <sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis>

    <git-commit-id-plugin.version>9.0.1</git-commit-id-plugin.version>
    <version.copyright>Copyright (C) 2019-2023 Niels Basjes</version.copyright>
    <version.license>Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License.</version.license>
    <version.url>${project.url}</version.url>
    <project.build.outputTimestamp>2024-07-22T11:12:56Z</project.build.outputTimestamp>
  </properties>

  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>org.junit</groupId>
        <artifactId>junit-bom</artifactId>
        <version>${junit5.version}</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
    </dependencies>
  </dependencyManagement>

  <dependencies>

    <dependency>
      <groupId>org.junit.jupiter</groupId>
      <artifactId>junit-jupiter-engine</artifactId>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>org.junit.vintage</groupId>
      <artifactId>junit-vintage-engine</artifactId>
      <scope>test</scope>
    </dependency>

  </dependencies>

  <profiles>

    <profile>
      <id>skipQuality</id>
      <properties>
        <skipTests>true</skipTests>
        <sonar.skip>true</sonar.skip>
        <rat.skip>true</rat.skip>
        <checkstyle.skip>true</checkstyle.skip>
        <jacoco.skip>true</jacoco.skip>
        <spotbugs.skip>true</spotbugs.skip>
        <dependency-check.skip>true</dependency-check.skip>
        <dependency-convergence.phase>none</dependency-convergence.phase>
        <docker-based-tests.skip>true</docker-based-tests.skip>
        <invoker.skip>true</invoker.skip>
        <cyclonedx.skip>true</cyclonedx.skip>
        <gpg.skip>true</gpg.skip>
      </properties>
    </profile>

    <profile>
      <id>packageForRelease</id>
      <build>
        <plugins>

          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-gpg-plugin</artifactId>
            <version>3.2.4</version>
            <executions>
              <execution>
                <id>sign-artifacts</id>
                <phase>verify</phase>
                <goals>
                  <goal>sign</goal>
                </goals>
              </execution>
            </executions>
          </plugin>

          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-source-plugin</artifactId>
            <version>3.3.1</version>
            <executions>
              <execution>
                <id>attach-sources</id>
                <goals>
                  <goal>jar-no-fork</goal>
                </goals>
              </execution>
            </executions>
          </plugin>

          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-javadoc-plugin</artifactId>
            <version>3.8.0</version>
            <executions>
              <execution>
                <id>attach-javadocs</id>
                <goals>
                  <goal>jar</goal>
                </goals>
              </execution>
            </executions>
          </plugin>

          <plugin>
            <!-- explicitly define maven-deploy-plugin after other to force exec order -->
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-deploy-plugin</artifactId>
            <version>3.1.2</version>
            <executions>
              <execution>
                <id>deploy</id>
                <phase>deploy</phase>
                <goals>
                  <goal>deploy</goal>
                </goals>
              </execution>
            </executions>
          </plugin>

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

    <profile>
      <id>release</id>
      <build>
        <plugins>
          <plugin>
            <!-- Description: https://github.com/git-commit-id/git-commit-id-maven-plugin -->
            <groupId>io.github.git-commit-id</groupId>
            <artifactId>git-commit-id-maven-plugin</artifactId>
            <version>${git-commit-id-plugin.version}</version>
            <executions>
              <execution>
                <id>Validate-Revision-Information</id>
                <phase>validate</phase>
                <goals>
                  <goal>validateRevision</goal>
                </goals>
                <configuration>
                  <validationProperties>
                    <!-- verify that the current repository is not dirty -->
                    <validationProperty>
                      <name>Don't try to release if something has not yet been committed.</name>
                      <!--suppress UnresolvedMavenProperty -->
                      <value>${git.dirty}</value>
                      <shouldMatchTo>false</shouldMatchTo>
                    </validationProperty>
                    <!-- verify that the current commit has a tag -->
                    <validationProperty>
                      <name>validating current commit has a tag</name>
                      <!--suppress UnresolvedMavenProperty -->
                      <value>${git.closest.tag.commit.count}</value>
                      <shouldMatchTo>0</shouldMatchTo>
                    </validationProperty>
                  </validationProperties>
                  <validationShouldFailIfNoMatch>true</validationShouldFailIfNoMatch>
                </configuration>
              </execution>
            </executions>
          </plugin>

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

    <profile>
      <id>SkipSonarBecauseItWasNotConfigured</id>
      <activation>
        <property>
          <name>!env.SONAR_TOKEN</name>
        </property>
      </activation>
      <properties>
        <sonar.skip>true</sonar.skip>
      </properties>
    </profile>

  </profiles>

  <build>
    <defaultGoal>clean package</defaultGoal>
    <plugins>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-toolchains-plugin</artifactId>
        <executions>
          <execution>
            <goals>
              <goal>toolchain</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <toolchains>
            <jdk>
              <version>17</version>
            </jdk>
          </toolchains>
        </configuration>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.13.0</version>
        <configuration>
          <source>8</source>
          <release>8</release>
          <compilerArgs>
            <!-- Enable almost all warnings.                                                                      -->
            <!-- Ignore 'processing' to avoid "No processor claimed any of these annotations" in several places.  -->
            <!-- Ignore 'serial' warnings about not having a serialVersionUID                                     -->
            <!-- Ignore 'path' warnings (some dependencies have a bad classpath in their MANIFEST.MF)             -->
            <!--   [WARNING] [path] bad path element                                                              -->
            <!--     "/home/nbasjes/.m2/repository/org/scala-lang/scala-compiler/2.12.7/scala-reflect.jar":       -->
            <!--     no such file or directory                                                                    -->
            <!--   https://stackoverflow.com/questions/41944939/maven-build-failure-involving-manifest-mf-classpath-in-dependency-jars  -->
            <!--   https://stackoverflow.com/questions/1344202/bad-path-warning-where-is-it-coming-from                                 -->
            <arg>-Xlint:all,-processing,-serial,-path</arg>
            <arg>-Werror</arg>
            <arg>-implicit:class</arg>
          </compilerArgs>
          <showWarnings>true</showWarnings>
          <showDeprecation>true</showDeprecation>
        </configuration>
      </plugin>

      <plugin>
        <groupId>org.jacoco</groupId>
        <artifactId>jacoco-maven-plugin</artifactId>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-release-plugin</artifactId>
        <version>3.1.1</version>
        <dependencies>
          <dependency>
            <groupId>nl.basjes.maven.release</groupId>
            <artifactId>conventional-commits-version-policy</artifactId>
            <version>1.0.7</version>
          </dependency>
        </dependencies>
        <configuration>
          <autoVersionSubmodules>true</autoVersionSubmodules>

          <scmCommentPrefix>Release:</scmCommentPrefix>
          <scmReleaseCommitComment>Release: Version @{releaseLabel}</scmReleaseCommitComment>
          <scmDevelopmentCommitComment>Release: Start development of next version</scmDevelopmentCommitComment>
          <scmRollbackCommitComment>Release: Rollback the release of @{releaseLabel}</scmRollbackCommitComment>

          <tagNameFormat>v@{project.version}</tagNameFormat>
          <projectVersionPolicyId>ConventionalCommitsVersionPolicy</projectVersionPolicyId>
          <projectVersionPolicyConfig>
            <versionTag>^v([0-9]+\.[0-9]+\.[0-9]+)$</versionTag>
          </projectVersionPolicyConfig>

          <preparationProfiles>packageForRelease</preparationProfiles>
          <preparationGoals>clean verify</preparationGoals>
          <releaseProfiles>packageForRelease,release,deployToSonatype</releaseProfiles>
          <pushChanges>false</pushChanges>
          <remoteTagging>false</remoteTagging>
        </configuration>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-deploy-plugin</artifactId>
      </plugin>

      <plugin>
        <!-- Description: https://github.com/git-commit-id/git-commit-id-maven-plugin -->
        <groupId>io.github.git-commit-id</groupId>
        <artifactId>git-commit-id-maven-plugin</artifactId>
        <version>${git-commit-id-plugin.version}</version>
        <executions>
          <execution>
            <id>get-the-git-infos</id>
            <phase>validate</phase>
            <goals>
              <goal>revision</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <dateFormat>yyyy-MM-dd '@' HH:mm:ss z</dateFormat>
        </configuration>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-enforcer-plugin</artifactId>
        <version>3.5.0</version>
        <dependencies>
          <dependency>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>extra-enforcer-rules</artifactId>
            <version>1.8.0</version>
          </dependency>
        </dependencies>
        <executions>
          <execution>
            <id>enforce-build</id>
            <phase>validate</phase>
            <goals>
              <goal>enforce</goal>
            </goals>
            <configuration>
              <fail>true</fail>
              <rules>
                <requireJavaVersion>
                  <version>[11,)</version>
                  <message>Although the target JVM is JRE 8, the build MUST be done with JDK 11 or higher.</message>
                </requireJavaVersion>
                <requireMavenVersion>
                  <version>[${maven.minimal.version},)</version>
                  <message>You must use a newer version of Maven</message>
                </requireMavenVersion>
                <enforceBytecodeVersion>
                  <maxJdkVersion>8</maxJdkVersion>
                </enforceBytecodeVersion>
                <dependencyConvergence />
              </rules>
            </configuration>
          </execution>
        </executions>
      </plugin>


      <plugin>
        <groupId>org.apache.rat</groupId>
        <artifactId>apache-rat-plugin</artifactId>
        <version>${rat.version}</version>
        <inherited>false</inherited>
        <executions>
          <execution>
            <phase>validate</phase>
            <goals>
              <goal>check</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
<!--          <addDefaultLicenses>false</addDefaultLicenses>-->
          <addDefaultLicenseMatchers>false</addDefaultLicenseMatchers>
          <families>
            <family>
              <id>CC</id>
              <name>Creative Commons</name>
            </family>
          </families>
          <licenses>
            <license>
              <family>CC</family>
              <id>CC-BY-NC-ND</id>
              <notes />
              <name>Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International</name>
              <any>
                <text>Attribution-NonCommercial-NoDerivatives</text>
              </any>
            </license>
          </licenses>
          <approvedLicenses>
            <approvedLicense>CC</approvedLicense>
          </approvedLicenses>
          <consoleOutput>true</consoleOutput>
          <excludeSubProjects>false</excludeSubProjects>
          <excludes>
            <!-- Version control files -->
            <exclude>**/.git/**</exclude>
            <exclude>**/.gitignore</exclude>
            <exclude>**/.gitmodules</exclude>
            <!-- IDE settings and files -->
            <exclude>**/.classpath</exclude>
            <exclude>**/.project</exclude>
            <exclude>**/.settings/**</exclude>
            <exclude>**/.idea/**</exclude>
            <exclude>**/*.iml</exclude>
            <exclude>*.patch</exclude>
            <exclude>*.diff</exclude>
            <!-- Documentation -->
            <exclude>src/**</exclude>
            <exclude>docs/**</exclude>
            <!-- Files that cannot be 'polluted' -->
            <exclude>CNAME</exclude>
            <exclude>.github/**</exclude>
            <exclude>*.json</exclude>
            <exclude>generate-sunspec-parser/src/main/resources/models/**</exclude>
            <exclude>**/*.csv</exclude>
            <!-- Test and demo input files -->
            <exclude>**/testfiles/**</exclude>
            <exclude>**/*.log</exclude>
            <exclude>**/examples/**/*.jar</exclude>
            <!-- File generated during build -->
            <exclude>**/target/**</exclude>
            <exclude>**/*.tokens</exclude>
            <exclude>**/dependency-reduced-pom.xml</exclude>
            <!-- Other files -->
            <exclude>ReleaseProcedure.txt</exclude>
            <exclude>benchmarks/*.txt</exclude>
            <exclude>benchmarks/*.csv</exclude>
            <exclude>analyzer/run-pitest.sh</exclude>
            <exclude>analyzer/pitest/</exclude>
            <exclude>**/.~lock.*</exclude>
            <exclude>docker/_m2/**</exclude>
            <exclude>docker/_gnupg/**</exclude>
            <!-- Test scripts -->
            <exclude>*.sh</exclude>
            <exclude>**/_*/**</exclude>
          </excludes>
        </configuration>
      </plugin>

    </plugins>

    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-toolchains-plugin</artifactId>
          <version>3.2.0</version>
        </plugin>

        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-checkstyle-plugin</artifactId>
          <version>${checkstyle-plugin.version}</version>
          <dependencies>
            <dependency>
              <groupId>nl.basjes.energy</groupId>
              <artifactId>devtools</artifactId>
              <version>${project.version}</version>
            </dependency>
            <dependency>
              <groupId>com.puppycrawl.tools</groupId>
              <artifactId>checkstyle</artifactId>
              <version>${checkstyle.version}</version>
            </dependency>
          </dependencies>
          <configuration>
            <consoleOutput>true</consoleOutput>
            <configLocation>checkstyle/checkstyle.xml</configLocation>
            <suppressionsLocation>checkstyle/suppressions.xml</suppressionsLocation>
            <includeTestSourceDirectory>true</includeTestSourceDirectory>
          </configuration>
          <!-- Runs by default in the verify phase  (mvn verify or later in the build cycle)
               the 'check' goal will fail the build if it does not pass.  "mvn checkstyle:check"
               will do this alone, or "mvn checkstyle:checkstyle" will report but not break  -->
          <executions>
            <execution>
              <id>checkstyle-check</id>
              <phase>test</phase>
              <goals>
                <goal>check</goal>
              </goals>
            </execution>
          </executions>
        </plugin>

        <!-- Coverage analysis for tests -->
        <plugin>
          <groupId>org.jacoco</groupId>
          <artifactId>jacoco-maven-plugin</artifactId>
          <version>${jacoco.version}</version>
          <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 name of the property containing the settings
                    for JaCoCo runtime agent.
                -->
                <propertyName>jacoco.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>
            </execution>
          </executions>
        </plugin>

        <plugin>
          <groupId>org.sonarsource.scanner.maven</groupId>
          <artifactId>sonar-maven-plugin</artifactId>
          <version>4.0.0.4121</version>
        </plugin>

        <plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-clean-plugin</artifactId><version>3.4.0</version></plugin>
        <plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-compiler-plugin</artifactId><version>3.13.0</version></plugin>
        <plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-deploy-plugin</artifactId><version>3.1.2</version></plugin>
        <plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-install-plugin</artifactId><version>3.1.2</version></plugin>
        <plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-resources-plugin</artifactId><version>3.3.1</version></plugin>
        <plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-site-plugin</artifactId><version>3.12.1</version></plugin>
        <plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-surefire-plugin</artifactId><version>3.3.1</version></plugin>
        <plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-shade-plugin</artifactId><version>3.6.0</version></plugin>
        <plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-jar-plugin</artifactId><version>3.4.2</version></plugin>
        <plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-war-plugin</artifactId><version>3.4.0</version></plugin>
        <plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-assembly-plugin</artifactId><version>3.7.1</version></plugin>

      </plugins>
    </pluginManagement>
  </build>

  <modules>
    <module>devtools</module>
    <module>generate-sunspec-parser</module>
    <module>modbus-parsers</module>
    <module>udfs</module>
  </modules>

  <url>https://energy.basjes.nl</url>

  <licenses>
    <license>
      <name>Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International</name>
      <url>https://creativecommons.org/licenses/by-nc-nd/4.0/</url>
      <distribution>repo</distribution>
    </license>
  </licenses>

  <developers>
    <developer>
      <name>Niels Basjes</name>
      <email>niels@basjes.nl</email>
      <roles>
        <role>Architect</role>
        <role>Developer</role>
      </roles>
      <timezone>Europe/Amsterdam</timezone>
    </developer>
  </developers>

  <scm>
    <url>https://energy.basjes.nl</url>
    <connection>scm:git:https://github.com/nielsbasjes/energy.git</connection>
    <developerConnection>scm:git:file:///${project.basedir}</developerConnection>
    <tag>v0.0.2</tag>
  </scm>

</project>
