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

    <parent>
        <groupId>com.atlassian.shindig</groupId>
        <artifactId>shindig-parent</artifactId>
        <version>2.2.3</version>
    </parent>

    <artifactId>shindig-features</artifactId>
    <packaging>jar</packaging>

    <name>Apache Shindig Features</name>
    <description>Packages all the features that shindig provides into a single jar file to allow
        loading from the classpath
    </description>

    <build>
        <resources>
            <resource>
                <targetPath>features</targetPath>
                <directory>${basedir}/src/main/javascript/features</directory>
            </resource>
            <resource>
                <targetPath>META-INF</targetPath>
                <directory>${basedir}</directory>
                <includes>
                    <include>NOTICE</include>
                </includes>
            </resource>
        </resources>
        <testResources>
            <testResource>
                <targetPath>features</targetPath>
                <directory>${basedir}/src/test/javascript/features</directory>
            </testResource>
        </testResources>
        <pluginManagement>
            <!-- set versions of common plugins for reproducibility, ordered alphabetically by owner -->
            <plugins>
                <!-- Misc -->
                <plugin>
                    <groupId>de.berlios.jsunit</groupId>
                    <artifactId>jsunit-maven2-plugin</artifactId>
                    <version>1.3</version>
                </plugin>
                <plugin>
                    <groupId>net.sf.alchim</groupId>
                    <artifactId>yuicompressor-maven-plugin</artifactId>
                    <version>0.7.1</version>
                </plugin>
            </plugins>
        </pluginManagement>
        <!-- ordered alphabetically by owner -->
        <plugins>
            <plugin>
                <groupId>de.berlios.jsunit</groupId>
                <artifactId>jsunit-maven2-plugin</artifactId>
                <executions>
                    <execution>
                        <configuration>
                            <sourceDirectory>${basedir}/src/main/javascript/features</sourceDirectory>
                            <sources>
                                <source>../../../../src/test/javascript/features/mocks/env.js</source>
                                <source>../../../../src/test/javascript/features/mocks/xhr.js</source>
                                <source>core/config.js</source>
                                <source>core/json.js</source>
                                <source>core/auth.js</source>
                                <source>core/util.js</source>
                                <source>core/prefs.js</source>
                                <source>core.io/io.js</source>
                                <source>setprefs/setprefs.js</source>
                                <source>views/views.js</source>
                                <source>opensocial-reference/opensocial.js</source>
                                <source>opensocial-reference/activity.js</source>
                                <source>opensocial-reference/address.js</source>
                                <source>opensocial-reference/bodytype.js</source>
                                <source>opensocial-reference/collection.js</source>
                                <source>opensocial-reference/container.js</source>
                                <source>opensocial-reference/datarequest.js</source>
                                <source>opensocial-reference/dataresponse.js</source>
                                <source>opensocial-reference/email.js</source>
                                <source>opensocial-reference/enum.js</source>
                                <source>opensocial-reference/environment.js</source>
                                <source>opensocial-reference/idspec.js</source>
                                <source>opensocial-reference/mediaitem.js</source>
                                <source>opensocial-reference/message.js</source>
                                <source>opensocial-reference/name.js</source>
                                <source>opensocial-reference/navigationparameters.js</source>
                                <source>opensocial-reference/organization.js</source>
                                <source>opensocial-reference/person.js</source>
                                <source>opensocial-reference/phone.js</source>
                                <source>opensocial-reference/responseitem.js</source>
                                <source>opensocial-reference/url.js</source>
                                <source>opensocial-base/jsonactivity.js</source>
                                <source>opensocial-base/jsonperson.js</source>
                                <source>opensocial-rest/restfulcontainer.js</source>
                                <source>opensocial-jsonrpc/jsonrpccontainer.js</source>
                            </sources>
                            <testSourceDirectory>${basedir}/src/test/javascript/features</testSourceDirectory>
                            <testSuites>
                                <testSuite>
                                    <name>FeatureTests</name>
                                    <type>TESTCASES</type>
                                    <includes>
                                        <include>mocks/*.js</include>
                                        <include>**/*test.js</include>
                                    </includes>
                                </testSuite>
                            </testSuites>
                        </configuration>
                        <goals>
                            <goal>jsunit-test</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>net.sf.alchim</groupId>
                <artifactId>yuicompressor-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <goals>
                            <goal>compress</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <suffix>.opt</suffix>
                    <excludes>
                        <exclude>**/*.xml</exclude>
                        <!-- Caja is already minified -->
                        <exclude>**/caja/*.js</exclude>
                    </excludes>
                    <jswarn>false</jswarn>
                    <statistics>false</statistics>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>reporting</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-dependency-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>create-jsdoc-home</id>
                                <phase>site</phase>
                                <goals>
                                    <goal>unpack</goal>
                                </goals>
                                <configuration>
                                    <artifactItems>
                                        <artifactItem>
                                            <groupId>org.jsdoctoolkit</groupId>
                                            <artifactId>jsdoc</artifactId>
                                            <version>2.1.0</version>
                                            <type>jar</type>
                                            <overWrite>true</overWrite>
                                            <outputDirectory>${project.build.directory}/jsdoc-toolkit</outputDirectory>
                                        </artifactItem>
                                    </artifactItems>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-antrun-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>run-jsdoc</id>
                                <phase>site</phase>
                                <configuration>
                                    <tasks>
                                        <taskdef name="jsdoctoolkit" classname="uk.co.darrenhurley.ant.tasks.JsDocToolkit" />

                                        <mkdir dir="${project.reporting.outputDirectory}/jsdoc" />

                                        <jsdoctoolkit jsdochome="${project.build.directory}/jsdoc-toolkit/" template="jsdoc" outputdir="${project.reporting.outputDirectory}/jsdoc">
                                            <fileset dir="${basedir}/src/main/javascript/features">
                                                <include name="**/*.js" />
                                            </fileset>
                                        </jsdoctoolkit>
                                    </tasks>
                                </configuration>
                                <goals>
                                    <goal>run</goal>
                                </goals>
                            </execution>
                        </executions>
                        <dependencies>
                            <dependency>
                                <groupId>org.jsdoctoolkit</groupId>
                                <artifactId>jsdoctoolkit-ant-task</artifactId>
                                <version>1.0</version>
                                <exclusions>
                                    <exclusion>
                                        <groupId>ant</groupId>
                                        <artifactId>ant-contrib</artifactId>
                                    </exclusion>
                                </exclusions>
                            </dependency>
                            <dependency>
                                <groupId>rhino</groupId>
                                <artifactId>js</artifactId>
                                <version>1.7R1</version>
                            </dependency>
                        </dependencies>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
