<?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>11.0.0</version>
        <relativePath>../../pom.xml</relativePath>
    </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>

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

    <dependencies>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>com.atlassian.maven.plugins</groupId>
                <artifactId>amps-maven-plugin</artifactId>
                <extensions>true</extensions>

                <executions>
                    <execution>
                        <id>js-enforcement</id>
                        <goals>
                            <goal>verify-fe-manifest-associations</goal>
                        </goals>
                    </execution>
                </executions>

                <configuration>
                    <includedFeModuleManifests>
                        <includedFeModuleManifest>${project.basedir}/package.json</includedFeModuleManifest>
                        <includedFeModuleManifest>${project.basedir}/../../yarn.lock</includedFeModuleManifest>
                        <!-- Include any intra-workspace dependency package.json files to ensure that we can filter out devDependencies properly -->
                        <!-- @atlassian/aui -->
                        <includedFeModuleManifest>${project.basedir}/../../packages/core/package.json</includedFeModuleManifest>
                    </includedFeModuleManifests>

                    <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>
                            com.atlassian.sal.api.features,
                            *
                        </Import-Package>
                        <Spring-Context>*</Spring-Context>
                    </instructions>
                </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-core</id>
                        <goals>
                            <goal>yarn</goal>
                        </goals>
                        <configuration>
                            <arguments>dist</arguments>
                        </configuration>
                        <phase>process-resources</phase>
                    </execution>
                    <execution>
                        <id>04-build-frontend</id>
                        <goals>
                            <goal>yarn</goal>
                        </goals>
                        <configuration>
                            <arguments>rspack --config p2/p2-plugin/webpack.config.js</arguments>
                            <environmentVariables>
                                <NODE_ENV>production</NODE_ENV>
                            </environmentVariables>
                        </configuration>
                        <phase>process-resources</phase>
                    </execution>
                    <execution>
                        <id>05-inject-lookandfeel</id>
                        <goals>
                            <goal>yarn</goal>
                        </goals>
                        <configuration>
                            <arguments>node p2/p2-plugin/webpack.lookandfeel-inject.js p2/p2-plugin/target/classes/META-INF/plugin-descriptor/webpacked-modules.xml</arguments>
                        </configuration>
                        <phase>process-resources</phase>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <version>${maven-resources-plugin.version}</version>
                <!-- Specifying it here to avoid IntelliJ breaking with
                    multiple modules having the same directories. Bug is
                    https://youtrack.jetbrains.com/issue/IDEA-364116/ -->
                <executions>
                    <!-- Copy license texts in to the plugin -->
                    <execution>
                        <id>copy-licenses</id>
                        <phase>process-sources</phase>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${project.build.outputDirectory}/META-INF/licenses</outputDirectory>
                            <resources>
                                <resource>
                                    <directory>${aui.project.root.dir}/licenses</directory>
                                    <includes>
                                        <include>LICENSE-*</include>
                                    </includes>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                    <execution>
                        <id>copy-soy-templates</id>
                        <phase>process-sources</phase>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${project.build.outputDirectory}</outputDirectory>
                            <!-- Specifying it here to avoid IntelliJ breaking with
                                multiple modules having the same directories. Bug is
                                https://youtrack.jetbrains.com/issue/IDEA-364116/ -->
                            <resources>
                                <resource>
                                    <directory>${aui.project.root.dir}/packages/soy/src</directory>
                                </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>

</project>
