<?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">

    <parent>
        <artifactId>servicedesk-components</artifactId>
        <groupId>com.atlassian.servicedesk</groupId>
        <version>3.16.3-REL-0009</version>
    </parent>

    <modelVersion>4.0.0</modelVersion>
    <artifactId>servicedesk-frontend-plugin</artifactId>
    <name>Service Desk Frontend Plugin</name>
    <description>Compiles all the necessary front-end artifacts and serve them via generated WRM descriptor</description>

    <packaging>atlassian-plugin</packaging>

    <build>
        <plugins>
            <plugin>
                <groupId>com.atlassian.util</groupId>
                <artifactId>soy-packager-maven-plugin</artifactId>
                <version>1.0.2</version>
            </plugin>

            <plugin>
                <groupId>com.atlassian.plugin</groupId>
                <artifactId>atlassian-spring-scanner-maven-plugin</artifactId>
                <configuration>
                    <!-- Turn this on to true to show the inner workings of the build time scanner -->
                    <verbose>false</verbose>
                </configuration>
            </plugin>

            <plugin>
                <groupId>com.atlassian.maven.plugins</groupId>
                <artifactId>maven-jira-plugin</artifactId>
                <version>${amps.version}</version>
                <configuration>
                    <compressResources>false</compressResources>
                    <systemPropertyVariables>
                        <plugin.resource.directories>${basedir}/target/classes</plugin.resource.directories>
                    </systemPropertyVariables>
                    <instructions>
                        <!-- Specifies the location of standard plugin modules to scan -->
                        <Atlassian-Scan-Folders>META-INF/plugin-descriptors</Atlassian-Scan-Folders>
                        <Atlassian-Plugin-Key>com.atlassian.servicedesk.frontend-webpack-plugin</Atlassian-Plugin-Key>
                        <Bundle-SymbolicName>com.atlassian.servicedesk.frontend-webpack-plugin</Bundle-SymbolicName>
                        <Spring-Context>*</Spring-Context>
                        <Export-Package>
                            com.atlassian.servicedesk.frontend.obr.install
                        </Export-Package>
                        <Import-Package>
                            com.atlassian.frontend.obr.install,

                            *
                        </Import-Package>
                    </instructions>
                    <pluginDependencies>
                        <pluginDependency>
                            <groupId>com.atlassian.frontend</groupId>
                            <artifactId>atlassian-frontend-runtime-plugin</artifactId>
                        </pluginDependency>
                    </pluginDependencies>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>clover</id>
            <build>
                <plugins>
                    <plugin>
                        <!-- Don't need frontend resources for Clover execution, so turn off -->
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>exec-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>process-static-resources</id>
                                <phase>none</phase>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>frontend-build</id>
            <activation>
                <property>
                    <name>!frontend-watch</name>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>exec-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>process-static-resources</id>
                                <phase>compile</phase>
                                <goals>
                                    <goal>exec</goal>
                                </goals>
                                <configuration>
                                    <workingDirectory>../../</workingDirectory>
                                    <executable>yarn</executable>
                                    <arguments>
                                        <argument>run</argument>
                                        <argument>build</argument>
                                    </arguments>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>frontend-watch</id>
            <activation>
                <property>
                    <name>frontend-watch</name>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>exec-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>process-static-resources</id>
                                <phase>compile</phase>
                                <goals>
                                    <goal>exec</goal>
                                </goals>
                                <configuration>
                                    <workingDirectory>../../</workingDirectory>
                                    <executable>yarn</executable>
                                    <arguments>
                                        <argument>run</argument>
                                        <argument>watch:prepare</argument>
                                    </arguments>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

    <dependencies>
        <dependency>
            <groupId>com.atlassian.plugin</groupId>
            <artifactId>atlassian-spring-scanner-annotation</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.servicedesk</groupId>
            <artifactId>production-soy-compiler</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.servicedesk</groupId>
            <artifactId>testing-soy-compiler</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.plugins</groupId>
            <artifactId>atlassian-plugins-webresource-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.plugins</groupId>
            <artifactId>atlassian-plugins-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-beans</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.servicedesk</groupId>
            <artifactId>jira-servicedesk-internal-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.frontend</groupId>
            <artifactId>atlassian-frontend-runtime-plugin</artifactId>
            <scope>provided</scope>
        </dependency>
    </dependencies>

</project>
