<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>
        <groupId>com.atlassian.confluence.plugins</groupId>
        <artifactId>confluence-bundled-plugins</artifactId>
        <version>4.0-m27</version>
    </parent>

    <groupId>com.atlassian.plugins</groupId>
    <artifactId>atlassian-editor-plugin</artifactId>

    <name>Atlassian Editor Plugin</name>
    <description>Atlassian Editor Plugin</description>
    <url>http://confluence.atlassian.com/display/CONFEXT/TinyMCE+Plugin</url>

    <dependencies>
        <!-- REST dependencies -->
        <dependency>
            <groupId>javax.ws.rs</groupId>
            <artifactId>jsr311-api</artifactId>
            <version>1.0</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.xml.bind</groupId>
            <artifactId>jaxb-api</artifactId>
            <version>2.1</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.atlassian.plugins.rest</groupId>
            <artifactId>com.atlassian.jersey-library</artifactId>
            <version>${rest.version}</version>
            <type>pom</type>
            <scope>provided</scope>
        </dependency>
        <!-- Needed for Qualifier annotations -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring</artifactId>
            <version>2.5.6</version>
            <scope>provided</scope>
        </dependency>
        <!-- End of REST dependencies -->

        <dependency>
            <groupId>jmock</groupId>
            <artifactId>jmock</artifactId>
            <version>1.2.0</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>jmock</groupId>
            <artifactId>jmock-cglib</artifactId>
            <version>1.2.0</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>cglib</groupId>
            <artifactId>cglib-nodep</artifactId>
            <version>2.1_3</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <properties>
        <atlassian.plugin.key>com.atlassian.plugins.editor</atlassian.plugin.key>
        <confluence.version>${project.version}</confluence.version>
        <atlassian.product.version>${project.version}</atlassian.product.version>
    </properties>
    
    <build>
        <resources>
            <!-- This filtering strategy is intentionally weird to trick the IDEA plugin into including the directory in the classpath -->
            <resource>
                <directory>src/main/resources</directory>
                <excludes>
                    <exclude>atlassian-plugin.xml</exclude>
                    <exclude>**/*.gif</exclude>
                    <exclude>**/*.png</exclude>
                </excludes>
            </resource>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
                <includes>
                    <include>atlassian-plugin.xml</include>
                    <include>**/*.gif</include>
                    <include>**/*.png</include>
                </includes>
            </resource>
        </resources>
        <plugins>
            <plugin>
                <groupId>org.twdata.maven</groupId>
                <artifactId>maven-cli-plugin</artifactId>
                <version>1.0.3</version>
                <configuration>
                    <commands>
                        <pi>resources compile jar com.atlassian.maven.plugins:atlassian-pdk:install</pi>
                        <pu>com.atlassian.maven.plugins:atlassian-pdk:uninstall</pu>
                    </commands>
                </configuration>
            </plugin>
        </plugins>
    </build>
    <profiles>
         <profile>
            <id>smart-sprites</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>exec-maven-plugin</artifactId>
                        <dependencies>
                            <dependency>
                                <groupId>org.carrot2.labs</groupId>
                                <artifactId>smart-sprites</artifactId>
                                <version>0.2.6</version>
                            </dependency>
                        </dependencies>
                        <executions>
                            <execution>
                                <phase>process-resources</phase>
                                <goals>
                                    <goal>java</goal>
                                </goals>
                                <configuration>
                                    <mainClass>org.carrot2.labs.smartsprites.SmartSprites</mainClass>
                                    <executableDependency>
                                        <groupId>org.carrot2.labs</groupId>
                                        <artifactId>smart-sprites</artifactId>
                                    </executableDependency>
                                    <includePluginDependencies>true</includePluginDependencies>
                                    <!-- We don't need any project dependencies-->
                                    <includeProjectDependencies>false</includeProjectDependencies>
                                    <arguments>
                                        <!-- The values have to be entered as two separate arguments -->
                                        <argument>--root-dir-path</argument>
                                        <argument>src/main/resources</argument>
                                    </arguments>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <!-- Smart Sprites outputs the sprite images to same directory as the url path specified.
                         So we move the new generated sprites back into the css resource directory. You can
                         delete the @contextPath directory after running this profile. -->
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-antrun-plugin</artifactId>
                        <executions>
                            <execution>
                                <phase>process-resources</phase>
                                <goals>
                                   <goal>run</goal>
                                </goals>
                                <configuration>
                                    <target>
                                        <copy todir="src/main/resources/css" flatten="true" overwrite="true">
                                            <fileset dir="src/main/resources/css/@contextPath/download/resources/${atlassian.plugin.key}">
                                                <include name="*.png" />
                                            </fileset>
                                        </copy>
                                    </target>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
            <properties>
                <maven.yuicompressor.skip>true</maven.yuicompressor.skip>
            </properties>
        </profile>
    </profiles>
</project>
