<?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>
    <artifactId>diktat-rules</artifactId>
    <name>diktat-rules</name>
    <description>The main diktat ruleset</description>

    <parent>
        <groupId>org.cqfn.diktat</groupId>
        <artifactId>diktat-parent</artifactId>
        <version>1.2.5</version>
    </parent>

    <dependencies>
        <dependency>
            <!-- kotlinpoet is needed only during build, but maven doesn't have such scope. -->
            <!-- If we ever move to gradle, it should be moved into a separate task. -->
            <!-- Also, we can't move it to test scope now, because Generation.kt has to be compiled before tests are compiled -->
            <groupId>com.squareup</groupId>
            <artifactId>kotlinpoet</artifactId>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.cqfn.diktat</groupId>
            <artifactId>diktat-common</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>org.cqfn.diktat</groupId>
            <artifactId>diktat-test-framework</artifactId>
            <version>${project.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.pinterest.ktlint</groupId>
            <artifactId>ktlint-core</artifactId>
        </dependency>
        <dependency>
            <groupId>org.jetbrains.kotlin</groupId>
            <artifactId>kotlin-stdlib-jdk8</artifactId>
        </dependency>
        <dependency>
            <!-- guava is used for string case utils -->
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
        </dependency>
        <dependency>
            <groupId>io.github.microutils</groupId>
            <artifactId>kotlin-logging-jvm</artifactId>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.platform</groupId>
            <artifactId>junit-platform-suite-engine</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.assertj</groupId>
            <artifactId>assertj-core</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-all</artifactId>
            <scope>test</scope>
        </dependency>
        <!-- is used for simplifying boolean expressions-->
        <dependency>
            <groupId>com.bpodgursky</groupId>
            <artifactId>jbool_expressions</artifactId>
        </dependency>
    </dependencies>

    <build>
        <sourceDirectory>${project.basedir}/src/main/kotlin</sourceDirectory>
        <testSourceDirectory>${project.basedir}/src/test/kotlin</testSourceDirectory>
        <plugins>
            <plugin>
                <groupId>org.jetbrains.kotlin</groupId>
                <artifactId>kotlin-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>build-generated-code</id>
                        <phase>process-test-sources</phase>
                        <goals>
                            <goal>compile</goal>
                        </goals>
                        <configuration>
                            <sourceDirs>
                                <source>${project.basedir}/src/main/kotlin/generated</source>
                            </sourceDirs>
                        </configuration>
                    </execution>
                    <execution>
                        <id>compile</id>
                        <phase>compile</phase>
                        <goals>
                            <goal>compile</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>test-compile</id>
                        <phase>process-test-sources</phase>
                        <goals>
                            <goal>test-compile</goal>
                        </goals>
                        <configuration>
                            <sourceDirs>
                                <!-- For some weird reason if main sourceset is removed from here, syntax highlighting in idea an ability to launch tests is broken -->
                                <source>src/main/kotlin</source>
                                <source>src/test/kotlin</source>
                                <source>${project.basedir}/src/main/kotlin</source>
                                <source>${project.basedir}/src/test/kotlin</source>
                            </sourceDirs>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>generate-warnings</id>
                        <phase>generate-test-sources</phase>
                        <goals>
                            <goal>java</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <mainClass>org.cqfn.diktat.ruleset.generation.GenerationKt</mainClass>
                    <arguments>
                        <argument>${project.build.sourceDirectory}</argument>
                        <argument>${project.basedir}/src/test/resources</argument>
                    </arguments>
                </configuration>
            </plugin>

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

</project>
