<?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>0.1.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/cqfn/diktat.git</connection>
        <developerConnection>scm:git:ssh://github.com:cqfn/diktat.git</developerConnection>
        <url>http://github.com/cqfn/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>
        <kotlin.version>1.3.72</kotlin.version>
        <kotlin.compiler.incremental>true</kotlin.compiler.incremental>
        <ktlint.version>0.37.1</ktlint.version>
        <junit.version>5.7.0</junit.version>
        <guava.version>29.0-jre</guava.version>
        <jackson.version>2.11.3</jackson.version>
        <slf4j.version>1.7.30</slf4j.version>
        <commons-cli.version>1.4</commons-cli.version>
        <diktat-check.version>0.1.1</diktat-check.version>
        <kotlinpoet.version>1.6.0</kotlinpoet.version>
        <detekt.version>1.14.0</detekt.version>
        <dokka.version>1.4.10</dokka.version>
        <jacoco.version>0.8.6</jacoco.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>
    </modules>

    <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-compiler-embeddable</artifactId>
                <version>${kotlin.version}</version>
            </dependency>
            <dependency>
                <groupId>com.pinterest.ktlint</groupId>
                <artifactId>ktlint-core</artifactId>
                <version>${ktlint.version}</version>
            </dependency>
            <dependency>
                <groupId>com.google.guava</groupId>
                <artifactId>guava</artifactId>
                <version>${guava.version}</version>
            </dependency>
            <dependency>
                <groupId>com.fasterxml.jackson.core</groupId>
                <artifactId>jackson-core</artifactId>
                <version>${jackson.version}</version>
            </dependency>
            <dependency>
                <groupId>com.fasterxml.jackson.core</groupId>
                <artifactId>jackson-annotations</artifactId>
                <version>${jackson.version}</version>
            </dependency>
            <dependency>
                <groupId>com.fasterxml.jackson.dataformat</groupId>
                <artifactId>jackson-dataformat-yaml</artifactId>
                <version>${jackson.version}</version>
            </dependency>
            <dependency>
                <groupId>com.fasterxml.jackson.core</groupId>
                <artifactId>jackson-databind</artifactId>
                <version>${jackson.version}</version>
            </dependency>
            <dependency>
                <groupId>com.fasterxml.jackson.module</groupId>
                <artifactId>jackson-module-kotlin</artifactId>
                <version>${jackson.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.8.0</version>
            </dependency>
            <dependency>
                <groupId>commons-configuration</groupId>
                <artifactId>commons-configuration</artifactId>
                <version>1.10</version>
            </dependency>
            <dependency>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-api</artifactId>
                <version>${slf4j.version}</version>
            </dependency>
            <dependency>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-log4j12</artifactId>
                <version>${slf4j.version}</version>
            </dependency>
            <dependency>
                <groupId>io.github.java-diff-utils</groupId>
                <artifactId>java-diff-utils</artifactId>
                <version>4.8</version>
            </dependency>
            <dependency>
                <groupId>org.junit.jupiter</groupId>
                <artifactId>junit-jupiter</artifactId>
                <version>${junit.version}</version>
            </dependency>
            <dependency>
                <groupId>org.assertj</groupId>
                <artifactId>assertj-core</artifactId>
                <version>3.17.0</version>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <pluginRepositories>
        <pluginRepository>
            <!-- for dokka and probably other kotlin-related artifacts -->
            <id>jcenter</id>
            <name>JCenter</name>
            <url>https://jcenter.bintray.com/</url>
            <releases>
                <enabled>true</enabled>
            </releases>
        </pluginRepository>
    </pluginRepositories>

    <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-deploy-plugin</artifactId>
                    <version>3.0.0-M1</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-jar-plugin</artifactId>
                    <version>3.2.0</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-assembly-plugin</artifactId>
                    <version>3.3.0</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <version>3.0.0-M5</version>
                </plugin>
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>versions-maven-plugin</artifactId>
                    <version>2.8.1</version>
                    <configuration>
                        <generateBackupPoms>false</generateBackupPoms>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>build-helper-maven-plugin</artifactId>
                    <version>3.2.0</version>
                </plugin>
                <plugin>
                    <groupId>org.jetbrains.kotlin</groupId>
                    <artifactId>kotlin-maven-plugin</artifactId>
                    <version>${kotlin.version}</version>
                </plugin>
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>exec-maven-plugin</artifactId>
                    <version>3.0.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.0.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.1.2</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>
                            <classPath>${maven.compile.classpath}</classPath>
                            <languageVersion>1.3</languageVersion>
                            <jvmTarget>1.8</jvmTarget>
                            <excludes>**/resources/**/*.kt</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>
                            <debug>true</debug>
                            <inputs>
                                <input>${project.basedir}/src/main/kotlin</input>
                                <input>${project.basedir}/src/test/kotlin</input>
                            </inputs>
                            <diktatConfigFile>diktat-analysis.yml</diktatConfigFile>
                        </configuration>
                    </execution>
                    <execution>
                        <id>functional-test</id>
                        <phase>none</phase>
                        <goals>
                            <goal>check</goal>
                        </goals>
                        <configuration>
                            <inputs>
                                <input>${project.basedir}/src/test/resources/test/funcTest</input>
                            </inputs>
                            <diktatConfigFile>diktat-analysis.yml</diktatConfigFile>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <!-- todo: remove antrun completely after diktat-maven-plugin is released -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-antrun-plugin</artifactId>
                <version>3.0.0</version>
                <executions>
                    <execution>
                        <id>diktat</id>
                        <phase>none</phase>
                        <configuration>
                            <target name="ktlint">
                                <java taskname="ktlint" dir="${maven.multiModuleProjectDirectory}" fork="true"
                                      failonerror="true"
                                      classpathref="maven.plugin.classpath" classname="com.pinterest.ktlint.Main">
                                    <arg value="${project.basedir}/src/main/kotlin/**/*.kt"/>
                                    <arg value="${project.basedir}/src/test/kotlin/**/*.kt"/>
                                </java>
                            </target>
                        </configuration>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>functional-test</id>
                        <phase>none</phase>
                        <inherited>false</inherited>
                        <configuration>
                            <target name="ktlint">
                                <java taskname="ktlint" dir="${maven.multiModuleProjectDirectory}" fork="true"
                                      failonerror="true"
                                      classpathref="maven.plugin.classpath" classname="com.pinterest.ktlint.Main">
                                    <arg value="diktat-rules/src/test/resources/test/funcTest/*.kt"/>
                                </java>
                            </target>
                        </configuration>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </execution>
                </executions>
                <dependencies>
                    <dependency>
                        <groupId>com.pinterest</groupId>
                        <artifactId>ktlint</artifactId>
                        <version>${ktlint.version}</version>
                        <exclusions>
                            <exclusion>
                                <groupId>com.pinterest.ktlint</groupId>
                                <artifactId>ktlint-ruleset-standard</artifactId>
                            </exclusion>
                        </exclusions>
                    </dependency>
                    <dependency>
                        <groupId>org.cqfn.diktat</groupId>
                        <artifactId>diktat-rules</artifactId>
                        <version>${diktat-check.version}</version>
                    </dependency>
                </dependencies>
            </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.0</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>
                            <languageVersion>1.3</languageVersion>
                            <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>1.6</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>
    </profiles>
</project>
