<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>
    <parent>
        <groupId>com.atlassian.jira</groupId>
        <artifactId>jira-plugins</artifactId>
        <version>9.1.0-m0003</version>
    </parent>
    <artifactId>jira-func-test-plugin</artifactId>
    <name>Atlassian Jira - Plugins - DevMode - Func Test Plugin</name>
    <description>Provides a plugin that allows code to be injected into a functionally tested Jira</description>
    <packaging>bundle</packaging>
    <build>
        <resources>
            <!-- It looks weird to have one command to include only atlassian-plugin.xml and another to include everything
                 but this single file. We're doing that, because
                 * only the first command is able to substitute Maven properties,
                   e.g. "${atlassian.plugin.key}" with "com.atlassian.jira.dev.func-test-plugin",
                 * only the second command is able to include everything, as "<include>*</include>" doesn't work -->
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
                <includes>
                    <include>atlassian-plugin.xml</include>
                </includes>
            </resource>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>false</filtering>
                <excludes>
                    <exclude>atlassian-plugin.xml</exclude>
                </excludes>
            </resource>
        </resources>
        <plugins>
            <plugin>
                <groupId>com.atlassian.plugin</groupId>
                <artifactId>atlassian-spring-scanner-maven-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.apache.felix</groupId>
                <artifactId>maven-bundle-plugin</artifactId>
                <configuration>
                    <instructions>
                        <Atlassian-Plugin-Key>${atlassian.plugin.key}</Atlassian-Plugin-Key>
                        <Bundle-SymbolicName>${atlassian.plugin.key}</Bundle-SymbolicName>
                        <Export-Package/>
                        <Spring-Context>*</Spring-Context>
                        <Import-Package>
                            !com.sun.tools.javac,
                            !org.apache.env.*,
                            !org.apache.tools.*,
                            !sun.*,
                            !org.apache.xmlbeans.*,
                            !antlr*,
                            com.atlassian.scheduler*,
                            com.atlassian.jira.plugin.webfragment.conditions,
                            org.apache.commons.io.*;version="2.6",
                            *
                        </Import-Package>
                        <!-- Ideally, we should ensure that the functest-plugin is present, so we can import
                               packages from it, embedding the required dependencies for now -->
                        <Embed-Dependency>
                            functest-plugin,
                            junit,
                            hamcrest-core,
                            rhino,
                            jstyleparser,
                            antlr4-runtime,
                            stringtemplate,
                            unbescape
                        </Embed-Dependency>
                        <Include-Resource>
                            {maven-resources},
                            META-INF/plugin-components=target/classes/META-INF/plugin-components
                        </Include-Resource>
                    </instructions>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.twdata.maven</groupId>
                <artifactId>maven-cli-plugin</artifactId>
            </plugin>

            <plugin>
                <groupId>com.atlassian.maven.plugins</groupId>
                <artifactId>jira-maven-plugin</artifactId>
                <configuration>
                    <productVersion>${project.version}</productVersion>
                    <productDataVersion>${project.version}</productDataVersion>

                    <enableQuickReload>true</enableQuickReload>
                    <!-- make AMPS faster -->
                    <compressResources>false</compressResources>
                    <enableDevToolbox>false</enableDevToolbox>
                    <enablePde>false</enablePde>
                    <skipRestDocGeneration>true</skipRestDocGeneration>
                    <allowGoogleTracking>false</allowGoogleTracking>
                    <skipManifestValidation>true</skipManifestValidation>
                    <extractDependencies>false</extractDependencies>
                    <!-- See here for an explanation of default instructions: -->
                    <!-- https://developer.atlassian.com/docs/advanced-topics/configuration-of-instructions-in-atlassian-plugins -->
                    <instructions>
                        <Atlassian-Plugin-Key>${atlassian.plugin.key}</Atlassian-Plugin-Key>
                        <!-- Add package import here -->
                        <Import-Package>*</Import-Package>
                        <!-- Ensure plugin is spring powered -->
                        <Spring-Context>*</Spring-Context>
                    </instructions>
                </configuration>
            </plugin>

            <!-- FRONTEND COMPILATION CONFIGURATION
               We're not using the frontend-maven-plugin here, because it doesn't work in conjunction with
               exclusion of JavaScript from the src/main/resources directory via the <resources> block.

               I have no idea how to make this plugin sympathetic to front-end resource compilation.
               The compilation task gets run multiples of times, but none of the assets end up in the JAR.
               I suspect it has something to do with the usage of the maven-bundle-plugin.

               If anybody wants to try and make compiling this plugin via Gulp work, go ahead!
               If successful, do the same fix in jira-reference-plugin/pom.xml.
           -->
        </plugins>
    </build>

    <dependencies>
        <dependency>
            <groupId>com.atlassian.jira</groupId>
            <artifactId>jira-core</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.ws.rs</groupId>
            <artifactId>jsr311-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.jira.tests</groupId>
            <artifactId>jira-testkit-plugin</artifactId>
            <version>${testkit.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.applinks</groupId>
            <artifactId>applinks-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.xml.bind</groupId>
            <artifactId>jaxb-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.sal</groupId>
            <artifactId>sal-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.plugins.rest</groupId>
            <artifactId>atlassian-rest-common</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.activeobjects</groupId>
            <artifactId>activeobjects-plugin</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.functest</groupId>
            <artifactId>functest-plugin</artifactId>
            <version>${fp.version}</version>
            <scope>provided</scope>
            <exclusions>
                <exclusion>
                    <groupId>com.google.collections</groupId>
                    <artifactId>google-collections</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.hamcrest</groupId>
            <artifactId>hamcrest-core</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.mozilla</groupId>
            <artifactId>rhino</artifactId>
            <version>1.7.7</version>
        </dependency>
        <dependency>
            <groupId>net.sf.cssbox</groupId>
            <artifactId>jstyleparser</artifactId>
            <version>4.0.0</version>
        </dependency>
        <dependency>
            <groupId>org.antlr</groupId>
            <artifactId>antlr4-runtime</artifactId>
            <version>4.5.3</version>
        </dependency>
        <dependency>
            <groupId>org.unbescape</groupId>
            <artifactId>unbescape</artifactId>
            <version>1.1.6.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-core</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.jira</groupId>
            <artifactId>jira-tests</artifactId>
            <scope>test</scope>
        </dependency>

        <!-- transformless plugins dependencies -->
        <dependency>
            <groupId>com.atlassian.plugin</groupId>
            <artifactId>atlassian-spring-scanner-annotation</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.hamcrest</groupId>
            <artifactId>hamcrest-library</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.antlr</groupId>
            <artifactId>stringtemplate</artifactId>
            <scope>provided</scope>
        </dependency>
    </dependencies>
    <properties>
        <atlassian.plugin.key>com.atlassian.jira.dev.func-test-plugin</atlassian.plugin.key>
    </properties>
</project>
