<?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/maven-v4_0_0.xsd">

    <modelVersion>4.0.0</modelVersion>

    <parent>
        <artifactId>workspace</artifactId>
        <groupId>com.atlassian.auinext</groupId>
        <version>9.2.0</version>
    </parent>

    <groupId>com.atlassian.aui</groupId>
    <artifactId>auiplugin</artifactId>

    <name>Atlassian UI Plugin</name>
    <description>
        The Atlassian User Interface library (AUI)
        is a set of patterns and components for building user interfaces
        in Atlassian products and services.
    </description>

    <packaging>atlassian-plugin</packaging>

    <dependencies>
    </dependencies>

    <build>
        <resources>
            <!-- Soy templates -->
            <resource>
                <directory>${root.location}packages/soy/src</directory>
            </resource>
        </resources>
        <plugins>
            <plugin>
                <groupId>com.atlassian.maven.plugins</groupId>
                <artifactId>amps-maven-plugin</artifactId>
                <version>${amps.version}</version>
                <extensions>true</extensions>
                <configuration>
                    <products>
                        <product>
                            <id>refapp</id>
                            <version>${refapp.version}</version>
                        </product>
                    </products>
                    <quickReloadVersion>2.0.0</quickReloadVersion>
                    <enableQuickReload>true</enableQuickReload>
                    <compressResources>false</compressResources>

                    <instructions>
                        <Atlassian-Plugin-Key>${atlassian.plugin.key}</Atlassian-Plugin-Key>
                        <Atlassian-Scan-Folders>META-INF/plugin-descriptor</Atlassian-Scan-Folders>
                        <Export-Package>*</Export-Package>
                        <Import-Package>*</Import-Package>
                        <Spring-Context>*</Spring-Context>
                    </instructions>
                    <pluginArtifacts>
                        <!-- Load ourselves in to AMPS if ever tested from here -->
                        <pluginArtifact>
                            <groupId>${project.groupId}</groupId>
                            <artifactId>${project.artifactId}</artifactId>
                            <version>${project.version}</version>
                        </pluginArtifact>
                    </pluginArtifacts>
                </configuration>
            </plugin>

            <plugin>
                <groupId>com.github.eirslett</groupId>
                <artifactId>frontend-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>01-install-binaries</id>
                        <goals>
                            <goal>install-node-and-yarn</goal>
                        </goals>
                        <phase>initialize</phase>
                        <inherited>false</inherited>
                    </execution>
                    <execution>
                        <id>02-install-deps</id>
                        <goals>
                            <goal>yarn</goal>
                        </goals>
                        <configuration>
                            <arguments>${frontend.install.cmd}</arguments>
                            <environmentVariables>
                                <!-- We need to ensure webpack and friends are installed. -->
                                <NODE_ENV>development</NODE_ENV>
                            </environmentVariables>
                        </configuration>
                        <phase>initialize</phase>
                        <inherited>false</inherited>
                    </execution>
                    <execution>
                        <id>03-build-frontend</id>
                        <goals>
                            <goal>webpack</goal>
                        </goals>
                        <configuration>
                            <arguments>--config p2/p2-plugin/webpack.config.js</arguments>
                        </configuration>
                        <phase>process-resources</phase>
                    </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.plugin</groupId>
                            <artifactId>atlassian-spring-scanner-external-jar</artifactId>
                        </dependency>
                    </scannedDependencies>
                    <verbose>false</verbose>
                </configuration>
            </plugin>

            <!-- Copy license texts in to the plugin -->
            <plugin>
                <artifactId>maven-resources-plugin</artifactId>
                <executions>
                    <execution>
                        <id>copy-license</id>
                        <phase>process-sources</phase>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${project.build.outputDirectory}/META-INF/licenses</outputDirectory>
                            <resources>
                                <resource>
                                    <directory>${root.location}/licenses</directory>
                                    <includes>
                                        <include>LICENSE-*</include>
                                    </includes>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <!--
                 Despite having no Java in the plugin, we still need to publish sources.
                 This is mainly to keep source distribution build configurations working in Jira.
            -->
            <plugin>
                <artifactId>maven-source-plugin</artifactId>
                <executions>
                    <execution>
                        <id>attach-sources</id>
                        <goals><goal>jar-no-fork</goal></goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <properties>
        <atlassian.plugin.key>com.atlassian.auiplugin</atlassian.plugin.key>
        <root.location>${basedir}/../../</root.location>
        <node.path>${project.parent.build.directory}</node.path>
    </properties>

</project>
