<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>auiplugin-parent</artifactId>
        <groupId>com.atlassian.aui</groupId>
        <version>5.8.13</version>
    </parent>

    <artifactId>auiplugin</artifactId>
    <packaging>atlassian-plugin</packaging>

    <name>Atlassian UI Plugin</name>
    <description>An Atlassian plugin that contains the core javascript files used in Atlassian products.</description>
    <url>https://bitbucket.org/atlassian/aui</url>

    <properties>
        <atlassian.plugin.key>com.atlassian.auiplugin</atlassian.plugin.key>
        <maven.build.timestamp.format>yyyy.MM.dd HH:mm:ss Z</maven.build.timestamp.format>
        <!-- Workaround from http://jira.codehaus.org/browse/MRESOURCES-99
             Used for ${timestamp} replacements later -->
        <timestamp>${maven.build.timestamp}</timestamp>
    </properties>

    <dependencies>
        <dependency>
            <groupId>dom4j</groupId>
            <artifactId>dom4j</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.plugins</groupId>
            <artifactId>atlassian-plugins-osgi</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.plugins</groupId>
            <artifactId>atlassian-plugins-webresource</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.soy</groupId>
            <artifactId>soy-template-renderer-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.sal</groupId>
            <artifactId>sal-api</artifactId>
            <scope>provided</scope>
        </dependency>

        <!-- Test dependencies -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-all</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.core</groupId>
            <artifactId>atlassian-core</artifactId>
            <scope>test</scope>
        </dependency>
        <!-- Required by transformer tests -->
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <scope>test</scope>
        </dependency>
        <!-- Only exists to unpack soy deps for testing -->
        <dependency>
            <groupId>com.atlassian.soy</groupId>
            <artifactId>soy-template-plugin</artifactId>
            <scope>test</scope>
        </dependency>
        <!-- Only exists to unpack jquery deps for testing -->
        <dependency>
            <groupId>com.atlassian.plugins</groupId>
            <artifactId>jquery</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <resources>
            <!-- Need aui-adg source files for atlassian-plugin.xml -->
            <resource>
                <directory>../../src</directory>
            </resource>

            <!-- Bundled Bower components -->
            <resource>
                 <directory>${aui.location}/.tmp/requirejs-transformed/bower_components</directory>
                 <includes>
                     <include>skatejs/dist/skate.js</include>
                     <include>skatejs-template-html/dist/template-html.js</include>
                     <include>tether/tether.js</include>
                     <include>fancy-file-input/dist/fancy-file-input.js</include>
                     <include>fancy-file-input/dist/fancy-file-input.css</include>
                 </includes>
             </resource>

             <!-- Transformed resources from AUI -->
             <resource>
                 <directory>${aui.location}/.tmp/requirejs-transformed/src</directory>
                 <excludes>
                     <!-- atlassian.js is pulled in with filtering=true in the resource below -->
                     <exclude>js/aui.js</exclude>
                 </excludes>
             </resource>

             <!-- This defines project.version transform targets. -->
             <resource>
                 <directory>${aui.location}/.tmp/requirejs-transformed/src</directory>
                 <filtering>true</filtering>
                 <includes>
                     <include>js/aui.js</include>
                 </includes>
             </resource>

            <!-- Resources from AUI that are not in the transformed path -->
            <resource>
                <directory>${aui.location}/src</directory>
                <includes>
                    <include>css-vendor/</include>
                    <include>i18n/</include>
                    <include>less/</include>
                    <include>soy/</include>
                </includes>
            </resource>

            <!-- This defines project.version transform targets. -->
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
                <includes>
                    <include>atlassian-plugin.xml</include>
                    <include>version</include>
                    <include>${aui.location}/src/i18n/aui.properties</include>
                </includes>
            </resource>
        </resources>

        <plugins>
            <plugin>
                <groupId>com.atlassian.maven.plugins</groupId>
                <artifactId>maven-amps-plugin</artifactId>
                <configuration>
                    <productVersion>${refapp.version}</productVersion>
                    <extractDependencies>true</extractDependencies>
                    <closureJsCompiler>true</closureJsCompiler>
                    <systemPropertyVariables>
                        <plugin.resource.directories>${basedir}/src/main/resources,${aui.location}/src</plugin.resource.directories>
                    </systemPropertyVariables>
                </configuration>
            </plugin>

            <!-- unpack lib dependencies to make available to qunit -->
            <plugin>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <id>extract-lib-dependencies</id>
                        <phase>generate-test-resources</phase>
                        <goals>
                            <goal>unpack-dependencies</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${project.build.directory}/qunit/dependencies</outputDirectory>
                            <includeGroupIds>com.atlassian.plugins</includeGroupIds>
                            <includeArtifactIds>jquery</includeArtifactIds>
                            <includes>**/*.js</includes>
                        </configuration>
                    </execution>
                    <execution>
                        <id>extract-soyutils-dependency-for-demos</id>
                        <!--run during generate-resources phase so that demos.json generation can use it too-->
                        <phase>generate-resources</phase>
                        <goals>
                            <goal>unpack-dependencies</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${project.build.directory}/soyutils</outputDirectory>
                            <includeGroupIds>com.atlassian.soy</includeGroupIds>
                            <includeArtifactIds>soy-template-plugin</includeArtifactIds>
                            <includes>**/soyutils.js</includes>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>com.atlassian.lesscss</groupId>
                <artifactId>lesscss-maven-plugin</artifactId>
                <version>3.2.0</version>
                <executions>
                    <execution>
                        <id>compile-aui-less</id>
                        <phase>process-resources</phase>
                        <goals>
                            <goal>compile</goal>
                        </goals>
                        <configuration>
                            <sourceDirectory>${aui.location}/src</sourceDirectory>
                        </configuration>
                    </execution>
                    <execution>
                        <id>compile-adg-less</id>
                        <phase>process-resources</phase>
                        <goals>
                            <goal>compile</goal>
                        </goals>
                        <configuration>
                            <sourceDirectory>${basedir}/../../src</sourceDirectory>
                        </configuration>
                    </execution>
                </executions>
                <configuration>
                    <excludes>
                        <exclude>less/batch/*</exclude>
                        <exclude>less/imports/*</exclude>
                    </excludes>
                    <outputDirectory>target/classes</outputDirectory>
                </configuration>
            </plugin>

            <plugin>
                <artifactId>maven-source-plugin</artifactId>
                <executions>
                    <execution>
                        <id>attach-sources</id>
                        <goals><goal>jar-no-fork</goal></goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <artifactId>maven-javadoc-plugin</artifactId>
                <executions>
                    <execution>
                        <id>attach-javadocs</id>
                        <goals><goal>jar</goal></goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>
