<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>
        <groupId>org.cometd.javascript</groupId>
        <artifactId>cometd-javascript-project</artifactId>
        <version>3.0.8</version>
    </parent>

    <modelVersion>4.0.0</modelVersion>
    <artifactId>cometd-javascript-dojo</artifactId>
    <packaging>war</packaging>
    <name>CometD :: JavaScript :: Dojo</name>

    <build>
        <plugins>
            <plugin>
                <artifactId>maven-antrun-plugin</artifactId>
                <executions>
                    <execution>
                        <id>main</id>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>run</goal>
                        </goals>
                        <configuration>
                            <target>
                                <copy file="${basedir}/src/main/webapp/dojox/cometd/main.js" tofile="${project.build.directory}/${project.build.finalName}/dojox/cometd.js" />
                            </target>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <artifactId>maven-war-plugin</artifactId>
                <configuration>
                    <overlays>
                        <overlay />
                        <overlay>
                            <groupId>org.cometd.javascript</groupId>
                            <artifactId>cometd-javascript-common</artifactId>
                        </overlay>
                        <overlay>
                            <groupId>org.dojotoolkit</groupId>
                            <artifactId>dojo-war</artifactId>
                            <excludes>
                                <exclude>META-INF/**</exclude>
                                <exclude>dojox/cometd.js*</exclude>
                                <exclude>dojox/cometd</exclude>
                                <exclude>dojox/cometd/**</exclude>
                            </excludes>
                        </overlay>
                    </overlays>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>sync-dojo</id>
            <activation>
                <property>
                    <name>performRelease</name>
                    <value>true</value>
                </property>
            </activation>
            <properties>
                <cometd-dojo-dir>${project.build.directory}/cometd-dojo</cometd-dojo-dir>
                <cometd-dojo-fetch>scm:git:git@github.com:cometd/cometd-dojo.git</cometd-dojo-fetch>
                <cometd-dojo-push>scm:git:ssh://git@github.com/cometd/cometd-dojo.git</cometd-dojo-push>
            </properties>
            <build>
                <plugins>
                    <plugin>
                        <artifactId>maven-scm-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>clone</id>
                                <phase>pre-integration-test</phase>
                                <goals>
                                    <goal>checkout</goal>
                                </goals>
                                <configuration>
                                    <checkoutDirectory>${cometd-dojo-dir}</checkoutDirectory>
                                    <connectionUrl>${cometd-dojo-fetch}</connectionUrl>
                                    <developerConnectionUrl>${cometd-dojo-push}</developerConnectionUrl>
                                </configuration>
                            </execution>
                            <execution>
                                <id>push</id>
                                <phase>post-integration-test</phase>
                                <goals>
                                    <goal>checkin</goal>
                                </goals>
                                <configuration>
                                    <basedir>${cometd-dojo-dir}</basedir>
                                    <includes>cometd.js,cometd/**,org/**</includes>
                                    <message>Synchronizing ${project.version}</message>
                                    <connectionUrl>${cometd-dojo-fetch}</connectionUrl>
                                    <developerConnectionUrl>${cometd-dojo-push}</developerConnectionUrl>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <artifactId>maven-antrun-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>sync</id>
                                <phase>integration-test</phase>
                                <goals>
                                    <goal>run</goal>
                                </goals>
                                <configuration>
                                    <target>
                                        <copy todir="${cometd-dojo-dir}">
                                            <fileset dir="${project.build.directory}/${project.build.finalName}">
                                                <include name="org/**" />
                                            </fileset>
                                            <fileset dir="${project.build.directory}/${project.build.finalName}/dojox">
                                                <include name="cometd.js" />
                                                <include name="cometd/**" />
                                            </fileset>
                                        </copy>
                                    </target>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

    <dependencies>
        <dependency>
            <groupId>org.cometd.javascript</groupId>
            <artifactId>cometd-javascript-common</artifactId>
            <version>${project.version}</version>
            <type>war</type>
        </dependency>
        <dependency>
            <groupId>org.dojotoolkit</groupId>
            <artifactId>dojo-war</artifactId>
            <version>${dojo-version}</version>
            <type>war</type>
        </dependency>
    </dependencies>

</project>
