<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>org.openqa.selenium</groupId>
        <version>0.9.2</version>
        <artifactId>selenium-rc</artifactId>
    </parent>
    <groupId>org.openqa.selenium.server</groupId>
    <artifactId>selenium-server</artifactId>
    <packaging>jar</packaging>
    <name>Selenium RC Server</name>
    <build>
        <plugins>
            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <version>2.2-beta-2-SNAPSHOT</version>
                <configuration>
                    <descriptor>src/main/assembly/dep.xml</descriptor>
                    <archive>
                        <manifest>
                            <mainClass>org.openqa.selenium.server.SeleniumServer</mainClass>
                        </manifest>
                    </archive>
                </configuration>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                    </execution>
                </executions>
            </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>
                                
                                <unzip src="${maven.dependency.org.openqa.selenium.core.selenium-core.jar.path}" dest="target/classes">
                                    <patternset>
                                        <include name="VERSION.txt"/>
                                    </patternset>
                                </unzip>
                                
                                <propertyfile file="target/classes/VERSION.txt">
                                    <entry key="selenium.rc.version" value="${project.version}" />
                                    <entry key="selenium.rc.revision" value="${svn-revision}" />
                                </propertyfile>
                                <property file="target/classes/VERSION.txt" />
                                
                                <copy todir="target/classes" overwrite="true">
                                    <fileset dir="src/main/resources">
                                        <include name="core/scripts/selenium-version.js"/>
                                    </fileset>
                                    <filterset>
                                        <filter token="COREVERSION" value="${selenium.core.version}"/>
                                        <filter token="COREREVISION" value="${selenium.core.revision}"/>
                                        <filter token="RCVERSION" value="${project.version}"/>
                                        <filter token="RCREVISION" value="${svn-revision}"/>
                                    </filterset>
                                </copy>
                            </tasks>
                        </configuration>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </execution>
                    <execution>
	                    <id>fixup-bouncy-castle</id>
                        <phase>verify</phase>
                        <goals>
                            <goal>run</goal>
                        </goals>
                        <configuration>
                            <tasks>
								<!-- we do the following after the assembly plugin because we can't 
								     let the bouncy castle signature entries get dumped in to the 
								     main jar w/o re-signing the jar, which we don't want to do. 
								     so this simple trick removes the two files that tip java off
								     to any sort of security in the first place, which is fine with us.-->
								<move file="target/selenium-server-${project.version}-standalone.jar" 
									  tofile="target/selenium-server-${project.version}-standalone.bak"/>
								<jar destfile="target/selenium-server-${project.version}-standalone.jar">
									<zipfileset src="target/selenium-server-${project.version}-standalone.bak" 
										        excludes="META-INF/BCKEY.DSA,META-INF/BCKEY.SF"/>
									<manifest>
								      <attribute name="Main-Class" value="org.openqa.selenium.server.SeleniumServer"/>
								    </manifest>
								</jar>
								<delete file="target/selenium-server-${project.version}-standalone.bak"/>
                            </tasks>
                        </configuration>
                    </execution>
                </executions>
                <dependencies>
                    <dependency>
                        <groupId>ant</groupId>
                        <artifactId>ant-nodeps</artifactId>
                        <version>1.6.5</version>
                    </dependency>
                    <dependency>
                        <groupId>ant</groupId>
                        <artifactId>ant-trax</artifactId>
                        <version>1.6.5</version>
                    </dependency>
                </dependencies>
            </plugin>
        </plugins>
    </build>
    <dependencies>
        <dependency>
            <groupId>org.openqa.selenium.server</groupId>
            <artifactId>selenium-server-coreless</artifactId>
        </dependency>
        <dependency>
            <groupId>org.openqa.selenium.core</groupId>
            <artifactId>selenium-core</artifactId>
        </dependency>
    </dependencies>
</project>
