<?xml version="1.0" encoding="UTF-8"?>
<!--
  Copyright (c) 2018 PANTHEON.tech s.r.o. All Rights Reserved.

  This program and the accompanying materials are made available under the
  terms of the Eclipse Public License v1.0 which accompanies this distribution,
  and is available at https://www.eclipse.org/legal/epl-v10.html
-->
<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>

    <parent>
        <groupId>io.lighty.core</groupId>
        <artifactId>lighty-minimal-parent</artifactId>
        <version>14.4.0</version>
        <relativePath>../lighty-minimal-parent</relativePath>
    </parent>

    <!-- This is the main parent for building LightyModule jars. -->

    <artifactId>lighty-parent</artifactId>
    <packaging>pom</packaging>

    <name>${project.groupId}:${project.artifactId}</name>
    <url>https://github.com/PANTHEONtech/lighty</url>
    <description>
        Parent pom for code artifacts using Lighty.io.
    </description>

    <properties>
        <maven.compiler.release>11</maven.compiler.release>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.testng</groupId>
            <artifactId>testng</artifactId>
        </dependency>

        <!-- ODL components are using JDT annotations quite widely -->
        <dependency>
            <groupId>org.eclipse.jdt</groupId>
            <artifactId>org.eclipse.jdt.annotation</artifactId>
        </dependency>
    </dependencies>

    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.8.1</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-clean-plugin</artifactId>
                    <version>3.1.0</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-resources-plugin</artifactId>
                    <version>3.2.0</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-jar-plugin</artifactId>
                    <version>3.2.0</version>
                    <configuration>
                        <archive>
                            <manifest>
                                <addClasspath>true</addClasspath>
                            </manifest>
                        </archive>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-install-plugin</artifactId>
                    <version>2.5.2</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-assembly-plugin</artifactId>
                    <version>3.2.0</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-failsafe-plugin</artifactId>
                    <version>3.0.0-M5</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <version>3.0.0-M5</version>
                    <configuration>
                        <forkCount>1</forkCount>
                        <reuseForks>true</reuseForks>
                        <redirectTestOutputToFile>true</redirectTestOutputToFile>
                        <excludes>
                            <exclude>**/*TestIT.java</exclude>
                        </excludes>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.jacoco</groupId>
                    <artifactId>jacoco-maven-plugin</artifactId>
                    <version>0.8.7</version>
                    <executions>
                        <execution>
                            <id>jacoco-prepare-agent</id>
                            <goals>
                                <goal>prepare-agent</goal>
                            </goals>
                        </execution>
                        <execution>
                            <id>jacoco-report</id>
                            <goals>
                                <goal>report</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-no-fork</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>build-helper-maven-plugin</artifactId>
                    <version>3.0.0</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-javadoc-plugin</artifactId>
                    <version>3.1.1</version>
                    <configuration combine.children="append">
                        <!-- Keep things quiet except for warnings/errors -->
                        <quiet>true</quiet>
                    </configuration>
                    <executions>
                        <execution>
                            <id>attach-javadocs</id>
                            <goals>
                                <goal>jar</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <artifactId>maven-checkstyle-plugin</artifactId>
                    <version>3.1.1</version>
                    <dependencies>
                        <dependency>
                            <groupId>com.puppycrawl.tools</groupId>
                            <artifactId>checkstyle</artifactId>
                            <!-- This should match the dependency management on com.puppycrawl.tools:checkstyle above -->
                            <version>8.34</version>
                        </dependency>
                        <dependency>
                            <groupId>com.github.sevntu-checkstyle</groupId>
                            <artifactId>sevntu-checks</artifactId>
                            <version>1.37.1</version>
                        </dependency>
                        <dependency>
                            <groupId>org.opendaylight.odlparent</groupId>
                            <artifactId>checkstyle</artifactId>
                            <version>8.1.9</version>
                        </dependency>
                    </dependencies>
                </plugin>
                <plugin>
                    <groupId>com.github.spotbugs</groupId>
                    <artifactId>spotbugs-maven-plugin</artifactId>
                    <version>3.1.12.2</version>
                    <dependencies>
                        <dependency>
                            <groupId>com.github.spotbugs</groupId>
                            <artifactId>spotbugs</artifactId>
                            <version>3.1.12</version>
                        </dependency>
                        <dependency>
                            <groupId>org.opendaylight.odlparent</groupId>
                            <artifactId>spotbugs</artifactId>
                            <version>8.1.9</version>
                        </dependency>
                        <dependency>
                            <!-- The SpotBugs Maven plugin uses SLF4J 1.8 beta 2 -->
                            <groupId>org.slf4j</groupId>
                            <artifactId>slf4j-simple</artifactId>
                            <version>1.8.0-beta2</version>
                        </dependency>
                    </dependencies>
                </plugin>
            </plugins>
        </pluginManagement>

        <plugins>
            <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.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>source-quality</id>
            <build>
                <plugins>
                    <plugin>
                        <artifactId>maven-checkstyle-plugin</artifactId>
                        <configuration>
                            <configLocation>odl_checks.xml</configLocation>
                            <suppressionsLocation>checkstyle-suppressions.xml</suppressionsLocation>
                            <!-- <sourceDirectories> are needed so that checkstyle ignores the
                                 generated sources directory -->
                            <sourceDirectories>
                                <directory>${project.build.sourceDirectory}</directory>
                            </sourceDirectories>
                            <includeResources>true</includeResources>
                            <includeTestSourceDirectory>true</includeTestSourceDirectory>
                            <includeTestResources>true</includeTestResources>
                            <includes>**\/*.java, **\/*.xtend</includes>
                            <excludes>
                                    org/opendaylight/yang/gen/**,
                                    **/protobuff/messages/**,
                                    **/thrift/gen/*.java
                            </excludes>
                            <failsOnError>true</failsOnError>
                            <consoleOutput>true</consoleOutput>
                            <propertyExpansion>checkstyle.violationSeverity=error</propertyExpansion>
                        </configuration>
                        <executions>
                            <execution>
                                <goals>
                                    <goal>check</goal>
                                </goals>
                                <phase>process-sources</phase>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>com.github.spotbugs</groupId>
                        <artifactId>spotbugs-maven-plugin</artifactId>
                        <configuration>
                            <plugins>
                                <plugin>
                                    <groupId>jp.skypencil.findbugs.slf4j</groupId>
                                    <artifactId>bug-pattern</artifactId>
                                    <version>1.4.2</version>
                                </plugin>
                            </plugins>
                            <!--
                              Enables analysis which takes more memory but finds more bugs.
                              If you run out of memory, changes the value of the effort element
                              to 'Low'.
                            -->
                            <effort>Max</effort>
                            <!-- Reports all bugs (other values are medium and max) -->
                            <threshold>Low</threshold>
                            <!-- Build doesn't fail if problems are found -->
                            <failOnError>true</failOnError>
                            <!-- References the excluded rules -->
                            <excludeFilterFile>spotbugs-exclude.xml</excludeFilterFile>
                            <!-- Produces XML report -->
                            <xmlOutput>true</xmlOutput>
                            <!-- Configures the directory in which the XML report is created -->
                            <findbugsXmlOutputDirectory>${project.build.directory}/spotbugs</findbugsXmlOutputDirectory>
                        </configuration>
                        <executions>
                            <!--
                              Ensures that SpotBugs inspects source code when project is compiled.
                            -->
                            <execution>
                                <id>analyze-compile</id>
                                <phase>compile</phase>
                                <goals>
                                    <goal>check</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <profile>
            <id>test-integration</id>
            <!-- run integration tests and skip unit tests -->
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-failsafe-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>integration-test-execution</id>
                                <goals>
                                    <goal>integration-test</goal>
                                </goals>
                            </execution>
                        </executions>
                        <configuration>
                            <suiteXmlFiles>
                                <suiteXmlFile>
                                    ${project.build.testOutputDirectory}/suites/all/suiteOfSuites.xml
                                </suiteXmlFile>
                            </suiteXmlFiles>
                            <includes>
                                <include>**/*TestIT.java</include>
                            </includes>
                            <redirectTestOutputToFile>true</redirectTestOutputToFile>
                        </configuration>
                    </plugin>

                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <configuration>
                            <skipTests>true</skipTests>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

</project>

