<?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.gwtplatform</groupId>
        <artifactId>gwtp-core</artifactId>
        <version>0.7</version>
    </parent>

    <artifactId>gwtp-all</artifactId>
    <packaging>jar</packaging>
    <name>GWTP all (compound jar)</name>

    <properties>
        <maven-assembly-plugin.version>2.2</maven-assembly-plugin.version>
    </properties>

    <!-- The compound jar consist of the following dependencies -->
    <dependencies>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>gwtp-mvp-client</artifactId>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>gwtp-clients-common</artifactId>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>gwtp-dispatch-client</artifactId>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>gwtp-dispatch-shared</artifactId>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>gwtp-dispatch-server</artifactId>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>gwtp-dispatch-server-guice</artifactId>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>gwtp-dispatch-server-spring</artifactId>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>gwtp-tester</artifactId>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>gwtp-processors</artifactId>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>gwtp-crawler</artifactId>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>gwtp-crawler-service</artifactId>
            <scope>compile</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-assembly-plugin</artifactId>
                <version>${maven-assembly-plugin.version}</version>
                <executions>
                    <!-- Build compound jar -->
                    <execution>
                        <id>all-binary</id>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                        <configuration>
                            <descriptors>
                                <descriptor>src/assemble/all-binary.xml</descriptor>
                            </descriptors>
                            <appendAssemblyId>false</appendAssemblyId>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <!-- Use 'release' profile to attach to the build the
        compound sources jar and the compound javadoc jar. -->
        <profile>
            <id>release</id>

            <properties>
                <unpackedDependenciesDir>${project.build.directory}/exploded-modules</unpackedDependenciesDir>
                <unpackedJavadocDir>${project.build.directory}/apidocs</unpackedJavadocDir>
                <javadocArtifactFile>${project.build.directory}/${project.build.finalName}-javadoc.jar</javadocArtifactFile>
            </properties>

            <!-- The sources for each module -->
            <dependencies>
                <dependency>
                    <groupId>${project.groupId}</groupId>
                    <artifactId>gwtp-mvp-client</artifactId>
                    <version>${project.version}</version>
                    <classifier>sources</classifier>
                </dependency>
                <dependency>
                    <groupId>${project.groupId}</groupId>
                    <artifactId>gwtp-clients-common</artifactId>
                    <version>${project.version}</version>
                    <classifier>sources</classifier>
                </dependency>
                <dependency>
                    <groupId>${project.groupId}</groupId>
                    <artifactId>gwtp-dispatch-client</artifactId>
                    <version>${project.version}</version>
                    <classifier>sources</classifier>
                </dependency>
                <dependency>
                    <groupId>${project.groupId}</groupId>
                    <artifactId>gwtp-dispatch-shared</artifactId>
                    <version>${project.version}</version>
                    <classifier>sources</classifier>
                </dependency>
                <dependency>
                    <groupId>${project.groupId}</groupId>
                    <artifactId>gwtp-dispatch-server</artifactId>
                    <version>${project.version}</version>
                    <classifier>sources</classifier>
                </dependency>
                <dependency>
                    <groupId>${project.groupId}</groupId>
                    <artifactId>gwtp-dispatch-server-guice</artifactId>
                    <version>${project.version}</version>
                    <classifier>sources</classifier>
                </dependency>
                <dependency>
                    <groupId>${project.groupId}</groupId>
                    <artifactId>gwtp-dispatch-server-spring</artifactId>
                    <version>${project.version}</version>
                    <classifier>sources</classifier>
                </dependency>
                <dependency>
                    <groupId>${project.groupId}</groupId>
                    <artifactId>gwtp-tester</artifactId>
                    <version>${project.version}</version>
                    <classifier>sources</classifier>
                </dependency>
                <dependency>
                    <groupId>${project.groupId}</groupId>
                    <artifactId>gwtp-processors</artifactId>
                    <version>${project.version}</version>
                    <classifier>sources</classifier>
                </dependency>
                <dependency>
                    <groupId>${project.groupId}</groupId>
                    <artifactId>gwtp-crawler</artifactId>
                    <version>${project.version}</version>
                    <classifier>sources</classifier>
                </dependency>

                <!-- This is needed in order for the classes from gwt-dev that
                (are used in ProxyGenerator class) to be resolved while creating the javadoc -->
                <dependency>
                    <groupId>com.google.gwt</groupId>
                    <artifactId>gwt-dev</artifactId>
                    <scope>provided</scope>
                </dependency>
            </dependencies>

            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-assembly-plugin</artifactId>
                        <version>${maven-assembly-plugin.version}</version>
                        <executions>
                            <!-- Build all-sources jar -->
                            <execution>
                                <id>all-sources</id>
                                <phase>package</phase>
                                <goals>
                                    <goal>single</goal>
                                </goals>
                                <configuration>
                                    <descriptors>
                                        <descriptor>src/assemble/all-sources.xml</descriptor>
                                    </descriptors>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>

                    <!-- Unpack the sources into ${explodedModulesDir}. This is the
                    first step to create the compound javadoc. -->
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-dependency-plugin</artifactId>
                        <version>2.1</version>
                        <executions>
                            <execution>
                                <id>unpack-dependencies</id>
                                <phase>generate-resources</phase>
                                <goals>
                                    <goal>unpack-dependencies</goal>
                                </goals>
                                <configuration>
                                    <!--<classifier>sources</classifier>-->
                                    <includeClassifiers>sources</includeClassifiers>
                                    <excludeTransitive>true</excludeTransitive>
                                    <excludeArtifactIds>junit</excludeArtifactIds>
                                    <outputDirectory>${unpackedDependenciesDir}</outputDirectory>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>

                    <!-- Generate the compound javadoc with the help of ant.
                    - javadoc target generates the javadoc
                    - jar target jars the generated javadoc -->
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-antrun-plugin</artifactId>
                        <version>1.6</version>
                        <executions>
                            <!-- Generate the javadoc -->
                            <execution>
                                <id>generate-all-javadoc</id>
                                <phase>compile</phase>
                                <configuration>
                                    <target>
                                        <javadoc packagenames="com.gwtplatform.*" maxmemory="256m" sourcepath="${unpackedDependenciesDir}" defaultexcludes="yes" destdir="${unpackedJavadocDir}" version="true" use="true" windowtitle="${project.name} ${project.version} API.">
                                            <doctitle>
                                                <![CDATA[<h1>${project.name} ${project.version} API</h1>]]>
                                            </doctitle>
                                            <bottom>
                                                <![CDATA[<i>Copyright &#169; ${project.inceptionYear}
                                                <a href="${project.organization.url}">${project.organization.name}</a>.
                                                All Rights Reserved.</i>]]>
                                            </bottom>
                                            <classpath refid="maven.compile.classpath" />
                                            <link href="http://download.oracle.com/javase/6/docs/api/" />
                                            <link href="http://google-web-toolkit.googlecode.com/svn/javadoc/2.0/" />
                                            <link href="http://static.springsource.org/spring/docs/3.0.x/javadoc-api/" />
                                            <link href="http://google-gin.googlecode.com/svn/trunk/javadoc/" />
                                            <link href="http://google-guice.googlecode.com/svn/trunk/javadoc/" />
                                            <link href="http://aopalliance.sourceforge.net/doc/" />
                                        </javadoc>
                                        <jar destfile="${javadocArtifactFile}" basedir="${unpackedJavadocDir}" includes="**/**" />
                                    </target>
                                </configuration>
                                <goals>
                                    <goal>run</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>

                    <!-- Attach the compound javadoc jar to be installed and deployed -->
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>build-helper-maven-plugin</artifactId>
                        <version>1.5</version>
                        <executions>
                            <execution>
                                <id>attach-artifacts</id>
                                <phase>package</phase>
                                <goals>
                                    <goal>attach-artifact</goal>
                                </goals>
                                <configuration>
                                    <artifacts>
                                        <artifact>
                                            <file>${javadocArtifactFile}</file>
                                            <type>jar</type>
                                            <classifier>javadoc</classifier>
                                        </artifact>
                                    </artifacts>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

</project>