<?xml version="1.0"?>
<project name="Drools" basedir="." default="usage">

  <target name="usage">
    <echo>ant -f update-version.xml -Dcurrent="5.0-SNAPSHOT" -Dnew="5.0.0" -Dosgi.current="5.0.0.SNAPSHOT" -Dosgi.new="5.0.0" updateVersion</echo>
  </target>

  <target name="updateVersion" depends="checkProps, error" unless="propsNotSet">
    <replaceregexp match="&lt;version&gt;${current}&lt;/version&gt;"
                   replace="&lt;version&gt;${new}&lt;/version&gt;" 
                   byline="true">
      <fileset dir="." includes="pom.xml, 
                                 jbpm-*/pom.xml, 
                                 jbpm-gwt/**/pom.xml,
                                 jbpm-docs/**/pom.xml"/>
    </replaceregexp>
  	<replaceregexp match="&lt;jbpm.osgi.version&gt;${osgi.current}&lt;/jbpm.osgi.version&gt;"
  	               replace="&lt;jbpm.osgi.version&gt;${osgi.new}&lt;/jbpm.osgi.version&gt;" 
  	               byline="true">
  	  <fileset dir="." includes="pom.xml"/>
  	</replaceregexp>
    <replaceregexp match="&lt;releaseinfo&gt;${current}&lt;/releaseinfo&gt;"
                   replace="&lt;releaseinfo&gt;${new}&lt;/releaseinfo&gt;" 
                   byline="true">
      <fileset dir="." includes="jbpm-docs/src/main/docbook/**/master.xml"/>
    </replaceregexp> 
    <replaceregexp match="jBPM.version=${current}"
                   replace="jBPM.version=${new}" 
                   byline="true">
      <fileset dir="." includes="jbpm-installer/build.properties"/>
    </replaceregexp>             
    <replaceregexp match="jBPM.version=${current}"
                   replace="jBPM.version=${new}" 
                   byline="true">
      <fileset dir="." includes="jbpm-installer/build.properties"/>
    </replaceregexp> 
    <replaceregexp match="jBPM.url=http://hudson.jboss.org/hudson/job/jBPM/lastStableBuild/artifact/jbpm-distribution/target"
                   replace="jBPM.url=http://sourceforge.net/projects/jbpm/files/jBPM%205/jbpm-${new}" 
                   byline="true">
      <fileset dir="." includes="jbpm-installer/build.properties"/>
    </replaceregexp> 
  </target>       
  
  <target name="error" if="propsNotSet">
    <echo>current and new are not set</echo>
  </target>           
  
  <target name="checkProps">
     <condition property="propsSet" value="true">
       <not>
         <isset property="current" />
       </not>
     </condition>   
     <condition property="propsNotSet" value="true">
       <not>
         <isset property="new" />
       </not>
     </condition>        
  </target>
  
</project>
