<?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">
    <parent>
        <artifactId>servicedesk-components</artifactId>
        <groupId>com.atlassian.servicedesk</groupId>
        <version>3.1.2</version>
    </parent>

    <modelVersion>4.0.0</modelVersion>
    <artifactId>servicedesk-knowledge-base-plugin</artifactId>

    <name>Service Desk Knowledge Base Plugin</name>
    <description>Plugin that provides Confluence knowledge base integration for Service Desk</description>
    <packaging>atlassian-plugin</packaging>

    <dependencies>
        <!-- Atlassian Platform dependencies -->
        <dependency>
            <groupId>com.atlassian.plugin</groupId>
            <artifactId>atlassian-spring-scanner-annotation</artifactId>
        </dependency>
        <dependency>
            <groupId>com.atlassian.plugin</groupId>
            <artifactId>atlassian-spring-scanner-runtime</artifactId>
        </dependency>
        <!-- SD -->
        <dependency>
            <groupId>com.atlassian.servicedesk</groupId>
            <artifactId>jira-servicedesk-internal-api</artifactId>
            <version>${project.version}</version>
            <scope>provided</scope>
        </dependency>
        <!-- JIRA -->
        <dependency>
            <groupId>com.atlassian.jira</groupId>
            <artifactId>jira-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <!-- Atlassian Pocketknife -->
        <dependency>
            <groupId>com.atlassian.pocketknife</groupId>
            <artifactId>pocketknife-features-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.pocketknife</groupId>
            <artifactId>pocketknife-features-plugin</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.pocketknife</groupId>
            <artifactId>atlassian-pocketknife-step</artifactId>
        </dependency>
        <dependency>
            <groupId>com.atlassian.pocketknife</groupId>
            <artifactId>atlassian-pocketknife-api-commons</artifactId>
            <scope>provided</scope>
        </dependency>

        <!-- Spring dependencies -->
        <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>

        <!-- Dependencies to other Atlassian lib/modules/plugins -->
        <dependency>
            <groupId>com.atlassian.plugins</groupId>
            <artifactId>atlassian-plugins-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.sal</groupId>
            <artifactId>sal-api</artifactId>
            <scope>provided</scope>
        </dependency>

        <!--3rd party libs -->
        <!-- None yet -->

        <!-- test dependencies -->
        <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>
        <resources>
            <!--
                We use gulp (via the mvn exec plugin) transform and copy frontend resources to the frontend-resources
                directory. So we need to let maven know where to find them so they still get bundled in the jar.
            -->
            <resource>
                <directory>target/frontend-resources</directory>
            </resource>
            <resource>
                <directory>src/main/resources</directory>
                <excludes>
                    <!--
                        These frontend resources are copied across to target/frontend-resources
                        See: gulpfile.babel.js
                    -->
                    <exclude>**/*.js</exclude>
                    <exclude>**/*.less</exclude>
                    <exclude>**/*.css</exclude>
                    <exclude>**/*.soy</exclude>
                </excludes>
            </resource>
            <resource>
                <directory>src/main/resources</directory>
                <!-- tell maven to replace ${var} variables with their build time values -->
                <filtering>true</filtering>
            </resource>
        </resources>

        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>process-frontend-resources</id>
                        <phase>generate-resources</phase>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                        <configuration>
                            <workingDirectory>../../</workingDirectory>
                            <executable>node_modules/gulp/bin/gulp.js</executable>
                            <arguments>
                                <argument>generate-knowledge-base-resources</argument>
                            </arguments>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>com.atlassian.plugin</groupId>
                <artifactId>atlassian-spring-scanner-maven-plugin</artifactId>
                <version>${atlassian.spring.scanner.version}</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>atlassian-spring-scanner</goal>
                        </goals>
                        <phase>process-classes</phase>
                    </execution>
                </executions>
                <configuration>
                    <scannedDependencies>
                        <!-- None -->
                    </scannedDependencies>
                    <verbose>false</verbose>
                </configuration>
            </plugin>

            <plugin>
                <groupId>com.atlassian.maven.plugins</groupId>
                <artifactId>maven-jira-plugin</artifactId>
                <version>${amps.version}</version>
                <extensions>true</extensions>
                <configuration>
                    <productVersion>${jira.version.parent}</productVersion>
                    <productDataVersion>${jira.version.parent}</productDataVersion>
                    <closureJsCompiler>true</closureJsCompiler>
                    <enableFastdev>false</enableFastdev>
                    <enableDevToolbox>false</enableDevToolbox>
                    <systemPropertyVariables>
                        <plugin.resource.directories>${basedir}/target/frontend-resources</plugin.resource.directories>
                    </systemPropertyVariables>
                    <instructions>
                        <Atlassian-Plugin-Key>com.atlassian.servicedesk.servicedesk-knowledge-base-plugin</Atlassian-Plugin-Key>
                        <Bundle-SymbolicName>com.atlassian.servicedesk.servicedesk-knowledge-base-plugin</Bundle-SymbolicName>
                        <Spring-Context>*</Spring-Context>
                        <Export-Package>
                            <!-- None yet -->
                        </Export-Package>
                        <Import-Package>
                            <!-- JIRA 7 and platform 4 use Gemini while the old uses SpringDM -->
                            org.springframework.*;resolution:="optional",
                            org.eclipse.gemini.blueprint.*;resolution:="optional",

                            <!-- BND cannot find this runtime dependency of the Atlassian plugin system -->
                            !com.atlassian.refapp.api,
                            !com.query.spatial.*,
                            !com.vividsolutions.jts.io,
                            !net.sf.cglib.proxy,
                            !oracle.spatial.geometry,
                            !oracle.sql,
                            !org.geolatte.geom.*,
                            !org.jvnet.hudson.annotation_indexer,
                            !org.postgis,

                            <!--Then other mandatory imports -->
                            <!-- None yet -->

                            <!-- if you declare a com.atlassian.plugin.osgi.external.SingleModuleDescriptorFactory, in your code at runtime the actual -->
                            <!-- package that will be called is com.atlassian.plugin.osgi.bridge.external.SingleModuleDescriptorFactory -->
                            <!-- JIRA 7 and platform 4 use Gemini while the old uses SpringDM -->

                            <!-- At build time the BND plugin will expand this * into the actual packages your code needs access to by analyzing -->
                            <!-- all of your code and it's dependencies through byte code scanning -->
                            *
                        </Import-Package>
                        <Atlassian-Scan-Folders>servicedesk</Atlassian-Scan-Folders>
                    </instructions>
                    <extractDependencies>false</extractDependencies>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>
