<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>org.sonatype.oss</groupId>
        <artifactId>oss-parent</artifactId>
        <version>9</version>
    </parent>

    <groupId>com.antwerkz</groupId>
    <artifactId>antwerkz-parent</artifactId>
    <version>6</version>
    <packaging>pom</packaging>

    <name>antwerkz parent</name>
    <url>https://github.com/evanchooly/antwerkz-parent</url>

    <scm>
        <connection>scm:git:git@github.com:evanchooly/antwerkz-parent.git</connection>
        <developerConnection>scm:git:git@github.com:evanchooly/antwerkz-parent.git</developerConnection>
        <url>scm:git:git@github.com:evanchooly/antwerkz-parent.git</url>
    </scm>

    <properties>
        <dokka.version>1.8.10</dokka.version>
        <kotlin.compiler.jvmTarget>11</kotlin.compiler.jvmTarget>
        <kotlin.version>1.8.20</kotlin.version>
        <surefire.version>3.1.0</surefire.version>

        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <downloadSources>true</downloadSources>
        <nexus.url>https://oss.sonatype.org</nexus.url>
        <local.repository.path>${maven.multiModuleProjectDirectory}/target/localRepo</local.repository.path>
    </properties>

    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-jar-plugin</artifactId>
                    <version>3.3.0</version>
                    <configuration>
                        <archive>
                            <manifest>
                                <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
                                <addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
                            </manifest>
                        </archive>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.sonatype.plugins</groupId>
                    <artifactId>nexus-staging-maven-plugin</artifactId>
                    <version>1.6.13</version>
                    <configuration>
                        <serverId>central</serverId>
                        <nexusUrl>${nexus.url}</nexusUrl>
                        <autoReleaseAfterClose>true</autoReleaseAfterClose>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>com.github.spotbugs</groupId>
                    <artifactId>spotbugs-maven-plugin</artifactId>
                    <version>4.7.3.4</version>
                    <dependencies>
                        <dependency>
                            <groupId>com.github.spotbugs</groupId>
                            <artifactId>spotbugs</artifactId>
                            <version>4.7.3</version>
                            <type>pom</type>
                        </dependency>
                    </dependencies>
                    <executions>
                        <execution>
                            <id>spotbugs</id>
                            <goals>
                                <goal>check</goal>
                            </goals>
                            <phase>verify</phase>
                        </execution>
                    </executions>
                    <configuration>
                        <spotbugsXmlOutputDirectory>target/spotbugs</spotbugsXmlOutputDirectory>
                        <excludeFilterFile>${maven.multiModuleProjectDirectory}/config/findbugs-exclude.xml</excludeFilterFile>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>com.diffplug.spotless</groupId>
                    <artifactId>spotless-maven-plugin</artifactId>
                    <version>2.27.2</version>

                    <configuration>
                        <java>
                            <eclipse>
                                <file>${maven.multiModuleProjectDirectory}/config/eclipse-format.xml</file>
                            </eclipse>
                            <!--<googleJavaFormat />-->

                            <importOrder>
                                <file>${maven.multiModuleProjectDirectory}/config/eclipse.importorder</file>
                            </importOrder>

                            <removeUnusedImports/>
                        </java>
                        <kotlin>
                            <ktfmt>
                                <style>KOTLINLANG</style>
                                <!-- optional, other options are DEFAULT, DROPBOX, GOOGLE and KOTLINLANG -->
                            </ktfmt>
                        </kotlin>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <version>3.1.0</version>
                    <configuration>
                        <properties>
                            <failIfNoTests>true</failIfNoTests>
                        </properties>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-surefire-report-plugin</artifactId>
                    <version>${surefire.version}</version>
                    <configuration>
                        <alwaysGenerateSurefireReport>true</alwaysGenerateSurefireReport>
                    </configuration>
                    <executions>
                        <execution>
                            <phase>test</phase>
                        </execution>
                    </executions>
                </plugin>

                <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-site-plugin</artifactId>
                    <version>3.12.1</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-project-info-reports-plugin</artifactId>
                    <version>3.4.3</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-deploy-plugin</artifactId>
                    <version>3.1.1</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-javadoc-plugin</artifactId>
                    <version>3.5.0</version>
                </plugin>
            </plugins>
        </pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.sonatype.plugins</groupId>
                <artifactId>nexus-staging-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

    <distributionManagement>
        <snapshotRepository>
            <id>central</id>
            <url>${nexus.url}/content/repositories/snapshots</url>
        </snapshotRepository>
        <repository>
            <id>central</id>
            <url>${nexus.url}/service/local/staging/deploy/maven2/</url>
        </repository>
    </distributionManagement>

    <profiles>
        <profile>
            <id>code-audits</id>
            <activation>
                <property>
                    <name>code-audits</name>
                </property>
            </activation>
            <properties>
                <skipTests>true</skipTests>
            </properties>
            <build>
                <defaultGoal>verify</defaultGoal>
            </build>
        </profile>
        <profile>
            <id>publication</id>
            <activation>
                <property>
                    <name>release</name>
                </property>
            </activation>
            <properties>
                <skipTests>true</skipTests>
            </properties>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-enforcer-plugin</artifactId>
                        <version>3.3.0</version>
                        <executions>
                            <execution>
                                <id>enforce-environment-variable-is-set</id>
                                <goals>
                                    <goal>enforce</goal>
                                </goals>
                                <configuration>
                                    <rules>
                                        <requireEnvironmentVariable>
                                            <variableName>MAVEN_USERNAME</variableName>
                                        </requireEnvironmentVariable>
                                        <requireEnvironmentVariable>
                                            <variableName>MAVEN_CENTRAL_TOKEN</variableName>
                                        </requireEnvironmentVariable>
                                        <requireEnvironmentVariable>
                                            <variableName>MAVEN_GPG_PASSPHRASE</variableName>
                                        </requireEnvironmentVariable>
                                    </rules>
                                    <fail>true</fail>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>com.coderplus.maven.plugins</groupId>
                        <artifactId>copy-rename-maven-plugin</artifactId>
                        <version>1.0.1</version>
                        <executions>
                            <execution>
                                <id>copy-license-file</id>
                                <goals>
                                    <goal>copy</goal>
                                </goals>
                                <phase>generate-sources</phase>
                                <configuration>
                                    <sourceFile>${maven.multiModuleProjectDirectory}/LICENSE</sourceFile>
                                    <destinationFile>${project.build.outputDirectory}/META-INF/LICENSE-${project.artifactId}</destinationFile>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-javadoc-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>attach-javadocs</id>
                                <goals>
                                    <goal>jar</goal>
                                </goals>
                                <configuration>
                                    <attach>true</attach>
                                </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>
                                <configuration>
                                    <attach>true</attach>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>gpg</id>
            <activation>
                <property>
                    <name>release</name>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-gpg-plugin</artifactId>
                        <version>3.1.0</version>
                        <executions>
                            <execution>
                                <phase>verify</phase>
                                <goals>
                                    <goal>sign</goal>
                                </goals>
                                <configuration>
                                    <gpgArguments>
                                        <arg>--pinentry-mode</arg>
                                        <arg>loopback</arg>
                                    </gpgArguments>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>remote-deploy</id>
            <activation>
                <property>
                    <name>release</name>
                </property>
            </activation>
            <build>
                <defaultGoal>deploy</defaultGoal>
                <pluginManagement>
                    <plugins>
                        <plugin>
                            <groupId>org.sonatype.plugins</groupId>
                            <artifactId>nexus-staging-maven-plugin</artifactId>
                            <version>1.6.13</version>
                            <extensions>true</extensions>
                            <configuration>
                                <serverId>central</serverId>
                                <nexusUrl>${nexus.url}</nexusUrl>
                                <autoReleaseAfterClose>true</autoReleaseAfterClose>
                            </configuration>
                        </plugin>
                    </plugins>
                </pluginManagement>
            </build>
        </profile>
        <profile>
            <id>local-deploy</id>
            <activation>
                <activeByDefault>false</activeByDefault>
            </activation>
            <distributionManagement>
                <snapshotRepository>
                    <id>local-snapshot</id>
                    <url>file://${local.repository.path}/snapshot</url>
                </snapshotRepository>
                <repository>
                    <id>local-release</id>
                    <url>file://${local.repository.path}/release</url>
                </repository>
            </distributionManagement>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-clean-plugin</artifactId>
                        <version>3.2.0</version>
                        <inherited>false</inherited>
                        <configuration>
                            <filesets>
                                <fileset>
                                    <directory>${local.repository.path}</directory>
                                </fileset>
                            </filesets>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-antrun-plugin</artifactId>
                        <version>3.1.0</version>
                        <inherited>false</inherited>
                        <executions>
                            <execution>
                                <id>generate-repository-directories</id>
                                <phase>generate-sources</phase>
                                <configuration>
                                    <target>
                                        <mkdir dir="${local.repository.path}/snapshot"/>
                                        <mkdir dir="${local.repository.path}/release"/>
                                    </target>
                                </configuration>
                                <goals>
                                    <goal>run</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>java formatting</id>
            <activation>
                <property>
                    <name>!code-audits</name>
                </property>
                <file>
                    <exists>src/main/java</exists>
                </file>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>com.diffplug.spotless</groupId>
                        <artifactId>spotless-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <phase>process-sources</phase>
                                <goals>
                                    <goal>apply</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>check java formatting</id>
            <activation>
                <property>
                    <name>code-audits</name>
                </property>
                <file>
                    <exists>src/main/java</exists>
                </file>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>com.diffplug.spotless</groupId>
                        <artifactId>spotless-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <phase>process-sources</phase>
                                <goals>
                                    <goal>check</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <profile>
            <id>enable-kotlin</id>
            <activation>
                <file>
                    <exists>src/main/kotlin</exists>
                </file>
            </activation>
            <dependencies>
                <dependency>
                    <groupId>org.jetbrains.kotlin</groupId>
                    <artifactId>kotlin-stdlib</artifactId>
                    <version>${kotlin.version}</version>
                </dependency>
            </dependencies>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.jetbrains.kotlin</groupId>
                        <artifactId>kotlin-maven-plugin</artifactId>
                        <version>${kotlin.version}</version>
                        <executions>
                            <execution>
                                <id>compile</id>
                                <goals>
                                    <goal>compile</goal>
                                </goals>
                                <configuration>
                                    <sourceDirs>
                                        <sourceDir>${project.basedir}/src/main/java</sourceDir>
                                        <sourceDir>${project.basedir}/src/main/kotlin</sourceDir>
                                    </sourceDirs>
                                </configuration>
                            </execution>
                            <execution>
                                <id>test-compile</id>
                                <goals>
                                    <goal>test-compile</goal>
                                </goals>
                                <configuration>
                                    <sourceDirs>
                                        <sourceDir>${project.basedir}/src/test/java</sourceDir>
                                        <sourceDir>${project.basedir}/src/test/kotlin</sourceDir>
                                    </sourceDirs>
                                </configuration>
                            </execution>
                        </executions>
                        <configuration>
                            <jvmTarget>${kotlin.compiler.jvmTarget}</jvmTarget>
                            <javaParameters>true</javaParameters>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-compiler-plugin</artifactId>
                        <version>3.11.0</version>
                        <configuration>
                            <source>${kotlin.compiler.jvmTarget}</source>
                            <target>${kotlin.compiler.jvmTarget}</target>
                        </configuration>
                        <executions>
                            <!-- Replacing default-compile as it is treated specially by maven -->
                            <execution>
                                <id>default-compile</id>
                                <phase>none</phase>
                            </execution>
                            <!-- Replacing default-testCompile as it is treated specially by maven -->
                            <execution>
                                <id>default-testCompile</id>
                                <phase>none</phase>
                            </execution>
                            <execution>
                                <id>java-compile</id>
                                <phase>compile</phase>
                                <goals>
                                    <goal>compile</goal>
                                </goals>
                            </execution>
                            <execution>
                                <id>java-test-compile</id>
                                <phase>test-compile</phase>
                                <goals>
                                    <goal>testCompile</goal>
                                </goals>
                                <configuration>
                                    <skip>${maven.test.skip}</skip>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.jetbrains.dokka</groupId>
                        <artifactId>dokka-maven-plugin</artifactId>
                        <version>${dokka.version}</version>
                        <executions>
                            <execution>
                                <phase>prepare-package</phase>
                                <goals>
                                    <goal>dokka</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-jar-plugin</artifactId>
                        <version>3.3.0</version>
                        <executions>
                            <execution>
                                <phase>package</phase>
                                <goals>
                                    <goal>jar</goal>
                                </goals>
                                <configuration>
                                    <classifier>javadoc</classifier>
                                    <includes>
                                        <include>target/dokka</include>
                                    </includes>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>format-kotlin</id>
            <activation>
                <property>
                    <name>!code-audits</name>
                </property>
                <file>
                    <exists>src/main/kotlin</exists>
                </file>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>com.diffplug.spotless</groupId>
                        <artifactId>spotless-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>format-kotlin</id>
                                <phase>process-sources</phase>
                                <goals>
                                    <goal>apply</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>kotlin code checks</id>
            <activation>
                <property>
                    <name>code-audits</name>
                </property>
                <file>
                    <exists>src/main/kotlin</exists>
                </file>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>com.diffplug.spotless</groupId>
                        <artifactId>spotless-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>validate sources</id>
                                <phase>process-sources</phase>
                                <goals>
                                    <goal>check</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
