<?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.bitbucket.server</groupId>
        <artifactId>bitbucket-plugins-parent</artifactId>
        <version>6.1.3</version>
    </parent>

    <artifactId>bitbucket-pull-request-ui</artifactId>
    <packaging>atlassian-plugin</packaging>

    <name>Bitbucket Server - Pull Request UI</name>
    <description>Provides the new Pull Request UI</description>

    <properties>
        <atlassian.plugin.key>${project.groupId}.${project.artifactId}</atlassian.plugin.key>
    </properties>

    <build>
        <plugins>
            <plugin>
                <groupId>com.atlassian.maven.plugins</groupId>
                <artifactId>bitbucket-maven-plugin</artifactId>
                <extensions>true</extensions>
                <configuration>
                    <compressJs>false</compressJs>
                    <compressCss>false</compressCss>
                    <enableQuickReload>true</enableQuickReload>

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

                        <!-- Ensure plugin is spring powered -->
                        <Spring-Context>*</Spring-Context>

                        <Atlassian-Scan-Folders>META-INF/plugin-descriptors</Atlassian-Scan-Folders>
                    </instructions>
                </configuration>
            </plugin>
            <plugin>
                <groupId>com.github.eirslett</groupId>
                <artifactId>frontend-maven-plugin</artifactId>
                <configuration>
                    <installDirectory>../../${fe.node.installdir}</installDirectory>
                    <environmentVariables>
                        <!-- We need to use custom Babel environment other then "production" since
                             Webpack can't work with "transform-es2015-modules-amd-lazy" plugin -->
                        <BABEL_ENV>webpack</BABEL_ENV>
                    </environmentVariables>
                </configuration>
                <executions>
                    <execution>
                        <inherited>false</inherited>
                        <id>npm install</id>
                        <goals>
                            <goal>npm</goal>
                        </goals>
                        <phase>generate-resources</phase>
                        <configuration>
                            <skip>${skipNpmInstall}</skip>
                            <arguments>ci</arguments>
                        </configuration>
                    </execution>
                    <execution>
                        <id>npm build</id>
                        <phase>generate-resources</phase>
                        <goals>
                            <goal>npm</goal>
                        </goals>
                        <configuration>
                            <skip>${skipNpmInstall}</skip>
                            <arguments>run build</arguments>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>frontend-watch</id>
            <activation>
                <property>
                    <name>frontend-watch</name>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>com.github.eirslett</groupId>
                        <artifactId>frontend-maven-plugin</artifactId>
                        <configuration>
                            <installDirectory>../../${fe.node.installdir}</installDirectory>
                            <environmentVariables>
                                <!-- We need to use custom Babel environment other then "production" since
                                     Webpack can't work with "transform-es2015-modules-amd-lazy" plugin -->
                                <BABEL_ENV>webpack</BABEL_ENV>
                            </environmentVariables>
                        </configuration>
                        <executions>
                            <execution>
                                <id>process-static-resources</id>
                                <phase>compile</phase>
                                <goals>
                                    <goal>npm</goal>
                                </goals>
                                <configuration>
                                    <arguments>run watch:prepare</arguments>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
