<?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 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>io.github.atlascommunity</groupId>
    <artifactId>parent</artifactId>
    <version>3.1.0</version>
    <packaging>pom</packaging>
    <organization>
        <name>VK</name>
        <url>https://vk.company</url>
    </organization>
    <name>parent</name>
    <description>Parent POM.xml with most often used pre-configured features</description>
    <url>https://github.com/atlascommunity/parent</url>

    <licenses>
        <license>
            <name>The Apache Software License, Version 2.0</name>
            <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
        </license>
    </licenses>

    <developers>
        <developer>
            <name>Ivan Mashintsev</name>
            <email>mashintsev@gmail.com</email>
            <organization>VK</organization>
            <organizationUrl>https://vk.company</organizationUrl>
        </developer>
    </developers>

    <scm>
        <connection>scm:git:git://git@github.com:atlascommunity/parent.git</connection>
        <developerConnection>scm:git:ssh://git@github.com:atlascommunity/parent.git</developerConnection>
        <url>https://github.com/atlascommunity/parent/tree/main</url>
    </scm>

    <properties>
        <jira.version>8.20.4</jira.version>
        <amps.version>8.2.3</amps.version>
        <quick.reload.version>2.0.0</quick.reload.version>
        <atlassian.plugin.key>${project.groupId}.${project.artifactId}</atlassian.plugin.key>
        <revision>${git.closest.tag.name}.${git.commit.time}</revision>
        <javac.version>9+181-r4173-1</javac.version>
        <maven.compiler.source>${java.specification.version}</maven.compiler.source>
        <maven.compiler.target>${java.specification.version}</maven.compiler.target>
        <maven.build.timestamp.format>yyyy-MM-dd HH:mm</maven.build.timestamp.format>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <project.build.propertiesEncoding>UTF-8</project.build.propertiesEncoding>
        <cypress.command>test-dev</cypress.command>
        <commons.version>3.9.0</commons.version>
        <lombok.version>1.18.22</lombok.version>
    </properties>

    <dependencies>
        <!-- Jira core dependency, it's jira-api + some internal atlassian classes used in jira -->
        <dependency>
            <groupId>com.atlassian.jira</groupId>
            <artifactId>jira-core</artifactId>
            <scope>provided</scope>
            <exclusions>
                <exclusion>
                    <groupId>jndi</groupId>
                    <artifactId>jndi</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>jta</groupId>
                    <artifactId>jta</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <!-- Servlet API -->
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <!-- Active objects dependency needed for using atlassian active objects ORM-->
        <dependency>
            <groupId>com.atlassian.activeobjects</groupId>
            <artifactId>activeobjects-plugin</artifactId>
            <scope>provided</scope>
        </dependency>
        <!-- Atlassian spring scanner dependency, inside plugin used for DI via annotations like @Component, @Component-Import -->
        <dependency>
            <groupId>com.atlassian.plugin</groupId>
            <artifactId>atlassian-spring-scanner-annotation</artifactId>
            <scope>provided</scope>
        </dependency>
        <!-- Atlassian rest common dependency
        Inside plugins mostly used for it's JAX-RS annotations
         -->
        <dependency>
            <groupId>com.atlassian.plugins.rest</groupId>
            <artifactId>atlassian-rest-module</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>com.atlassian.templaterenderer</groupId>
            <artifactId>atlassian-template-renderer-api</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.jetbrains</groupId>
            <artifactId>annotations</artifactId>
            <version>23.0.0</version>
            <scope>compile</scope>
        </dependency>

        <!-- Lombok project dependency, inside plugins used for their usefull annotations like: @Getters/@Setters/@Slf4j etc-->
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>${lombok.version}</version>
            <scope>provided</scope>
        </dependency>
        <!-- Internal mail.ru dev team package, inside plugins usecases:
         1) RestExecutor for old plugins @deprecated only used in commons version < 2.0
         2) @Transactional annotation wrapping in a real jira transaction
         3) Rest exceptions mapping ?
        -->
        <dependency>
            <groupId>io.github.atlascommunity</groupId>
            <artifactId>commons</artifactId>
            <version>${commons.version}</version>
            <scope>provided</scope>
            <exclusions>
                <exclusion>
                    <artifactId>slf4j-api</artifactId>
                    <groupId>org.slf4j</groupId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>io.sentry</groupId>
            <artifactId>sentry</artifactId>
            <version>5.4.3</version>
        </dependency>
        <dependency>
            <groupId>com.konghq</groupId>
            <artifactId>unirest-java</artifactId>
            <version>3.11.12</version>
            <exclusions>
                <exclusion>
                    <groupId>org.apache.httpcomponents</groupId>
                    <artifactId>httpclient</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.apache.httpcomponents</groupId>
                    <artifactId>httpmime</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.apache.httpcomponents</groupId>
                    <artifactId>httpcore</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>com.google.code.gson</groupId>
                    <artifactId>gson</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>com.google.code.gson</groupId>
            <artifactId>gson</artifactId>
            <version>2.8.5</version>
        </dependency>

        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>io.swagger.core.v3</groupId>
            <artifactId>swagger-jaxrs2</artifactId>
            <version>2.1.13</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>io.swagger.core.v3</groupId>
            <artifactId>swagger-annotations</artifactId>
            <version>2.1.13</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>javax.ws.rs</groupId>
            <artifactId>javax.ws.rs-api</artifactId>
            <version>2.1</version>
            <scope>provided</scope>
        </dependency>
        <!-- Testing dependencies -->
        <!-- Junit 5 -->
        <!-- https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter -->
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-api</artifactId>
            <version>5.7.2</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-engine</artifactId>
            <version>5.7.2</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.vintage</groupId>
            <artifactId>junit-vintage-engine</artifactId>
            <version>5.7.2</version>
            <scope>test</scope>
        </dependency>
        <!-- Mockito -->
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-core</artifactId>
            <version>3.11.2</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.jira</groupId>
            <artifactId>jira-tests</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.google.truth</groupId>
            <artifactId>truth</artifactId>
            <version>1.1.3</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.google.truth.extensions</groupId>
            <artifactId>truth-java8-extension</artifactId>
            <version>1.1.3</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <resources>
            <resource>
                <directory>src/main/resources/</directory>
                <includes>
                    <include>plugin.properties</include>
                    <include>openapi-configuration.yaml</include>
                </includes>
                <filtering>true</filtering>
            </resource>
            <resource>
                <directory>src/main/resources/</directory>
                <excludes>
                    <exclude>plugin.properties</exclude>
                    <exclude>openapi-configuration.yaml</exclude>
                </excludes>
                <filtering>false</filtering>
            </resource>
        </resources>

        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.10.1</version>
                <configuration>
                    <compilerArgs>
                        <arg>-XDcompilePolicy=simple</arg>
                        <arg>-Xplugin:ErrorProne -Xep:DeadException:WARN -Xep:GuardedBy:OFF -XepDisableWarningsInGeneratedCode -XepExcludedPaths:.*/target/generated-sources/.* -Xep:SameNameButDifferent:OFF -XepOpt:NullAway:AnnotatedPackages=ru.mail.jira -XepOpt:NullAway:CustomNullableAnnotations=org.jetbrains.annotations</arg>
                    </compilerArgs>
                    <failOnWarning>true</failOnWarning>
                    <annotationProcessorPaths>
                        <path>
                            <groupId>com.google.errorprone</groupId>
                            <artifactId>error_prone_core</artifactId>
                            <version>2.10.0</version>
                        </path>
                        <path>
                            <groupId>com.uber.nullaway</groupId>
                            <artifactId>nullaway</artifactId>
                            <version>0.9.6</version>
                        </path>
                        <path>
                            <groupId>org.projectlombok</groupId>
                            <artifactId>lombok</artifactId>
                            <version>${lombok.version}</version>
                        </path>
                    </annotationProcessorPaths>
                </configuration>
            </plugin>
            <plugin>
                <groupId>com.atlassian.maven.plugins</groupId>
                <artifactId>jira-maven-plugin</artifactId>
                <version>8.3.3</version>
                <extensions>true</extensions>
                <configuration>
                    <productVersion>${jira.version}</productVersion>
                    <productDataVersion>${jira.version}</productDataVersion>
                    <compressJs>false</compressJs>
                    <compressCss>false</compressCss>
                    <allowGoogleTracking>false</allowGoogleTracking>
                    <skipRestDocGeneration>true</skipRestDocGeneration>
                    <skipManifestValidation>false</skipManifestValidation>
                    <extractDependencies>false</extractDependencies>
                    <enablePde>false</enablePde>
                    <enableQuickReload>true</enableQuickReload>
                    <applications>
                        <application>
                            <applicationKey>jira-software</applicationKey>
                            <version>${jira.version}</version>
                        </application>
                    </applications>
                    <products>
                        <product>
                            <id>jira</id>
                            <instanceId>jira</instanceId>
                            <version>${jira.version}</version>
                        </product>
                    </products>
                    <instructions>
                        <Atlassian-Plugin-Key>${project.groupId}.${project.artifactId}</Atlassian-Plugin-Key>
                        <Atlassian-Scan-Folders>META-INF/plugin-descriptors</Atlassian-Scan-Folders>
                        <Spring-Context>*</Spring-Context>
                        <Require-Capability>
                            <![CDATA[osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=1.8))"]]>
                        </Require-Capability>
                        <Import-Package>
                            <!-- jira stuff -->
                            com.atlassian.jira.plugin.webfragment.contextproviders,
                            com.atlassian.jira.plugin.webfragment.conditions,
                            com.atlassian.jira.plugin.workflow,
                            com.atlassian.jira.issue.customfields.searchers,
                            com.atlassian.jira.jql.operand,
                            <!-- spring imports -->
                            org.springframework.aop,
                            org.springframework.core,
                            org.springframework.osgi.*;resolution:="optional",
                            com.atlassian.jira.*;resolution:="optional",
                            com.atlassian.event.*;resolution:="optional",
                            com.atlassian.templaterenderer.*;resolution:="optional",
                            com.atlassian.sal.*;resolution:="optional",
                            com.atlassian.activeobjects.*;resolution:="optional",
                            com.atlassian.security.*;resolution:="optional",
                            *;version="0";resolution:=optional,
                        </Import-Package>
                    </instructions>
                    <pluginArtifacts>
                        <pluginArtifact>
                            <groupId>com.atlassian.labs.plugins</groupId>
                            <artifactId>quickreload</artifactId>
                            <version>3.1.0</version>
                        </pluginArtifact>
                    </pluginArtifacts>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>3.3.0</version>
                <executions>
                    <execution>
                        <id>unpack-dependencies</id>
                        <phase>initialize</phase>
                        <goals>
                            <goal>unpack</goal>
                        </goals>
                        <configuration>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>io.github.atlascommunity</groupId>
                                    <artifactId>commons</artifactId>
                                    <version>${commons.version}</version>
                                    <outputDirectory>${project.build.directory}/classes</outputDirectory>
                                    <includes>**/*.class</includes>
                                </artifactItem>
                            </artifactItems>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <version>3.2.0</version>
                <configuration>
                    <propertiesEncoding>UTF-8</propertiesEncoding>
                </configuration>
            </plugin>
            <plugin>
                <groupId>com.atlassian.plugin</groupId>
                <artifactId>atlassian-spring-scanner-maven-plugin</artifactId>
                <version>2.2.5</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>atlassian-spring-scanner</goal>
                        </goals>
                        <phase>process-classes</phase>
                    </execution>
                </executions>
                <configuration>
                    <verbose>false</verbose>
                </configuration>
            </plugin>
            <plugin>
                <groupId>com.diffplug.spotless</groupId>
                <artifactId>spotless-maven-plugin</artifactId>
                <version>2.22.3</version>
                <configuration>
                    <!--          <ratchetFrom>master</ratchetFrom>-->
                    <java>
                        <includes>
                            <include>src/main/java/**/*.java</include>
                            <include>src/test/java/**/*.java</include>
                        </includes>

                        <importOrder/>
                        <removeUnusedImports/>
                        <googleJavaFormat/>

                        <licenseHeader>
                            <content>/* (C)$YEAR */</content>
                        </licenseHeader>
                    </java>
                </configuration>
                <executions>
                    <execution>
                        <id>spotless-check</id>
                        <phase>compile</phase>
                        <goals>
                            <goal>apply</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>3.0.0-M5</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-deploy-plugin</artifactId>
                <version>3.0.0-M1</version>
                <configuration>
                    <skip>true</skip>
                </configuration>
            </plugin>
            <plugin>
                <groupId>io.github.git-commit-id</groupId>
                <artifactId>git-commit-id-maven-plugin</artifactId>
                <version>4.9.9</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>revision</goal>
                        </goals>
                        <phase>initialize</phase>
                    </execution>
                </executions>
                <configuration>
                    <dateFormat>yyyyMMddHHmmss</dateFormat>
                    <dotGitDirectory>${project.basedir}/.git</dotGitDirectory>
                    <generateGitPropertiesFile>false</generateGitPropertiesFile>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.owasp</groupId>
                <artifactId>dependency-check-maven</artifactId>
                <version>7.1.0</version>
                <configuration>
                    <skipProvidedScope>true</skipProvidedScope>
                    <skipRuntimeScope>true</skipRuntimeScope>
                    <failBuildOnCVSS>8</failBuildOnCVSS>
                    <formats>junit,html</formats>
                    <prettyPrint>true</prettyPrint>
                    <yarnAuditAnalyzerEnabled>false</yarnAuditAnalyzerEnabled>
                    <nodeAnalyzerEnabled>false</nodeAnalyzerEnabled>
                    <retireJsAnalyzerEnabled>false</retireJsAnalyzerEnabled>
                    <nuspecAnalyzerEnabled>false</nuspecAnalyzerEnabled>
                    <assemblyAnalyzerEnabled>false</assemblyAnalyzerEnabled>
                    <scanSet>
                        <fileSets>
                            <directory>./</directory>
                        </fileSets>
                    </scanSet>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>docs</id>
            <build>
                <plugins>
                    <!-- for documentation generation purpose -->
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-javadoc-plugin</artifactId>
                        <version>3.2.0</version>
                        <configuration>
                            <sourceFileIncludes>
                                <include>
                                    **/*Service.java
                                </include>
                                <include>
                                    **/*Dto.java
                                </include>
                                <include>
                                    **/*Function.java
                                </include>
                            </sourceFileIncludes>
                            <doclet>io.github.atlascommunity.marklet.Marklet</doclet>
                            <docletArtifact>
                                <groupId>io.github.atlascommunity</groupId>
                                <artifactId>marklet</artifactId>
                                <version>1.2.2</version>
                            </docletArtifact>
                            <reportOutputDirectory>./</reportOutputDirectory>
                            <destDir>./</destDir>
                            <additionalOptions>
                                <additionalOption>-d</additionalOption>
                                <additionalOption>javadoc</additionalOption>
                            </additionalOptions>
                            <useStandardDocletOptions>false</useStandardDocletOptions>
                        </configuration>
                        <executions>
                            <execution>
                                <phase>package</phase>
                                <goals>
                                    <goal>javadoc</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>io.swagger.core.v3</groupId>
                        <artifactId>swagger-maven-plugin</artifactId>
                        <version>2.1.6</version>
                        <configuration>
                            <outputFileName>openapi</outputFileName>
                            <outputPath>${project.basedir}/swagger</outputPath>
                            <outputFormat>YAML</outputFormat>
                            <prettyPrint>true</prettyPrint>
                            <resourcePackages>ru.mail.jira.plugins</resourcePackages>
                            <openapiFilePath>${project.build.directory}/classes/openapi-configuration.yaml</openapiFilePath>
                            <sortOutput>true</sortOutput>
                        </configuration>
                        <executions>
                            <execution>
                                <phase>package</phase>
                                <goals>
                                    <goal>resolve</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>jdk8</id>
            <activation>
                <jdk>1.8</jdk>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-compiler-plugin</artifactId>
                        <configuration>
                            <fork>true</fork>
                            <showWarnings>true</showWarnings>
                            <compilerArgs combine.children="append">
                                <arg>
                                    -J-Xbootclasspath/p:${settings.localRepository}/com/google/errorprone/javac/${javac.version}/javac-${javac.version}.jar
                                </arg>
                                <arg>-Xplugin:ErrorProne -Xep:DeadException:WARN -Xep:GuardedBy:OFF -XepDisableWarningsInGeneratedCode -XepExcludedPaths:.*/target/generated-sources/.*  -Xep:SameNameButDifferent:OFF</arg>
                            </compilerArgs>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>publish</id>
            <build>
                <plugins>
                    <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>
                    </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>
                            <!-- Set this to true and the release will automatically proceed and sync to Central Repository will follow  -->
                            <autoReleaseAfterClose>true</autoReleaseAfterClose>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

    <repositories>
        <repository>
            <id>atlassian</id>
            <url>https://packages.atlassian.com/maven/repository/public</url>
        </repository>
    </repositories>

    <pluginRepositories>
        <pluginRepository>
            <id>atlassian</id>
            <url>https://packages.atlassian.com/maven/repository/public</url>
        </pluginRepository>
    </pluginRepositories>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>com.atlassian.jira</groupId>
                <artifactId>jira-project</artifactId>
                <version>${jira.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>
</project>
