<?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-canned-responses-parent</artifactId>
        <groupId>com.atlassian.servicedesk</groupId>
        <version>3.8.2-REL-0001</version>
    </parent>

    <modelVersion>4.0.0</modelVersion>
    <packaging>atlassian-plugin</packaging>

    <artifactId>servicedesk-canned-responses-plugin</artifactId>
    <name>Service Desk Canned Responses Plugin</name>
    <description>Plugin for Canned Responses</description>

    <properties>
        <maven.build.timestamp.format>yyyy-MM-dd'T'HH:mm:ss.SSSZ</maven.build.timestamp.format>
        <timestamp>${maven.build.timestamp}</timestamp>
        <buildNumber/>
    </properties>

    <dependencies>
        <dependency>
            <groupId>com.atlassian.servicedesk</groupId>
            <artifactId>jira-servicedesk-api</artifactId>
            <version>${jira.servicedesk.application.version}</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>com.atlassian.servicedesk</groupId>
            <artifactId>jira-servicedesk-internal-api</artifactId>
            <version>${project.version}</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>com.atlassian.servicedesk</groupId>
            <artifactId>servicedesk-variable-substitution-api</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>com.atlassian.servicedesk</groupId>
            <artifactId>servicedesk-lingo-api</artifactId>
            <scope>provided</scope>
        </dependency>

        <!-- Atlassian Platform dependencies -->
        <dependency>
            <groupId>com.atlassian.plugin</groupId>
            <artifactId>atlassian-spring-scanner-annotation</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.servicedesk</groupId>
            <artifactId>servicedesk-internal-base-api</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>

        <!-- JIRA -->
        <dependency>
            <groupId>com.atlassian.jira</groupId>
            <artifactId>jira-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.jira</groupId>
            <artifactId>jira-core</artifactId>
            <scope>provided</scope>
            <exclusions>
                <exclusion>
                    <groupId>javax.servlet</groupId>
                    <artifactId>servlet-api</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <!-- Lucene (from JIRA - but define here so clear we use it) -->
        <dependency>
            <groupId>org.apache.lucene</groupId>
            <artifactId>lucene-core</artifactId>
            <version>${lucene.version}-atlassian-1</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.lucene</groupId>
            <artifactId>lucene-analyzers</artifactId>
            <version>${lucene.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian</groupId>
            <artifactId>lucene-extras</artifactId>
            <version>${lucene.version}-atlassian-3</version>
            <scope>provided</scope>
        </dependency>

        <!-- DB Schema -->
        <dependency>
            <groupId>com.atlassian.activeobjects</groupId>
            <artifactId>activeobjects-plugin</artifactId>
            <scope>provided</scope>
        </dependency>

        <!-- Atlassian Pocketknife -->
        <dependency>
            <groupId>com.atlassian.pocketknife</groupId>
            <artifactId>jira-pocketknife-enablement</artifactId>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.pocketknife</groupId>
            <artifactId>atlassian-pocketknife-querydsl</artifactId>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.pocketknife</groupId>
            <artifactId>atlassian-pocketknife-step</artifactId>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.pocketknife</groupId>
            <artifactId>atlassian-pocketknife-core</artifactId>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.pocketknife</groupId>
            <artifactId>atlassian-pocketknife-api-commons</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.pocketknife</groupId>
            <artifactId>atlassian-pocketknife-api-commons-jira</artifactId>
            <scope>provided</scope>
        </dependency>

        <!--Atlassian lib dependencies -->
        <dependency>
            <groupId>com.atlassian.sal</groupId>
            <artifactId>sal-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.util.concurrent</groupId>
            <artifactId>atlassian-util-concurrent</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.annotations</groupId>
            <artifactId>atlassian-annotations</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.fugue</groupId>
            <artifactId>fugue</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>io.atlassian.fugue</groupId>
            <artifactId>fugue</artifactId>
            <scope>provided</scope>
        </dependency>


        <!--3rd party libs -->
        <dependency>
            <groupId>javax.ws.rs</groupId>
            <artifactId>jsr311-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.querydsl</groupId>
            <artifactId>querydsl-core</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.querydsl</groupId>
            <artifactId>querydsl-sql</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.mysema.commons</groupId>
            <artifactId>mysema-commons-lang</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>joda-time</groupId>
            <artifactId>joda-time</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>commons-lang</groupId>
            <artifactId>commons-lang</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.google.code.gson</groupId>
            <artifactId>gson</artifactId>
        </dependency>

        <!-- 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>
        <dependency>
            <groupId>com.google.code.findbugs</groupId>
            <artifactId>jsr305</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.hamcrest</groupId>
            <artifactId>hamcrest-core</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.hamcrest</groupId>
            <artifactId>hamcrest-library</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>io.atlassian.fugue</groupId>
            <artifactId>fugue-hamcrest</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.jira</groupId>
            <artifactId>jira-tests</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.servicedesk</groupId>
            <artifactId>servicedesk-test-common</artifactId>
            <scope>test</scope>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>com.atlassian.servicedesk</groupId>
            <artifactId>sd-testing-backdoors</artifactId>
            <version>${project.version}</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>

    <build>

        <!--
       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.
        -->
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <excludes>
                    <exclude>**/*.css</exclude>
                    <exclude>**/*.less</exclude>
                    <exclude>**/*.js</exclude>
                    <exclude>**/*.soy</exclude>
                </excludes>
            </resource>
        </resources>

        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <excludes>
                        <exclude>**/*DBIT.java</exclude>
                    </excludes>
                </configuration>
                <executions>
                    <!-- using surefire for integration tests since AMPS completely ignores failsafe -->
                    <execution>
                        <id>integration-test-dbunit</id>
                        <goals>
                            <goal>test</goal>
                        </goals>
                        <phase>integration-test</phase>
                        <configuration>
                            <excludes>
                                <exclude>none</exclude>
                            </excludes>
                            <includes>
                                <include>**/*DBIT.java</include>
                            </includes>
                            <skipTests>${dbunit.skip}</skipTests>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>prepare-soy-resources</id>
                        <phase>generate-resources</phase>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                        <configuration>
                            <executable>../../../misc/scripts/sd-prepare-soy.py</executable>
                        </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>
                        <dependency>
                            <groupId>com.atlassian.pocketknife</groupId>
                            <artifactId>atlassian-pocketknife-querydsl</artifactId>
                        </dependency>
                        <dependency>
                            <groupId>com.atlassian.pocketknife</groupId>
                            <artifactId>atlassian-pocketknife-enablement</artifactId>
                        </dependency>
                        <dependency>
                            <groupId>com.atlassian.pocketknife</groupId>
                            <artifactId>atlassian-pocketknife-core</artifactId>
                        </dependency>
                    </scannedDependencies>
                    <verbose>false</verbose>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-antrun-plugin</artifactId>
                <executions>
                    <!-- Generate build properties -->
                    <execution>
                        <id>generate-build-properties</id>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>run</goal>
                        </goals>
                        <configuration>
                            <target>
                                <taskdef resource="net/sf/antcontrib/antcontrib.properties" classpathref="maven.plugin.classpath" />

                                <echo>  Running ant tasks.  Suck on that maven!</echo>

                                <echo>  Generating BuildProperties.properties...</echo>

                                <copy file="${project.basedir}/src/main/resources/buildprops/BuildProperties.properties.template" tofile="${project.build.outputDirectory}/buildprops/BuildProperties.properties" overwrite="true" />
                                <replace file="${project.build.outputDirectory}/buildprops/BuildProperties.properties" token="%SD_CANNED_RESPONSES_BUILD_DATE@" value="${timestamp}" />
                                <replace file="${project.build.outputDirectory}/buildprops/BuildProperties.properties" token="%SD_CANNED_RESPONSES_VERSION@" value="${project.version}" />
                                <replace file="${project.build.outputDirectory}/buildprops/BuildProperties.properties" token="%SD_CANNED_RESPONSES_CHANGE_SET@" value="${buildNumber}" />

                            </target>
                        </configuration>
                    </execution>
                </executions>
                <dependencies>
                    <dependency>
                        <groupId>ant-contrib</groupId>
                        <artifactId>ant-contrib</artifactId>
                        <version>1.0b3</version>
                        <exclusions>
                            <exclusion>
                                <groupId>ant</groupId>
                                <artifactId>ant</artifactId>
                            </exclusion>
                        </exclusions>
                    </dependency>
                </dependencies>
            </plugin>

            <plugin>
                <groupId>com.atlassian.util</groupId>
                <artifactId>db-schema-translator-maven-plugin</artifactId>
            </plugin>

            <plugin>
                <groupId>com.atlassian.maven.plugins</groupId>
                <artifactId>maven-jira-plugin</artifactId>
                <configuration>
                    <closureJsCompiler>true</closureJsCompiler>
                    <compressResources>false</compressResources>
                    <systemPropertyVariables>
                        <plugin.resource.directories>${basedir}/target/classes</plugin.resource.directories>
                    </systemPropertyVariables>
                    <instructions>
                        <Atlassian-Plugin-Key>com.atlassian.servicedesk.servicedesk-canned-responses-plugin</Atlassian-Plugin-Key>
                        <Bundle-SymbolicName>com.atlassian.servicedesk.servicedesk-canned-responses-plugin</Bundle-SymbolicName>
                        <Spring-Context>*</Spring-Context>
                        <Export-Package>
                            com.atlassian.servicedesk.plugins.cannedresponses.internal.bootstrap.obr.install,
                            com.atlassian.servicedesk.plugins.cannedresponses.internal.visiblefortesting
                        </Export-Package>
                        <Import-Package>
                            !org.springframework.osgi.service.exporter.support,
                            !org.springframework.osgi.service.importer.support,
                            !com.atlassian.refapp.api,
                            !net.sf.cglib.proxy,
                            !org.jvnet.hudson.annotation_indexer,

                            <!-- declare import for javax.annotation here so @PostConstruct can be used -->
                            javax.annotation,

                            <!-- 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,META-INF/plugin-descriptors</Atlassian-Scan-Folders>
                    </instructions>
                </configuration>
            </plugin>
        </plugins>

    </build>
</project>
