<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>
    <groupId>org.openqa.selenium.core</groupId>
    <artifactId>selenium-core</artifactId>
    <version>0.8.3</version>
    <name>Selenium Core</name>
    <packaging>jar</packaging>
    <url>http://www.openqa.org/selenium-core</url>
    <repositories>
        <repository>
            <id>openqa</id>
            <name>OpenQA Maven Repository</name>
            <url>http://maven.openqa.org</url>
        </repository>
        <repository>
            <id>apache.snapshots</id>
            <name>Maven Snapshot Repository</name>
            <url>http://people.apache.org/maven-snapshot-repository</url>
            <snapshots>
                <enabled>true</enabled>
                <updatePolicy>daily</updatePolicy>
            </snapshots>
            <releases>
                <enabled>false</enabled>
                <updatePolicy>never</updatePolicy>
            </releases>
        </repository>
    </repositories>
    <build>
        <plugins>
            <plugin>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <skip>true</skip>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-antrun-plugin</artifactId>
                <version>1.2-SNAPSHOT</version>
                <executions>
                    <execution>
                        <id>compile</id>
                        <phase>compile</phase>
                        <configuration>
                            <tasks>
                                <exec executable="svnversion" outputProperty="svn-revision" failOnError="true">
                                    <arg value="."/>
                                </exec>

                                <copy todir="target/classes" overwrite="true">
                                    <fileset dir="src/main/resources">
                                        <include name="core/scripts/selenium-version.js"/>
                                        <include name="VERSION.txt"/>
                                    </fileset>
                                    <filterset>
                                        <filter token="VERSION" value="${project.version}"/>
                                        <filter token="REVISION" value="${svn-revision}"/>
                                    </filterset>
                                </copy>
                                
                                <copy file="target/classes/core/TestRunner.html" tofile="target/classes/core/TestRunner.hta" />

                                <mkdir dir="target/classes/core"/>
                                <java jar="${maven.dependency.rhino.js.jar.path}" output="target/classes/core/iedoc.xml" failonerror="true" fork="true">
                                    <arg file="src/main/resources/doctool/doc.js"/>
                                    <arg file="src/main/resources/core/scripts/selenium-api.js"/>
                                    <arg file="src/main/resources/core/scripts/selenium-remoterunner.js"/>
                                </java>
                                <!--<xmlvalidate file="target/classes/core/iedoc.xml" lenient="true"/>-->
                                <java jar="${maven.dependency.rhino.js.jar.path}" output="target/classes/core/iedoc-core.xml" failonerror="true" fork="true">
                                    <arg file="src/main/resources/doctool/doc.js"/>
                                    <arg file="src/main/resources/core/scripts/selenium-api.js"/>
                                    <arg file="src/main/resources/core/scripts/selenium-testrunner.js"/>
                                </java>
                                <!--<xmlvalidate file="target/classes/core/iedoc-core.xml" lenient="true"/>-->

                                <xslt in="target/classes/core/iedoc-core.xml" out="target/classes/reference.html" style="src/main/resources/doctool/doc2html.xml"/>
                            </tasks>
                        </configuration>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </execution>
                </executions>
                <dependencies>
                    <dependency>
                        <groupId>ant</groupId>
                        <artifactId>ant-trax</artifactId>
                        <version>1.6.5</version>
                    </dependency>
                    <dependency>
                        <groupId>ant</groupId>
                        <artifactId>ant-nodeps</artifactId>
                        <version>1.6.5</version>
                    </dependency>
                    <dependency>
                        <groupId>ant</groupId>
                        <artifactId>ant-junit</artifactId>
                        <version>1.6.5</version>
                    </dependency>
                    <dependency>
                        <groupId>junit</groupId>
                        <artifactId>junit</artifactId>
                        <version>3.8.1</version>
                    </dependency>
                </dependencies>
            </plugin>
            <plugin>
                <artifactId>maven-clean-plugin</artifactId>
                <configuration>
                    <filesets>
                        <fileset>
                            <directory>.</directory>
                            <includes>
                                <include>results-*.html</include>
                            </includes>
                        </fileset>
                    </filesets>
                </configuration>
            </plugin>
        </plugins>
    </build>
    <profiles>
        <profile>
            <id>test</id>
            <activation>
                <property>
                    <name>!notest</name>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <artifactId>maven-antrun-plugin</artifactId>
                        <version>1.2-SNAPSHOT</version>
                        <executions>
                            <execution>
                                <id>test</id>
                                <phase>test</phase>
                                <configuration>
                                    <tasks>
                                        <condition property="browserFileNames" value="${firefox}">
                                            <available file="${firefox}"/>
                                        </condition>
                                        <condition property="browserFileNames" value="c:\program files\Mozilla Firefox\firefox.exe">
                                            <os family="windows"/>
                                        </condition>
                                        <condition property="browserFileNames" value="/Applications/Firefox.app/Contents/MacOS/firefox-bin">
                                            <os family="mac"/>
                                        </condition>
                                        <condition property="browserFileNames" value="/usr/bin/firefox">
                                            <os family="unix"/>
                                        </condition>
                                        <property name="testRunnerLocation" location="src/main/resources/jsunit/testRunner.html"/>
                                        <property name="testSuiteLocation" location="src/main/resources/unittest/browserbot/suite.html"/>
                                        <property name="port" value="8281"/>
                                        <property name="browserBotTestUrl"
                                                  value="file://${testRunnerLocation}?testPage=${testSuiteLocation}&amp;autoRun=true&amp;submitresults=localhost:${port}/jsunit/acceptor"/>
                                        <property name="resourceBase" value=""/>
                                        <property name="logsDirectory" value="target/logs"/>

                                        <mkdir dir="target/logs"/>
                                        <junit showoutput="true" errorproperty="tests.failed" failureproperty="tests.failed">
                                            <classpath>
                                                <fileset dir="code/java/lib">
                                                    <include name="*.jar"/>
                                                </fileset>
                                            </classpath>
                                            <sysproperty key="browserFileNames" value="${browserFileNames}"/>
                                            <sysproperty key="url" value="${browserBotTestUrl}"/>
                                            <sysproperty key="port" value="${port}"/>
                                            <sysproperty key="resourceBase" value="${resourceBase}"/>
                                            <sysproperty key="logsDirectory" value="target/logs"/>
                                            <test name="net.jsunit.StandaloneTest"/>
                                        </junit>
                                        <junitreport todir="target/logs">
                                            <fileset dir="target/logs"/>
                                            <report format="frames" todir="target/logs" />
                                        </junitreport>
                                        <fail if="tests.failed" message="JSUnit tests failed, see output for details: target/logs" />
                                    </tasks>
                                </configuration>
                                <goals>
                                    <goal>run</goal>
                                </goals>
                            </execution>
                        </executions>
                        <dependencies>
                            <dependency>
                                <groupId>ant</groupId>
                                <artifactId>ant-trax</artifactId>
                                <version>1.6.5</version>
                            </dependency>
                            <dependency>
                                <groupId>ant</groupId>
                                <artifactId>ant-junit</artifactId>
                                <version>1.6.5</version>
                            </dependency>
                            <dependency>
                                <groupId>junit</groupId>
                                <artifactId>junit</artifactId>
                                <version>3.8.1</version>
                            </dependency>
                        </dependencies>
                    </plugin>
                </plugins>
            </build>
        </profile>
        
        <profile>
            <id>integration-test-firefox</id>
            <activation>
                <property>
                    <name>!notest</name>
                </property>
            </activation>
            <properties>
                <slowResources>false</slowResources>
                <multiWindow>true</multiWindow>
                <browser>*firefox</browser>
                <seleneseSuite>TestSuite</seleneseSuite>
            </properties>
            <build>
                <plugins>
                    <plugin>
                        <artifactId>maven-antrun-plugin</artifactId>
                        <version>1.2-SNAPSHOT</version>
                        <executions>
                            <execution>
                                <id>integration-test</id>
                                <phase>integration-test</phase>
                                <configuration>
                                    <tasks>
                                        <taskdef resource="selenium-ant.properties">
                                            <classpath refid="maven.dependency.classpath" />
                                        </taskdef>
                                        <selenese 
                                            browser="${browser}"
                                            suite="src/main/resources/tests/${seleneseSuite}.html"
                                            port="4444"
                                            slowResources="${slowResources}"
                                            multiWindow="${multiWindow}"
                                            startURL="http://localhost:4444" />
                                    </tasks>
                                </configuration>
                                <goals>
                                    <goal>run</goal>
                                </goals>
                            </execution>
                        </executions>
                        <dependencies>
                            <dependency>
                                <groupId>ant</groupId>
                                <artifactId>ant-trax</artifactId>
                                <version>1.6.5</version>
                            </dependency>
                            <dependency>
                                <groupId>ant</groupId>
                                <artifactId>ant-junit</artifactId>
                                <version>1.6.5</version>
                            </dependency>
                            <dependency>
                                <groupId>junit</groupId>
                                <artifactId>junit</artifactId>
                                <version>3.8.1</version>
                            </dependency>
                        </dependencies>
                    </plugin>
                </plugins>
            </build>
        </profile>
        
        
        
    </profiles>
    <pluginRepositories>
        <pluginRepository>
            <id>snapshots</id>
            <name>Maven Plugin Snapshot Repository</name>
            <url>http://people.apache.org/maven-snapshot-repository</url>
            <layout>default</layout>
            <snapshots>
                <enabled>true</enabled>
                <updatePolicy>daily</updatePolicy>
            </snapshots>
            <releases>
                <enabled>false</enabled>
                <updatePolicy>never</updatePolicy>
            </releases>
        </pluginRepository>
    </pluginRepositories>
    <distributionManagement>
        <repository>
            <id>openqa</id>
            <name>OpenQA Maven Repository</name>
            <url>scp://maven.openqa.org/home/maven/maven.openqa.org/htdocs</url>
        </repository>
    </distributionManagement>
    <dependencies>
        <!--
        <dependency>
            <groupId>jsunit</groupId>
            <artifactId>jsunit</artifactId>
            <version>2.1</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>jetty</groupId>
            <artifactId>org.mortbay.jetty</artifactId>
            <version>5.1.10</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>commons-logging</groupId>
            <artifactId>commons-logging</artifactId>
            <version>1.0.4</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>2.4</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>jdom</groupId>
            <artifactId>jdom</artifactId>
            <version>1.0</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>xerces</groupId>
            <artifactId>xercesImpl</artifactId>
            <version>2.8.0</version>
            <scope>test</scope>
        </dependency>
        -->
        <dependency>
            <groupId>org.openqa.selenium.server</groupId>
            <artifactId>selenium-server-coreless</artifactId>
            <version>0.9.1</version>
        </dependency>
        <dependency>
            <groupId>rhino</groupId>
            <artifactId>js</artifactId>
            <version>1.6R5</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>3.8.1</version>
        </dependency>
    </dependencies>
</project>
