<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>org.cqfn.diktat</groupId>
    <artifactId>diktat-parent</artifactId>
    <version>1.2.4.2</version>
    <packaging>pom</packaging>

    <name>diktat</name>
    <description>diKTat kotlin formatter and fixer</description>
    <url>https://www.cqfn.org/diKTat/</url>

    <licenses>
        <license>
            <name>MIT License</name>
            <url>http://www.opensource.org/licenses/mit-license.php</url>
        </license>
    </licenses>

    <scm>
        <connection>scm:git:git://github.com/saveourtool/diktat.git</connection>
        <developerConnection>scm:git:ssh://github.com:saveourtool/diktat.git</developerConnection>
        <url>http://github.com/saveourtool/diktat/tree/master</url>
    </scm>

    <developers>
        <developer>
            <name>Andrey Kuleshov</name>
            <email>andrewkuleshov7@gmail.com</email>
            <url>https://github.com/akuleshov7</url>
        </developer>
        <developer>
            <name>Peter Trifanov</name>
            <email>peter.trifanov@mail.ru</email>
            <url>https://github.com/petertrr</url>
        </developer>
    </developers>

    <properties>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <kotlin.version>1.7.21</kotlin.version>
        <kotlin.compiler.incremental>true</kotlin.compiler.incremental>
        <kotlin.code.style>official</kotlin.code.style>
        <kotlinx.serialization.version>1.4.1</kotlinx.serialization.version>
        <ktlint.version>0.46.1</ktlint.version>
        <junit.version>5.9.1</junit.version>
        <junit.platform.version>1.9.1</junit.platform.version>
        <surefire.junit5.tree-reporter.version>1.1.0</surefire.junit5.tree-reporter.version>
        <guava.version>31.1-jre</guava.version>
        <commons-cli.version>1.5.0</commons-cli.version>
        <diktat-check.version>1.2.4</diktat-check.version>
        <kotlinpoet.version>1.12.0</kotlinpoet.version>
        <detekt.version>1.21.0.1</detekt.version>
        <dokka.version>1.7.20</dokka.version>
        <jacoco.version>0.8.8</jacoco.version>
        <maven-plugin-tools.version>3.6.4</maven-plugin-tools.version>
        <jbool.version>1.24</jbool.version>
        <mu-logging.version>3.0.4</mu-logging.version>
        <log4j.version>2.19.0</log4j.version>
    </properties>

    <modules>
        <module>diktat-common</module>
        <module>diktat-rules</module>
        <module>diktat-test-framework</module>
        <module>diktat-ruleset</module>
        <module>diktat-maven-plugin</module>
        <module>diktat-gradle-plugin</module>
    </modules>

    <!-- Even though deployment is handled by nexus plugin, this section is required for it's operation -->
    <distributionManagement>
        <snapshotRepository>
            <id>ossrh</id>
            <url>https://oss.sonatype.org/content/repositories/snapshots</url>
        </snapshotRepository>
    </distributionManagement>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>com.squareup</groupId>
                <artifactId>kotlinpoet</artifactId>
                <version>${kotlinpoet.version}</version>
            </dependency>
            <dependency>
                <groupId>org.jetbrains.kotlin</groupId>
                <artifactId>kotlin-stdlib</artifactId>
                <version>${kotlin.version}</version>
            </dependency>
            <dependency>
                <groupId>org.jetbrains.kotlin</groupId>
                <artifactId>kotlin-stdlib-jdk7</artifactId>
                <version>${kotlin.version}</version>
            </dependency>
            <dependency>
                <groupId>org.jetbrains.kotlin</groupId>
                <artifactId>kotlin-stdlib-jdk8</artifactId>
                <version>${kotlin.version}</version>
            </dependency>
            <dependency>
                <groupId>org.jetbrains.kotlin</groupId>
                <artifactId>kotlin-stdlib-common</artifactId>
                <version>${kotlin.version}</version>
            </dependency>
            <dependency>
                <groupId>org.jetbrains.kotlin</groupId>
                <artifactId>kotlin-compiler-embeddable</artifactId>
                <version>${kotlin.version}</version>
            </dependency>
            <dependency>
                <groupId>org.jetbrains.kotlinx</groupId>
                <artifactId>kotlinx-serialization-core</artifactId>
                <version>${kotlinx.serialization.version}</version>
            </dependency>
            <dependency>
                <groupId>org.jetbrains.kotlinx</groupId>
                <artifactId>kotlinx-serialization-core-jvm</artifactId>
                <version>${kotlinx.serialization.version}</version>
            </dependency>
            <dependency>
                <groupId>org.jetbrains.kotlinx</groupId>
                <artifactId>kotlinx-serialization-json</artifactId>
                <version>${kotlinx.serialization.version}</version>
            </dependency>
            <dependency>
                <groupId>org.jetbrains.kotlinx</groupId>
                <artifactId>kotlinx-serialization-json-jvm</artifactId>
                <version>${kotlinx.serialization.version}</version>
            </dependency>
            <dependency>
                <groupId>com.pinterest.ktlint</groupId>
                <artifactId>ktlint-core</artifactId>
                <version>${ktlint.version}</version>
                <exclusions>
                    <exclusion>
                        <groupId>ch.qos.logback</groupId>
                        <artifactId>logback-classic</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>
            <dependency>
                <groupId>com.pinterest.ktlint</groupId>
                <artifactId>ktlint-reporter-plain</artifactId>
                <version>${ktlint.version}</version>
            </dependency>
            <dependency>
                <groupId>com.pinterest.ktlint</groupId>
                <artifactId>ktlint-reporter-sarif</artifactId>
                <version>${ktlint.version}</version>
            </dependency>
            <dependency>
                <groupId>com.pinterest.ktlint</groupId>
                <artifactId>ktlint-reporter-json</artifactId>
                <version>${ktlint.version}</version>
            </dependency>
            <dependency>
                <groupId>com.pinterest.ktlint</groupId>
                <artifactId>ktlint-reporter-html</artifactId>
                <version>${ktlint.version}</version>
            </dependency>
            <dependency>
                <groupId>com.pinterest.ktlint</groupId>
                <artifactId>ktlint-reporter-baseline</artifactId>
                <version>${ktlint.version}</version>
            </dependency>
            <dependency>
                <groupId>com.charleskorn.kaml</groupId>
                <artifactId>kaml-jvm</artifactId>
                <version>0.47.0</version>
            </dependency>
            <dependency>
                <groupId>com.google.guava</groupId>
                <artifactId>guava</artifactId>
                <version>${guava.version}</version>
            </dependency>
            <dependency>
                <groupId>commons-cli</groupId>
                <artifactId>commons-cli</artifactId>
                <version>${commons-cli.version}</version>
            </dependency>
            <dependency>
                <groupId>commons-io</groupId>
                <artifactId>commons-io</artifactId>
                <version>2.11.0</version>
            </dependency>
            <dependency>
                <groupId>commons-configuration</groupId>
                <artifactId>commons-configuration</artifactId>
                <version>1.10</version>
            </dependency>
            <dependency>
                <groupId>io.github.microutils</groupId>
                <artifactId>kotlin-logging-jvm</artifactId>
                <version>${mu-logging.version}</version>
            </dependency>
            <dependency>
                <groupId>org.apache.logging.log4j</groupId>
                <artifactId>log4j-slf4j-impl</artifactId>
                <version>${log4j.version}</version>
            </dependency>
            <dependency>
                <groupId>io.github.petertrr</groupId>
                <artifactId>kotlin-multiplatform-diff-jvm</artifactId>
                <version>0.4.0</version>
            </dependency>
            <dependency>
                <groupId>org.junit.jupiter</groupId>
                <artifactId>junit-jupiter</artifactId>
                <version>${junit.version}</version>
            </dependency>
            <dependency>
                <groupId>org.junit.platform</groupId>
                <artifactId>junit-platform-suite-engine</artifactId>
                <version>${junit.platform.version}</version>
            </dependency>
            <dependency>
                <groupId>org.assertj</groupId>
                <artifactId>assertj-core</artifactId>
                <version>3.23.1</version>
            </dependency>
            <dependency>
                <groupId>org.mockito</groupId>
                <artifactId>mockito-all</artifactId>
                <version>1.10.19</version>
                <scope>test</scope>
            </dependency>
            <!-- is used for simplifying boolean expressions-->
            <dependency>
                <groupId>com.bpodgursky</groupId>
                <artifactId>jbool_expressions</artifactId>
                <version>${jbool.version}</version>
            </dependency>
        </dependencies>

    </dependencyManagement>

    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-clean-plugin</artifactId>
                    <version>3.2.0</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.10.1</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-deploy-plugin</artifactId>
                    <version>3.0.0</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-jar-plugin</artifactId>
                    <version>3.3.0</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-assembly-plugin</artifactId>
                    <version>3.4.2</version>
                    <configuration>
                        <archive>
                            <manifestEntries>
                                <Multi-Release>true</Multi-Release>
                            </manifestEntries>
                        </archive>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <version>3.0.0-M7</version>
                    <dependencies>
                        <dependency>
                            <groupId>me.fabriciorby</groupId>
                            <artifactId>maven-surefire-junit5-tree-reporter</artifactId>
                            <version>${surefire.junit5.tree-reporter.version}</version>
                        </dependency>
                    </dependencies>
                    <configuration>
                        <statelessTestsetReporter implementation="org.apache.maven.plugin.surefire.extensions.junit5.JUnit5Xml30StatelessReporter">
                            <!-- Prefer @DisplayName & friends, if any. -->
                            <usePhrasedFileName>true</usePhrasedFileName>
                            <usePhrasedTestCaseClassName>true</usePhrasedTestCaseClassName>
                            <usePhrasedTestCaseMethodName>true</usePhrasedTestCaseMethodName>
                            <usePhrasedTestSuiteClassName>true</usePhrasedTestSuiteClassName>
                        </statelessTestsetReporter>
                        <!-- For the console output, use the tree reporter from
                             https://github.com/fabriciorby/maven-surefire-junit5-tree-reporter. -->
                        <reportFormat>plain</reportFormat>
                        <consoleOutputReporter>
                            <disable>true</disable>
                        </consoleOutputReporter>
                        <statelessTestsetInfoReporter implementation="org.apache.maven.plugin.surefire.extensions.junit5.JUnit5StatelessTestsetInfoTreeReporter">
                            <!-- Prefer @DisplayName & friends, if any. -->
                            <usePhrasedFileName>true</usePhrasedFileName>
                            <usePhrasedClassNameInRunning>true</usePhrasedClassNameInRunning>
                            <!-- Avoid null's in *.txt summary -->
                            <usePhrasedClassNameInTestCaseSummary>false</usePhrasedClassNameInTestCaseSummary>
                        </statelessTestsetInfoReporter>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-plugin-plugin</artifactId>
                    <version>${maven-plugin-tools.version}</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-failsafe-plugin</artifactId>
                    <version>3.0.0-M7</version>
                    <dependencies>
                        <dependency>
                            <groupId>me.fabriciorby</groupId>
                            <artifactId>maven-surefire-junit5-tree-reporter</artifactId>
                            <version>${surefire.junit5.tree-reporter.version}</version>
                        </dependency>
                    </dependencies>
                    <configuration>
                        <statelessTestsetReporter implementation="org.apache.maven.plugin.surefire.extensions.junit5.JUnit5Xml30StatelessReporter">
                            <!-- Prefer @DisplayName & friends, if any. -->
                            <usePhrasedFileName>true</usePhrasedFileName>
                            <usePhrasedTestCaseClassName>true</usePhrasedTestCaseClassName>
                            <usePhrasedTestCaseMethodName>true</usePhrasedTestCaseMethodName>
                            <usePhrasedTestSuiteClassName>true</usePhrasedTestSuiteClassName>
                        </statelessTestsetReporter>
                        <!-- For the console output, use the tree reporter from
                             https://github.com/fabriciorby/maven-surefire-junit5-tree-reporter. -->
                        <reportFormat>plain</reportFormat>
                        <!-- For the Failsafe plug-in, don't disable
                             the consoleOutputReporter so that important logging
                             is not hidden. -->
                        <consoleOutputReporter>
                            <disable>false</disable>
                        </consoleOutputReporter>
                        <statelessTestsetInfoReporter implementation="org.apache.maven.plugin.surefire.extensions.junit5.JUnit5StatelessTestsetInfoTreeReporter">
                            <!-- Prefer @DisplayName & friends, if any. -->
                            <usePhrasedFileName>true</usePhrasedFileName>
                            <usePhrasedClassNameInRunning>true</usePhrasedClassNameInRunning>
                            <!-- Avoid null's in *.txt summary -->
                            <usePhrasedClassNameInTestCaseSummary>false</usePhrasedClassNameInTestCaseSummary>
                        </statelessTestsetInfoReporter>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>versions-maven-plugin</artifactId>
                    <version>2.13.0</version>
                    <configuration>
                        <generateBackupPoms>false</generateBackupPoms>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>build-helper-maven-plugin</artifactId>
                    <version>3.3.0</version>
                </plugin>
                <plugin>
                    <groupId>org.jetbrains.kotlin</groupId>
                    <artifactId>kotlin-maven-plugin</artifactId>
                    <version>${kotlin.version}</version>
                    <configuration>
                        <jvmTarget>1.8</jvmTarget>
                        <sourceDirs>
                            <source>src/main/kotlin</source>
                            <source>src/main/resources</source>
                        </sourceDirs>
                        <args>
                            <arg>-Werror</arg>
                            <arg>-opt-in=kotlin.RequiresOptIn</arg>
                        </args>
                    </configuration>
                    <inherited>true</inherited>
                </plugin>
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>exec-maven-plugin</artifactId>
                    <version>3.1.0</version>
                </plugin>
                <plugin>
                    <groupId>org.jacoco</groupId>
                    <artifactId>jacoco-maven-plugin</artifactId>
                    <version>${jacoco.version}</version>
                </plugin>
            </plugins>
        </pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>versions-maven-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>com.rudikershaw.gitbuildhook</groupId>
                <artifactId>git-build-hook-maven-plugin</artifactId>
                <version>3.3.0</version>
                <configuration>
                    <installHooks>
                        <!-- The location of a git hook to install into the default hooks directory. -->
                        <pre-commit>.git-hooks/pre-commit.sh</pre-commit>
                        <commit-msg>.git-hooks/commit-msg.sh</commit-msg>
                    </installHooks>
                </configuration>
                <inherited>false</inherited>
                <executions>
                    <execution>
                        <id>install-git-hooks</id>
                        <phase>initialize</phase>
                        <goals>
                            <!-- Install specific hooks directly to the default hooks directory. -->
                            <goal>install</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <!-- ========= CI/CD tools========== -->

            <plugin>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>3.3.0</version>
                <executions>
                    <execution>
                        <id>detekt</id>
                        <phase>none</phase>
                        <goals>
                            <goal>build-classpath</goal>
                        </goals>
                        <configuration>
                            <outputProperty>maven.compile.classpath</outputProperty>
                            <pathSeparator>${path.separator}</pathSeparator>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>com.github.ozsie</groupId>
                <artifactId>detekt-maven-plugin</artifactId>
                <version>${detekt.version}</version>
                <executions>
                    <execution>
                        <id>detekt</id>
                        <phase>none</phase>
                        <goals>
                            <goal>check</goal>
                        </goals>
                        <configuration>
                            <config>detekt-config.yml</config>
                            <buildUponDefaultConfig>true</buildUponDefaultConfig>
                            <classPath>${maven.compile.classpath}</classPath>
                            <jvmTarget>1.8</jvmTarget>
                            <excludes>**/resources/**/*.kt,**/resources/**/*.kts</excludes>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.cqfn.diktat</groupId>
                <artifactId>diktat-maven-plugin</artifactId>
                <version>${diktat-check.version}</version>
                <executions>
                    <execution>
                        <id>diktat</id>
                        <phase>none</phase>
                        <goals>
                            <goal>check</goal>
                            <goal>fix</goal>
                        </goals>
                        <configuration>
                            <inputs>
                                <input>${project.basedir}/src/main/kotlin</input>
                                <input>${project.basedir}/src/test/kotlin</input>
                            </inputs>
                            <excludes>
                                <exclude>${project.basedir}/src/main/kotlin/generated</exclude>
                            </excludes>
                            <diktatConfigFile>diktat-analysis.yml</diktatConfigFile>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <configuration>
                    <excludes>
                        <exclude>**/generation/**</exclude>
                    </excludes>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>prepare-agent</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>report</id>
                        <phase>test</phase>
                        <goals>
                            <goal>report</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>release</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>build-helper-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <!-- Add kotlin sources -->
                                <phase>generate-sources</phase>
                                <goals>
                                    <goal>add-source</goal>
                                </goals>
                                <configuration>
                                    <sources>
                                        <source>src/main/kotlin</source>
                                    </sources>
                                </configuration>
                            </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</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.jetbrains.dokka</groupId>
                        <artifactId>dokka-maven-plugin</artifactId>
                        <version>${dokka.version}</version>
                        <executions>
                            <execution>
                                <phase>package</phase>
                                <goals>
                                    <goal>javadocJar</goal>
                                </goals>
                            </execution>
                        </executions>
                        <configuration>
                            <sourceDirectories>
                                <dir>${project.basedir}/src/main/kotlin</dir>
                            </sourceDirectories>
                            <dokkaPlugins>
                                <plugin>
                                    <groupId>org.jetbrains.dokka</groupId>
                                    <artifactId>kotlin-as-java-plugin</artifactId>
                                    <version>${dokka.version}</version>
                                </plugin>
                            </dokkaPlugins>
                        </configuration>
                    </plugin>
                    <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>
                            </execution>
                        </executions>
                        <configuration>
                            <!-- This is needed to use passphrase from settings.xml or environment -->
                            <gpgArguments>
                                <arg>--pinentry-mode</arg>
                                <arg>loopback</arg>
                            </gpgArguments>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>org.sonatype.plugins</groupId>
                        <artifactId>nexus-staging-maven-plugin</artifactId>
                        <version>1.6.8</version>
                        <extensions>true</extensions>
                        <configuration>
                            <serverId>ossrh</serverId>
                            <nexusUrl>https://oss.sonatype.org/</nexusUrl>
                            <autoReleaseAfterClose>true</autoReleaseAfterClose>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>jdk11</id>
            <activation>
                <jdk>[11,</jdk>
            </activation>
            <properties>
                <maven.compiler.release>8</maven.compiler.release>
            </properties>
        </profile>
    </profiles>
</project>
