<?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.confluence.plugins</groupId>
        <artifactId>confluence-bundled-plugins</artifactId>
        <version>9.2.6</version>
    </parent>

    <artifactId>confluence-rest-resources</artifactId>
    <packaging>atlassian-plugin</packaging>

    <name>Confluence REST API Resources</name>
    <description>Expose the official Confluence API via REST.</description>

    <issueManagement>
        <system>Jira</system>
        <url>https://jira.atlassian.com/browse/CRA</url>
    </issueManagement>

    <properties>
        <enforcer.fail>false</enforcer.fail>
        <spotbugs.excludes>src/etc/findbugs-excludes.xml</spotbugs.excludes>
    </properties>

    <dependencies>
        <dependency>
            <groupId>com.atlassian.webhooks</groupId>
            <artifactId>atlassian-webhooks-rest</artifactId>
        </dependency>
        <dependency>
            <groupId>com.atlassian.plugins</groupId>
            <artifactId>atlassian-plugins-osgi-javaconfig</artifactId>
            <version>${atlassian.osgi.javaconfig.version}</version>
        </dependency>
        <dependency>
            <groupId>com.atlassian.dc.swagger</groupId>
            <artifactId>annotations</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>io.swagger.core.v3</groupId>
                    <artifactId>swagger-jaxrs2</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>io.swagger.core.v3</groupId>
            <artifactId>swagger-annotations</artifactId>
        </dependency>
        <dependency>
            <groupId>com.atlassian.confluence</groupId>
            <artifactId>confluence-private-api</artifactId>
            <version>${project.version}</version>
            <scope>provided</scope>
        </dependency>
        <!-- this plugin provides the serialization services from confluence-rest-serialization -->
        <dependency>
            <groupId>com.atlassian.confluence</groupId>
            <artifactId>confluence-rest-serialization-jackson2</artifactId>
            <version>${project.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>jakarta.inject</groupId>
            <artifactId>jakarta.inject-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.fugue</groupId>
            <artifactId>fugue</artifactId>
            <scope>provided</scope>
        </dependency>
        <!-- Exports shared jersey filters etc -->
        <dependency>
            <groupId>com.atlassian.confluence.plugins</groupId>
            <artifactId>confluence-rest-jersey-jackson2</artifactId>
            <version>${project.version}</version>
            <scope>provided</scope>
        </dependency>
        <!-- At runtime we import its navigation service -->
        <dependency>
            <groupId>com.atlassian.confluence.plugins</groupId>
            <artifactId>confluence-rest-navigation-v2</artifactId>
            <version>${project.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>jakarta.servlet</groupId>
            <artifactId>jakarta.servlet-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.plugins</groupId>
            <artifactId>atlassian-plugins-osgi</artifactId>
            <scope>provided</scope>
        </dependency>
        <!-- Bundle the atlassian-webhooks-rest classes in this module. The module contains a base implementation
             for a webhook resource, including REST representations of key webhook entities. There's also a dependency
             on atlassian-webhooks-api, but this should _not_ be bundled as these classes should be made available
             in OSGI by atlassian-webhooks-plugin.
        -->
        <dependency>
            <groupId>com.atlassian.webhooks</groupId>
            <artifactId>atlassian-webhooks-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-core</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.datatype</groupId>
            <artifactId>jackson-datatype-jsr310</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>jakarta.annotation</groupId>
            <artifactId>jakarta.annotation-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.confluence</groupId>
            <artifactId>confluence-java-api</artifactId>
            <version>${project.version}</version>
            <scope>provided</scope>
            <exclusions>
                <exclusion>
                    <groupId>com.fasterxml.jackson.core</groupId>
                    <artifactId>jackson-annotations</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>com.fasterxml.jackson.core</groupId>
                    <artifactId>jackson-core</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>com.fasterxml.jackson.core</groupId>
                    <artifactId>jackson-databind</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.codehaus.jackson</groupId>
                    <artifactId>jackson-core-asl</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.codehaus.jackson</groupId>
                    <artifactId>jackson-mapper-asl</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>com.atlassian.confluence</groupId>
            <artifactId>confluence-rest-v2-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.graphql</groupId>
            <artifactId>atlassian-dc-graphql</artifactId>
            <scope>provided</scope>
        </dependency>

        <!-- CONFDEV-38121 : This is needed for docgen to build properly, as it contains the sun jersey classes needed -->
        <dependency>
            <groupId>com.atlassian.plugins.rest</groupId>
            <artifactId>atlassian-rest-v2-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.plugins.rest</groupId>
            <artifactId>atlassian-rest-v2-internal-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>jakarta.ws.rs</groupId>
            <artifactId>jakarta.ws.rs-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.core</groupId>
            <artifactId>atlassian-core</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.analytics</groupId>
            <artifactId>analytics-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>joda-time</groupId>
            <artifactId>joda-time</artifactId>
            <scope>provided</scope>
        </dependency>
        <!-- for doc generation only -->
        <dependency>
            <groupId>com.atlassian.confluence.plugins</groupId>
            <artifactId>confluence-rest-enrichment</artifactId>
            <version>${project.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>commons-codec</groupId>
            <artifactId>commons-codec</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.soy</groupId>
            <artifactId>soy-template-renderer-api</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>com.atlassian.plugin</groupId>
            <artifactId>atlassian-spring-scanner-annotation</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.annotations</groupId>
            <artifactId>atlassian-annotations</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.osgi</groupId>
            <artifactId>osgi.core</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.event</groupId>
            <artifactId>atlassian-event</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>com.atlassian.graphql</groupId>
            <artifactId>atlassian-dc-graphql-annotations</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.graphql-java</groupId>
            <artifactId>graphql-java</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>commons-fileupload</groupId>
            <artifactId>commons-fileupload</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.assertj</groupId>
            <artifactId>assertj-core</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.glassfish.jersey.core</groupId>
            <artifactId>jersey-server</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>com.atlassian.soy</groupId>
            <artifactId>atlassian-soy-core</artifactId>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>javax.inject</groupId>
                    <artifactId>javax.inject</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.github.stefanbirkner</groupId>
            <artifactId>system-rules</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.confluence</groupId>
            <artifactId>confluence-testutils</artifactId>
            <version>${project.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-slf4j2-impl</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>com.atlassian.plugin</groupId>
                <artifactId>atlassian-spring-scanner-maven-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>com.atlassian.maven.plugins</groupId>
                <artifactId>confluence-maven-plugin</artifactId>
                <extensions>true</extensions>
                <configuration>
                    <instructions>
                        <Atlassian-Plugin-Key>${project.groupId}.${project.artifactId}</Atlassian-Plugin-Key>
                        <Spring-Context>*</Spring-Context>
                        <Import-Package>
                            com.atlassian.plugin.osgi.bridge.external,
                            !com.atlassian.confluence.plugins.restapi.enrich.documentation,
                            <!-- excluded, build-time only -->
                            !com.atlassian.confluence.plugins.rest.navigation.v2.impl,
                            <!-- excluded: used in StaticEnricherFilter, build-time only -->
                            <!--com.atlassian.confluence.plugins.rest.jersey.jackson2.cachecontrol, -->
                            <!-- PreventCachingResourceFilterFactory -->
                            com.atlassian.confluence.plugins.restapi.enrich,
                            com.atlassian.confluence.api.model.*,
                            com.atlassian.confluence.api.nav,
                            com.atlassian.confluence.rest.v2.api.graphql,
                            com.atlassian.webhooks;resolution:=optional,
                            com.atlassian.webhooks.diagnostics;resolution:=optional,
                            com.atlassian.webhooks.history;resolution:=optional,
                            com.atlassian.webhooks.request;resolution:=optional,
                            com.atlassian.webhooks.util;resolution:=optional,
                            com.atlassian.confluence.rest.v2.api*,
                            com.atlassian.confluence.rest.serialization.jackson2*,
                            javax.ws.rs*;version="[2.0.0,3.0.0)",
                            com.fasterxml.jackson.annotation;version="${jackson2.atlassian-rest.osgi.version}",
                            com.fasterxml.jackson.core.*;version="${jackson2.atlassian-rest.osgi.version}",
                            com.fasterxml.jackson.databind.*;version="${jackson2.atlassian-rest.osgi.version}",
                            *
                        </Import-Package>
                        <Export-package>com.atlassian.confluence.plugins.restapi.annotations</Export-package>
                    </instructions>
                    <skipManifestValidation>true</skipManifestValidation>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <excludes>
                        <exclude>it/**</exclude>
                        <exclude>**/*$*</exclude>
                    </excludes>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-enforcer-plugin</artifactId>
                <executions>
                    <execution>
                        <id>banned_dependencies</id>
                        <goals>
                            <goal>enforce</goal>
                        </goals>
                        <phase>validate</phase>
                        <configuration>
                            <rules>
                                <bannedDependencies>
                                    <searchTransitive>true</searchTransitive>
                                    <message>Do not depend on confluence core from confluence-rest-resources.
                                        All access to information in core should be via services in
                                        com.atlassian.confluence.api.service.</message>
                                    <excludes>
                                        <exclude>com.atlassian.confluence:confluence</exclude>
                                    </excludes>
                                </bannedDependencies>
                            </rules>
                            <fail>true</fail>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <!-- This makes generates javadoc when you run mvn clean generate-resources -Prestdoc. -->
            <id>restdoc</id>
            <dependencies>
                <dependency>
                    <groupId>com.atlassian.dc.swagger</groupId>
                    <artifactId>processor</artifactId>
                    <version>${swagger.dc.version}</version>
                    <scope>provided</scope>
                    <exclusions>
                        <exclusion>
                            <groupId>com.google.code.findbugs</groupId>
                            <artifactId>jsr305</artifactId>
                        </exclusion>
                    </exclusions>
                </dependency>
                <dependency>
                    <groupId>com.atlassian.confluence</groupId>
                    <artifactId>confluence-swagger-enrichers</artifactId>
                    <version>${project.version}</version>
                    <scope>provided</scope>
                </dependency>
            </dependencies>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-compiler-plugin</artifactId>
                        <executions>
                            <execution>
                                <goals>
                                    <goal>compile</goal>
                                </goals>
                                <phase>generate-sources</phase>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <artifactId>maven-resources-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>01-copy-docs-to-builddir</id>
                                <goals>
                                    <goal>copy-resources</goal>
                                </goals>
                                <phase>generate-sources</phase>
                                <configuration>
                                    <outputDirectory>${project.build.outputDirectory}</outputDirectory>
                                    <resources>
                                        <resource>
                                            <directory>src/main/doc</directory>
                                            <includes>
                                                <include>*.xml</include>
                                            </includes>
                                        </resource>
                                    </resources>
                                </configuration>
                            </execution>
                            <execution>
                                <id>copy-standard-resources</id>
                                <goals>
                                    <goal>copy-resources</goal>
                                </goals>
                                <phase>generate-sources</phase>
                                <configuration>
                                    <outputDirectory>${project.build.outputDirectory}</outputDirectory>
                                    <resources>
                                        <resource>
                                            <directory>src/main/resources</directory>
                                            <filtering>true</filtering>
                                            <includes>
                                                <include>atlassian-plugin.xml</include>
                                            </includes>
                                        </resource>
                                        <resource>
                                            <directory>src/main/resources</directory>
                                            <excludes>
                                                <exclude>atlassian-plugin.xml</exclude>
                                            </excludes>
                                        </resource>
                                    </resources>
                                </configuration>
                            </execution>
                            <execution>
                                <id>copy-xsl-resources</id>
                                <goals>
                                    <goal>copy-resources</goal>
                                </goals>
                                <phase>generate-sources</phase>
                                <configuration>
                                    <outputDirectory>target/${project.version}</outputDirectory>
                                    <resources>
                                        <resource>
                                            <directory>${basedir}/src/main/doc/static/</directory>
                                            <filtering>true</filtering>
                                            <excludes>
                                                <exclude>static/**</exclude>
                                            </excludes>
                                        </resource>
                                    </resources>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>io.swagger.core.v3</groupId>
                        <artifactId>swagger-maven-plugin</artifactId>
                        <version>${swagger.version}</version>
                        <configuration>
                            <resourcePackages>
                                <resourcePackage>com.atlassian.confluence.plugins.restapi.resources</resourcePackage>
                            </resourcePackages>
                            <scannerClass>com.atlassian.confluence.swagger.enricher.ConfluenceEnricher</scannerClass>
                            <outputPath>${project.build.directory}/site</outputPath>
                            <outputFileName>swagger</outputFileName>
                            <outputFormat>JSONANDYAML</outputFormat>
                            <prettyPrint>true</prettyPrint>
                            <openapiFilePath>${project.basedir}/src/main/resources/swagger-config.yaml</openapiFilePath>
                        </configuration>
                        <executions>
                            <execution>
                                <goals>
                                    <goal>resolve</goal>
                                </goals>
                                <phase>compile</phase>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>properties-maven-plugin</artifactId>
                        <version>1.0.0</version>
                        <configuration>
                            <properties>
                                <!-- Tell AtlassianWadlGeneratorResourceDocSupport to load atlassian-plugin.xml files from classpath -->
                                <atlassian-plugin.xml.path>path/not/found</atlassian-plugin.xml.path>
                            </properties>
                            <outputFile />
                        </configuration>
                        <dependencies>
                            <dependency>
                                <groupId>javax.xml.bind</groupId>
                                <artifactId>jaxb-api</artifactId>
                                <version>${jaxb.version}</version>
                            </dependency>
                            <dependency>
                                <groupId>org.glassfish.jaxb</groupId>
                                <artifactId>jaxb-runtime</artifactId>
                                <version>${jaxb.version}</version>
                            </dependency>
                        </dependencies>
                        <executions>
                            <execution>
                                <id>02-set-system-properties</id>
                                <goals>
                                    <goal>set-system-properties</goal>
                                </goals>
                                <phase>process-sources</phase>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>xml-maven-plugin</artifactId>
                        <dependencies>
                            <dependency>
                                <groupId>net.sf.saxon</groupId>
                                <artifactId>saxon</artifactId>
                                <version>8.7</version>
                            </dependency>
                        </dependencies>
                        <executions>
                            <execution>
                                <id>04-xsl transform target/application.html</id>
                                <goals>
                                    <goal>transform</goal>
                                </goals>
                                <phase>process-sources</phase>
                                <configuration>
                                    <transformationSets>
                                        <transformationSet>
                                            <dir>target/classes</dir>
                                            <includes>
                                                <include>application.wadl</include>
                                            </includes>
                                            <stylesheet>src/main/doc/wadl-documentation.xsl</stylesheet>
                                            <outputDir>target/${project.version}</outputDir>
                                            <fileMappers>
                                                <fileMapper implementation="org.codehaus.plexus.components.io.filemappers.RegExpFileMapper">
                                                    <pattern>application.wadl</pattern>
                                                    <replacement>index.html</replacement>
                                                </fileMapper>
                                            </fileMappers>
                                        </transformationSet>
                                    </transformationSets>
                                    <!-- the XSL above requires EXSLT node-set support, which xalan doesn't provide? -->
                                    <transformerFactory>net.sf.saxon.TransformerFactoryImpl</transformerFactory>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
