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

    <parent>
        <groupId>com.atlassian.bitbucket.server</groupId>
        <artifactId>bitbucket-plugins-parent</artifactId>
        <version>8.18.0</version>
    </parent>

    <artifactId>bitbucket-code-insights</artifactId>
    <packaging>atlassian-plugin</packaging>

    <name>Bitbucket Server - Code Insights</name>
    <description>
        This is an API for integrations to post and retrieve results from code analysis.
        This happens in the form of a 'report' which contains summary data about the analysis, and 'annotations' which are specific messages attached to lines in the code. Pull requests will display reports that have been created on the latest commit of the source branch and will show any annotations for these reports that are on lines that have been changed in the pull request.
    </description>

    <properties>
        <atlassian.plugin.key>${project.groupId}.${project.artifactId}</atlassian.plugin.key>
    </properties>

    <dependencies>
        <dependency>
            <groupId>io.swagger.core.v3</groupId>
            <artifactId>swagger-jaxrs2</artifactId>
            <scope>provided</scope>
        </dependency>

        <!-- Bitbucket dependencies -->
        <dependency>
            <groupId>com.atlassian.bitbucket.server</groupId>
            <artifactId>bitbucket-ao-common</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.bitbucket.server</groupId>
            <artifactId>bitbucket-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.bitbucket.server</groupId>
            <artifactId>bitbucket-code-insights-api</artifactId>
        </dependency>
        <dependency>
            <groupId>com.atlassian.bitbucket.server</groupId>
            <artifactId>bitbucket-code-insights-spi</artifactId>
        </dependency>
        <dependency>
            <groupId>com.atlassian.bitbucket.server</groupId>
            <artifactId>bitbucket-dmz-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.bitbucket.server</groupId>
            <artifactId>bitbucket-rest-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.bitbucket.server</groupId>
            <artifactId>bitbucket-rest-model</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.bitbucket.server</groupId>
            <artifactId>bitbucket-spi</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.bitbucket.server</groupId>
            <artifactId>bitbucket-util</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.bitbucket.server.swagger</groupId>
            <artifactId>annotations</artifactId>
            <scope>provided</scope>
        </dependency>

        <!-- Atlassian dependencies -->
        <dependency>
            <groupId>com.atlassian.activeobjects</groupId>
            <artifactId>activeobjects-plugin</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.cache</groupId>
            <artifactId>atlassian-cache-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.plugins</groupId>
            <artifactId>atlassian-plugins-core</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.plugins</groupId>
            <artifactId>atlassian-plugins-webresource</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.plugins.rest</groupId>
            <artifactId>atlassian-rest-common</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.scheduler</groupId>
            <artifactId>atlassian-scheduler-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.sal</groupId>
            <artifactId>sal-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.soy</groupId>
            <artifactId>soy-template-renderer-api</artifactId>
            <scope>provided</scope>
        </dependency>

        <!-- 3rd party dependencies -->
        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.sun.jersey</groupId>
            <artifactId>jersey-server</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.validation</groupId>
            <artifactId>validation-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.hibernate.validator</groupId>
            <artifactId>hibernate-validator</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-beans</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <scope>provided</scope>
        </dependency>

        <!-- Test dependencies -->
        <dependency>
            <groupId>com.atlassian.activeobjects</groupId>
            <artifactId>activeobjects-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.h2database</groupId>
            <artifactId>h2</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.bitbucket.server</groupId>
            <artifactId>bitbucket-test-util</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.cache</groupId>
            <artifactId>atlassian-cache-memory</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>jaxen</groupId>
            <artifactId>jaxen</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.hamcrest</groupId>
            <artifactId>hamcrest-library</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-core</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>com.atlassian.maven.plugins</groupId>
                <artifactId>bitbucket-maven-plugin</artifactId>
                <extensions>true</extensions>
                <configuration>
                    <!-- JS & CSS compression is handled by the frontend plugin / Gulp task -->
                    <compressJs>false</compressJs>
                    <compressCss>false</compressCss>
                    <extractDependencies>true</extractDependencies>
                    <instructions>
                        <Atlassian-Plugin-Key>${project.groupId}.${project.artifactId}</Atlassian-Plugin-Key>
                        <Export-Package>com.atlassian.bitbucket.codeinsights*</Export-Package>
                        <Import-Package>
                            *
                        </Import-Package>
                        <Private-Package>
                            com.atlassian.bitbucket.internal.codeinsights*
                        </Private-Package>
                        <Spring-Context>*</Spring-Context>
                    </instructions>
                    <enableDevToolbox>false</enableDevToolbox>
                    <enablePde>true</enablePde>
                    <enableQuickReload>true</enableQuickReload>
                    <quickReloadVersion>1.28</quickReloadVersion>
                </configuration>
            </plugin>
            <plugin>
                <groupId>com.github.eirslett</groupId>
                <artifactId>frontend-maven-plugin</artifactId>
                <configuration>
                    <workingDirectory>../../</workingDirectory>
                    <installDirectory>../../${fe.node.installdir}</installDirectory>
                </configuration>
                <executions>
                    <execution>
                        <id>gulp build</id>
                        <goals>
                            <goal>npm</goal>
                        </goals>
                        <phase>generate-resources</phase>
                        <configuration>
                            <arguments>run gulp plugin:code-insights:build</arguments>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>pmd</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-pmd-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>run pmd</id>
                                <goals>
                                    <goal>pmd</goal>
                                </goals>
                                <phase>verify</phase>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>release</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>com.atlassian.bitbucket.server.swagger</groupId>
                        <artifactId>swagger-maven-plugin</artifactId>
                        <version>${swagger-maven-plugin-version}</version>
                        <configuration>
                            <resourcePackages>
                                <resourcePackage>com.atlassian.bitbucket.internal.codeinsights.rest.commit</resourcePackage>
                            </resourcePackages>
                            <enrichers>
                                <enricher>com.atlassian.bitbucket.server.swagger.enricher.BitbucketEnricher</enricher>
                            </enrichers>
                            <outputDirectory>${project.build.directory}/site</outputDirectory>
                            <outputFilename>swagger</outputFilename>
                            <outputFormats>JSON,YAML</outputFormats>
                            <prettyPrint>true</prettyPrint>
                            <swaggerConfig>
                                <servers>
                                    <server>
                                        <url>/insights/latest</url>
                                        <description>Endpoint URL</description>
                                    </server>
                                </servers>
                                <info>
                                    <title>Code Insights REST API</title>
                                    <version>1.0.0</version>
                                </info>
                            </swaggerConfig>
                        </configuration>
                        <dependencies>
                            <dependency>
                                <groupId>com.atlassian.bitbucket.server.swagger</groupId>
                                <artifactId>processor</artifactId>
                                <version>${bitbucket-swagger-version}</version>
                            </dependency>
                        </dependencies>
                        <executions>
                            <execution>
                                <phase>compile</phase>
                                <goals>
                                    <goal>generate</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
