<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.plugins</groupId>
        <artifactId>atlassian-plugins-webresource-parent</artifactId>
        <version>3.5.19-ac3d947</version>
    </parent>

    <version>3.5.19-ac3d947</version>
    <groupId>com.atlassian.plugins</groupId>
    <artifactId>atlassian-plugins-webresource-rest</artifactId>
    <name>Atlassian Plugins - Web Resources REST</name>
    <packaging>atlassian-plugin</packaging>

    <dependencies>
        <dependency>
            <groupId>com.atlassian.json</groupId>
            <artifactId>atlassian-json-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.rest</groupId>
            <artifactId>atlassian-rest-common</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</groupId>
            <artifactId>atlassian-plugins-webresource</artifactId>
            <version>3.5.19-ac3d947</version>
            <type>test-jar</type>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.plugins</groupId>
            <artifactId>atlassian-plugins-webresource-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpclient</artifactId>
            <version>4.4.1</version>
        </dependency>
        <dependency>
            <groupId>com.atlassian.plugins</groupId>
            <artifactId>atlassian-plugins-webresource-common</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>com.atlassian.maven.plugins</groupId>
                <artifactId>maven-amps-plugin</artifactId>
                <version>${amps.version}</version>
                <extensions>true</extensions>
                <configuration>
                    <products>
                        <product>
                            <id>jira</id>
                            <version>${jira.version}</version>
                        </product>
                        <!--
                        <product>
                            <id>confluence</id>
                            <version>${confluence.version}</version>
                        </product>
                        <product>
                            <id>fecru</id>
                            <version>${fecru.version}</version>
                        </product>
                        <product>
                            <id>bamboo</id>
                            <version>${bamboo.version}</version>
                        </product>
                        <product>
                            <id>refapp</id>
                            <version>${refapp.version}</version>
                        </product>
                        -->
                    </products>
                    <instructions>
                        <Atlassian-Plugin-Key>${project.groupId}.${project.artifactId}</Atlassian-Plugin-Key>
                        <Private-Package>
                            com.atlassian.webresource.plugin
                        </Private-Package>
                        <Import-Package>
                            com.atlassian.plugin.*,
                            com.atlassian.plugins.rest.common.security,
                            com.atlassian.webresource.api*;version="${wrm.api.compat.version}",
                            com.atlassian.plugin.servlet*,
                            com.atlassian.plugin.webresource*;version="${wrm.api.compat.version}",
                            com.atlassian.json.marshal.*,
                            com.atlassian.html.encode*,
                            com.atlassian.util.concurrent,
                            com.google.common.*,
                            javax.naming.*,
                            javax.net.*,
                            javax.net.ssl.*,
                            javax.security.auth.*,
                            javax.ws.rs,
                            javax.ws.rs.core,
                            javax.xml.bind.annotation,
                            org.slf4j,
                            org.apache.commons.collections,
                            org.apache.commons.io,
                            org.apache.commons.lang,
                            org.apache.commons.lang.exception,
                            org.codehaus.jackson*,
                        </Import-Package>
                        <Spring-Context>*</Spring-Context>
                    </instructions>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>${jdkLevel}</source>
                    <target>${jdkLevel}</target>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <profiles>

        <!-- Compiling AMD modules. -->
        <profile>
            <id>build-atlassian-modules</id>
            <activation>
                <property>
                    <name>!skipAtlassianModulesBuild</name>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>exec-maven-plugin</artifactId>
                        <version>1.1.1</version>
                        <executions>
                            <execution>
                                <id>1-run-npm-install</id>
                                <phase>compile</phase>
                                <goals>
                                    <goal>exec</goal>
                                </goals>
                                <configuration>
                                    <executable>npm</executable>
                                    <arguments>
                                        <argument>install</argument>
                                    </arguments>
                                </configuration>
                            </execution>
                            <execution>
                                <id>2-run-atlassian-modules-builder</id>
                                <phase>compile</phase>
                                <goals>
                                    <goal>exec</goal>
                                </goals>
                                <configuration>
                                    <executable>node_modules/.bin/wrm-compile</executable>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <profile>
            <id>npm-tests</id>
            <activation>
                <property>
                    <name>!skipTests</name>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>exec-maven-plugin</artifactId>
                        <version>1.1.1</version>
                        <executions>
                            <execution>
                                <id>run-npm-install</id>
                                <phase>generate-test-resources</phase>
                                <goals>
                                    <goal>exec</goal>
                                </goals>
                                <configuration>
                                    <executable>npm</executable>
                                    <arguments>
                                        <argument>install</argument>
                                    </arguments>
                                </configuration>
                            </execution>
                            <execution>
                                <id>run-javascript-unit-tests</id>
                                <phase>test</phase>
                                <goals>
                                    <goal>exec</goal>
                                </goals>
                                <configuration>
                                    <executable>npm</executable>
                                    <arguments>
                                        <argument>test</argument>
                                    </arguments>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
