<?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>org.openhab.tools.sat</groupId>
  <artifactId>pom</artifactId>
  <version>0.12.0</version>
  <packaging>pom</packaging>

  <name>Static Code Analysis Tool Parent POM</name>
  <description>Tool that aggregates reports of PMD, Checkstyle and FindBugs</description>
  <url>https://github.com/openhab/static-code-analysis</url>

  <organization>
    <name>openHAB.org</name>
    <url>https://www.openhab.org</url>
  </organization>

  <licenses>
    <license>
      <name>Eclipse Public License 2.0</name>
      <url>https://www.eclipse.org/legal/epl-2.0/</url>
    </license>
  </licenses>

  <developers>
    <developer>
      <name>Svilen Valkanov</name>
      <email>svilen.valkanov@musala.com</email>
    </developer>
  </developers>

  <modules>
    <module>custom-checks</module>
    <module>sat-extension</module>
    <module>sat-plugin</module>
    <module>codestyle</module>
  </modules>
  <scm>
    <connection>scm:git:git@github.com:openhab/static-code-analysis.git</connection>
    <developerConnection>scm:git:git@github.com:openhab/static-code-analysis.git</developerConnection>
    <url>git@github.com:openhab/static-code-analysis.git</url>
  </scm>
  <issueManagement>
    <system>GitHub</system>
    <url>https://github.com/openhab/static-code-analysis/issues</url>
  </issueManagement>

  <distributionManagement>
    <repository>
      <uniqueVersion>false</uniqueVersion>
      <id>maven</id>
      <url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
    </repository>
  </distributionManagement>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <oh.java.version>11</oh.java.version>
    <maven.compiler.source>${oh.java.version}</maven.compiler.source>
    <maven.compiler.target>${oh.java.version}</maven.compiler.target>
    <maven.compiler.compilerVersion>${oh.java.version}</maven.compiler.compilerVersion>
    <maven.eclipse.version>2.10</maven.eclipse.version>
    <junit.version>5.8.1</junit.version>
    <commons.io.version>2.11.0</commons.io.version>
    <commons.lang3.version>3.12.0</commons.lang3.version>
    <mockito.version>4.0.0</mockito.version>
    <maven.resources.version>2.4</maven.resources.version>
    <pmd.version>6.39.0</pmd.version>
    <checkstyle.version>8.45.1</checkstyle.version>
    <spotbugs.version>4.4.2</spotbugs.version>
    <maven.core.version>3.6.0</maven.core.version>
    <maven.plugin.api.version>3.6.0</maven.plugin.api.version>
    <maven.plugin.annotations.version>3.6.0</maven.plugin.annotations.version>
    <maven.plugin.plugin.version>3.6.0</maven.plugin.plugin.version>
    <maven.plugin.compiler.version>3.8.1</maven.plugin.compiler.version>
    <mojo.executor.version>2.3.0</mojo.executor.version>
    <org.apache.ivy.version>2.4.0</org.apache.ivy.version>
    <org.jsoup.version>1.7.1</org.jsoup.version>
    <pde.core.version>3.11.1</pde.core.version>
    <sat.version>0.10.0</sat.version>
    <jdt-annotations.version>2.1.0</jdt-annotations.version>
    <flexmark.version>0.60.0</flexmark.version>
    <maven.surefire.plugin.version>3.0.0-M5</maven.surefire.plugin.version>
    <jetty.server.version>9.4.20.v20190813</jetty.server.version>
    <saxon.version>9.1.0.8</saxon.version>
    <spotless.version>2.0.3</spotless.version>
    <slf4j.version>1.7.25</slf4j.version>
    <logback.version>1.2.3</logback.version>
    <eea.version>2.3.0</eea.version>
    <m2e.jdt.annotationpath>target/dependency</m2e.jdt.annotationpath>
  </properties>

  <dependencies>
    <dependency>
      <groupId>javax.xml.bind</groupId>
      <artifactId>jaxb-api</artifactId>
      <version>2.3.1</version>
    </dependency>
    <dependency>
      <groupId>org.glassfish.jaxb</groupId>
      <artifactId>jaxb-runtime</artifactId>
      <version>2.3.1</version>
    </dependency>
    <dependency>
      <groupId>org.hamcrest</groupId>
      <artifactId>hamcrest-library</artifactId>
      <version>2.2</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>com.sun.activation</groupId>
      <artifactId>javax.activation</artifactId>
      <version>1.2.0</version>
    </dependency>
    <dependency>
      <groupId>org.junit.jupiter</groupId>
      <artifactId>junit-jupiter-api</artifactId>
      <version>${junit.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.junit.jupiter</groupId>
      <artifactId>junit-jupiter-params</artifactId>
      <version>${junit.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <!-- Required for Checkstyle tests -->
      <groupId>com.google.truth</groupId>
      <artifactId>truth</artifactId>
      <version>1.1.3</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.mockito</groupId>
      <artifactId>mockito-core</artifactId>
      <version>${mockito.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.mockito</groupId>
      <artifactId>mockito-junit-jupiter</artifactId>
      <version>${mockito.version}</version>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <repositories>
    <repository>
      <releases>
        <enabled>true</enabled>
        <updatePolicy>never</updatePolicy>
      </releases>
      <snapshots>
        <enabled>false</enabled>
      </snapshots>
      <id>openhab-artifactory-release</id>
      <name>JFrog Artifactory Repository</name>
      <url>https://openhab.jfrog.io/openhab/libs-release</url>
    </repository>
  </repositories>

  <pluginRepositories>
    <pluginRepository>
      <id>openhab-artifactory-release</id>
      <url>https://openhab.jfrog.io/openhab/libs-release</url>
    </pluginRepository>
  </pluginRepositories>

  <build>
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>com.mycila</groupId>
          <artifactId>license-maven-plugin</artifactId>
          <version>3.0</version>
          <configuration>
            <basedir>${basedir}</basedir>
            <header>licenses/epl-2.0/header.txt</header>
            <quiet>false</quiet>
            <failIfMissing>true</failIfMissing>
            <strictCheck>true</strictCheck>
            <aggregate>true</aggregate>
            <mapping>
              <xml>xml-header-style</xml>
            </mapping>
            <headerDefinitions>
              <headerDefinition>licenses/epl-2.0/xml-header-style.xml</headerDefinition>
            </headerDefinitions>
            <includes>
              <include>**/org/openhab/**/*.java</include>
              <include>**/OSGI-INF/*.xml</include>
            </includes>
            <excludes>
              <exclude>**/pom.xml</exclude>
              <exclude>target/**</exclude>
              <exclude>**/org/openhab/tools/analysis/findbugs/CustomClassNameLengthDetector.java</exclude>
              <exclude>**/org/openhab/tools/analysis/report/ReportUtility.java</exclude>
            </excludes>
            <useDefaultExcludes>true</useDefaultExcludes>
            <properties>
              <year>2021</year>
            </properties>
            <encoding>UTF-8</encoding>
          </configuration>
          <executions>
            <execution>
              <goals>
                <goal>check</goal>
              </goals>
            </execution>
          </executions>
        </plugin>

        <!-- This plugin's configuration is used to store Eclipse m2e settings only. -->
        <!-- It has no influence on the Maven build itself. -->
        <plugin>
          <groupId>org.eclipse.m2e</groupId>
          <artifactId>lifecycle-mapping</artifactId>
          <version>1.0.0</version>
          <configuration>
            <lifecycleMappingMetadata>
              <pluginExecutions>
                <pluginExecution>
                  <pluginExecutionFilter>
                    <groupId>org.commonjava.maven.plugins</groupId>
                    <artifactId>directory-maven-plugin</artifactId>
                    <versionRange>[0.3.1,)</versionRange>
                    <goals>
                      <goal>highest-basedir</goal>
                    </goals>
                  </pluginExecutionFilter>
                  <action>
                    <ignore></ignore>
                  </action>
                </pluginExecution>
              </pluginExecutions>
            </lifecycleMappingMetadata>
          </configuration>
        </plugin>

        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-enforcer-plugin</artifactId>
          <version>3.0.0-M2</version>
        </plugin>

        <plugin>
          <groupId>org.openhab.tools.sat</groupId>
          <artifactId>sat-plugin</artifactId>
          <version>${sat.version}</version>
          <configuration>
            <checkstyleFilter>${basedirRoot}/tools/static-code-analysis/checkstyle/suppressions.xml</checkstyleFilter>
            <checkstyleProperties>${basedirRoot}/tools/static-code-analysis/checkstyle/ruleset.properties</checkstyleProperties>
            <pmdFilter>${basedirRoot}/tools/static-code-analysis/pmd/suppressions.properties</pmdFilter>
            <spotBugsVersion>4.0.1</spotBugsVersion>
          </configuration>
          <executions>
            <execution>
              <goals>
                <goal>checkstyle</goal>
                <goal>pmd</goal>
                <goal>spotbugs</goal>
                <goal>report</goal>
              </goals>
              <phase>verify</phase>
            </execution>
          </executions>
        </plugin>

        <plugin>
          <groupId>com.github.ekryd.sortpom</groupId>
          <artifactId>sortpom-maven-plugin</artifactId>
          <version>2.10.0</version>
          <configuration>
            <predefinedSortOrder>recommended_2008_06</predefinedSortOrder>
            <createBackupFile>false</createBackupFile>
            <keepBlankLines>true</keepBlankLines>
          </configuration>
          <executions>
            <execution>
              <id>sortpom-verify</id>
              <goals>
                <goal>verify</goal>
              </goals>
              <phase>verify</phase>
              <configuration>
                <verifyFail>Stop</verifyFail>
              </configuration>
            </execution>
          </executions>
        </plugin>

        <plugin>
          <groupId>com.diffplug.spotless</groupId>
          <artifactId>spotless-maven-plugin</artifactId>
          <version>${spotless.version}</version>
          <configuration>
            <java>
              <eclipse>
                <file>openhab_codestyle.xml</file>
                <version>4.13.0</version>
              </eclipse>
              <removeUnusedImports/>
              <importOrder>
                <file>openhab.importorder</file>
              </importOrder>
              <endWithNewline/>
            </java>
            <formats>
              <format>
                <!-- *.xml -->
                <includes>
                  <include>src/**/*.xml</include>
                </includes>
                <excludes>
                  <exclude>**/pom.xml</exclude>
                  <exclude>src/test/resources/**/*.xml</exclude>
                </excludes>
                <eclipseWtp>
                  <type>XML</type>
                  <files>
                    <file>openhab_wst_xml_files.prefs</file>
                  </files>
                  <version>4.13.0</version>
                </eclipseWtp>
                <trimTrailingWhitespace/>
                <endWithNewline/>
              </format>
              <format>
                <!-- pom.xml -->
                <includes>
                  <include>pom.xml</include>
                </includes>
                <eclipseWtp>
                  <type>XML</type>
                  <files>
                    <file>openhab_wst_pom_file.prefs</file>
                  </files>
                  <version>4.13.0</version>
                </eclipseWtp>
                <trimTrailingWhitespace/>
                <endWithNewline/>
              </format>
            </formats>
          </configuration>
          <dependencies>
            <dependency>
              <groupId>org.openhab.tools</groupId>
              <artifactId>openhab-codestyle</artifactId>
              <version>${sat.version}</version>
            </dependency>
          </dependencies>
          <executions>
            <execution>
              <id>codestyle_check</id>
              <goals>
                <goal>check</goal>
              </goals>
              <phase>initialize</phase>
            </execution>
          </executions>
        </plugin>

      </plugins>
    </pluginManagement>
    <plugins>
      <plugin>
        <groupId>org.commonjava.maven.plugins</groupId>
        <artifactId>directory-maven-plugin</artifactId>
        <version>0.3.1</version>
        <executions>
          <execution>
            <id>directories</id>
            <goals>
              <goal>highest-basedir</goal>
            </goals>
            <phase>initialize</phase>
            <configuration>
              <property>basedirRoot</property>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>${maven.surefire.plugin.version}</version>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-eclipse-plugin</artifactId>
        <version>${maven.eclipse.version}</version>
        <configuration>
          <downloadSources>true</downloadSources>
          <downloadJavadocs>true</downloadJavadocs>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>${maven.plugin.compiler.version}</version>
        <configuration>
          <compilerId>eclipse</compilerId>
          <compilerArguments>
            <annotationpath>CLASSPATH</annotationpath>
            <classpath>${project.build.directory}/dependency</classpath>
          </compilerArguments>
          <compilerArgs>
            <arg>-err:+nullAnnot(org.eclipse.jdt.annotation.Nullable|org.eclipse.jdt.annotation.NonNull|org.eclipse.jdt.annotation.NonNullByDefault),+inheritNullAnnot,+nullAnnotConflict,-nullUncheckedConversion</arg>
            <arg>-warn:+null,+inheritNullAnnot,+nullAnnotConflict,-nullUncheckedConversion,+nullAnnotRedundant,+nullDereference</arg>
          </compilerArgs>
          <showWarnings>true</showWarnings>
          <showDeprecation>true</showDeprecation>
        </configuration>
        <dependencies>
          <dependency>
            <groupId>org.codehaus.plexus</groupId>
            <artifactId>plexus-compiler-eclipse</artifactId>
            <version>2.8.8</version>
          </dependency>
          <dependency>
            <groupId>org.eclipse.jdt</groupId>
            <artifactId>ecj</artifactId>
            <version>3.23.0</version>
          </dependency>
        </dependencies>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-source-plugin</artifactId>
        <version>2.4</version>
        <configuration>
          <attach>true</attach>
        </configuration>
        <executions>
          <execution>
            <id>attach-sources</id>
            <goals>
              <goal>jar-no-fork</goal>
            </goals>
            <phase>verify</phase>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-javadoc-plugin</artifactId>
        <version>3.1.1</version>
        <configuration>
          <source>11</source>
          <outputDirectory>${project.build.directory}/javadoc</outputDirectory>
          <failOnError>true</failOnError>
        </configuration>
        <executions>
          <execution>
            <id>attach-javadocs</id>
            <goals>
              <goal>jar</goal>
            </goals>
            <configuration>
              <additionalparam>${javadoc.opts}</additionalparam>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-enforcer-plugin</artifactId>
        <executions>
          <execution>
            <id>enforce-java</id>
            <goals>
              <goal>enforce</goal>
            </goals>
            <configuration>
              <rules>
                <requireJavaVersion>
                  <version>[11.0,12.0)</version>
                </requireJavaVersion>
              </rules>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>com.github.ekryd.sortpom</groupId>
        <artifactId>sortpom-maven-plugin</artifactId>
      </plugin>
      <plugin>
        <groupId>com.diffplug.spotless</groupId>
        <artifactId>spotless-maven-plugin</artifactId>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
        <version>3.1.2</version>
        <executions>
          <execution>
            <id>unpack-eea</id>
            <goals>
              <goal>unpack</goal>
            </goals>
            <configuration>
              <artifactItems>
                <artifactItem>
                  <groupId>org.lastnpe.eea</groupId>
                  <artifactId>eea-all</artifactId>
                  <version>${eea.version}</version>
                  <overWrite>true</overWrite>
                </artifactItem>
              </artifactItems>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
    <extensions>
      <extension>
        <groupId>org.openhab.tools.sat</groupId>
        <artifactId>sat-extension</artifactId>
        <version>${sat.version}</version>
      </extension>
    </extensions>
  </build>

  <profiles>
    <profile>
      <id>skip-check</id>
      <activation>
        <property>
          <name>skipChecks</name>
        </property>
      </activation>
      <build>
        <pluginManagement>
          <plugins>
            <plugin>
              <groupId>org.openhab.tools.sat</groupId>
              <artifactId>sat-plugin</artifactId>
              <version>${sat.version}</version>
              <executions>
                <execution>
                  <id>sat-all</id>
                  <phase>none</phase>
                </execution>
              </executions>
            </plugin>
          </plugins>
        </pluginManagement>
      </build>
    </profile>
    <profile>
      <id>check-code</id>
      <activation>
        <property>
          <name>!skipChecks</name>
        </property>
      </activation>
      <build>
        <plugins>
          <plugin>
            <groupId>org.openhab.tools.sat</groupId>
            <artifactId>sat-plugin</artifactId>
          </plugin>
        </plugins>
      </build>
    </profile>
    <profile>
      <id>sign</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>1.5</version>
            <executions>
              <execution>
                <id>sign-artifacts</id>
                <goals>
                  <goal>sign</goal>
                </goals>
                <phase>verify</phase>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>

</project>
