<?xml version="1.0" encoding="UTF-8"?>

<!-- ====================================================================== -->
<!--                                                                        -->
<!--  JBoss, the OpenSource J2EE webOS                                      -->
<!--                                                                        -->
<!--  Distributable under LGPL license.                                     -->
<!--  See terms of license at http://www.gnu.org.                           -->
<!--                                                                        -->
<!-- ====================================================================== -->

<!-- $Id: build-release.xml 9055 2009-01-16 13:36:34Z darran.lofthouse@jboss.com $ -->

<project>

  <target name="release" depends="release-to-repository,release-to-portal" description="Release JBossWS">
    <echo message="*********************************************"/>
    <echo message="* Released: jbossws-${version.id}"/>
    <echo message="*"/>
    <echo message="* Almost there, please do these steps manually"/>
    <echo message="*"/>
    <echo message="*  - Create SVN tag: jbossws-native-${version.id}"/>
    <echo message="*  - Release the jbossws-${version.id} version in JIRA"/>
    <echo message="*  - Update portal-content/project.xml"/>
    <echo message="*  - Update portal-content/counter.xml"/>
    <echo message="*  - Update news in portal-content/freezone/projectDescription.html"/>
    <echo message="*  - Verify release notes and install instructions"/>
    <echo message="*  - Publish the interop endpoints"/>
    <echo message="*  - Commit the portal-content"/>
    <echo message="*  - Commit the repository jars"/>
    <echo message="*  - Write a sticky post on the user forum"/>
    <echo message="*  - Post a message to jbossws-announce@lists.jboss.org"/>
    <echo message="*  - Post a message to thecore@jboss.org"/>
    <echo message="*"/>
    <echo message="*********************************************"/>
  </target>
  
  <!-- Release to jboss.local.repository -->
  <target name="release-to-repository" depends="jars,check-svn-externals,warn-svn-externals" 
    description="Release to jboss.local.repository">

    <!-- jboss/jbossws -->
    <property name="jboss.repository.dir" value="${jboss.local.repository}/jboss"/>
    <mkdir dir="${jboss.repository.dir}/jbossws/${repository.id}/lib"/>
    <copy todir="${jboss.repository.dir}/jbossws/${repository.id}/lib" overwrite="true">
      <fileset dir="${core.output.lib.dir}">
        <include name="jbossws-client.jar"/>
        <include name="jbossws-core.jar"/>
        <include name="jboss-jaxrpc.jar"/>
        <include name="jboss-jaxws.jar"/>
        <include name="jboss-saaj.jar"/>
        <include name="jbossws-core-src.zip"/>
        <include name="jbossws-core-scripts.zip"/>
      </fileset>
    </copy>
    <copy tofile="${jboss.repository.dir}/jbossws/${repository.id}/component-info.xml" file="${core.output.etc.dir}/component-info.xml" filtering="true" overwrite="true">
      <filterset>
        <filtersfile file="${core.dir}/version.properties"/>
      </filterset>
    </copy>
	  
    <!-- jboss/jbossws-native50 -->
    <property name="jboss.repository.dir" value="${jboss.local.repository}/jboss"/>
    <mkdir dir="${jboss.repository.dir}/jbossws-native50/${repository.id}/lib"/>
    <copy todir="${jboss.repository.dir}/jbossws-native50/${repository.id}/lib" overwrite="true">
      <fileset dir="${core.dir}/output/lib">
        <include name="jbossws-native50.sar"/>
        <include name="jbossws-native50-deployer.zip"/>
      </fileset>
    </copy>
    <copy tofile="${jboss.repository.dir}/jbossws-native50/${repository.id}/component-info.xml" file="${core.etc.dir}/component-info50.xml" filtering="true" overwrite="true">
      <filterset>
        <filtersfile file="${core.dir}/version.properties"/>
      </filterset>
    </copy>
    
    <!-- jboss/jbossws-native42 -->
    <property name="jboss.repository.dir" value="${jboss.local.repository}/jboss"/>
    <mkdir dir="${jboss.repository.dir}/jbossws-native42/${repository.id}/lib"/>
    <copy todir="${jboss.repository.dir}/jbossws-native42/${repository.id}/lib" overwrite="true">
      <fileset dir="${core.dir}/output/lib">
        <include name="jbossws-native42.sar"/>
      </fileset>
    </copy>
    <copy tofile="${jboss.repository.dir}/jbossws-native42/${repository.id}/component-info.xml" file="${core.etc.dir}/component-info42.xml" filtering="true" overwrite="true">
      <filterset>
        <filtersfile file="${core.dir}/version.properties"/>
      </filterset>
    </copy>
    
    <!-- jboss/jbossws-native40 -->
    <property name="jboss.repository.dir" value="${jboss.local.repository}/jboss"/>
    <mkdir dir="${jboss.repository.dir}/jbossws-native40/${repository.id}/lib"/>
    <copy todir="${jboss.repository.dir}/jbossws-native40/${repository.id}/lib" overwrite="true">
      <fileset dir="${core.dir}/output/lib">
        <include name="jbossws-native40.sar"/>
      </fileset>
    </copy>
    <copy tofile="${jboss.repository.dir}/jbossws-native40/${repository.id}/component-info.xml" file="${core.etc.dir}/component-info40.xml" filtering="true" overwrite="true">
      <filterset>
        <filtersfile file="${core.dir}/version.properties"/>
      </filterset>
    </copy>
  </target>

  <target name="check-svn-externals" depends="init">
    <exec dir="${core.dir}/src/test-framework" executable="svn" failonerror="true" output="${core.dir}/output/svn-info.xml">
      <arg line="info"/>
      <arg line="--xml"/>
    </exec>
    <xmlproperty file="${core.dir}/output/svn-info.xml"/>
    <condition property="framework.externals.ok">
      <or>
        <contains string="${info.entry.url}" substring="http://anonsvn.jboss.org/repos/jbossws/framework/tags"/>
        <equals arg1="${repository.id}" arg2="snapshot"/>
      </or>
    </condition>
  </target>
  <target name="warn-svn-externals" depends="init" unless="framework.externals.ok">
    <echo>
      ***********************************************
      *  External link to framework is not tagged!  *
      *  Run: svn pe svn:externals src              *
      ***********************************************
    </echo>
  </target>
  
  <!-- Release to portal content -->
  <target name="release-to-portal" depends="check-portal-content,build-src-dist,build-bin-dist" 
    description="Release to portal-content" if="jbossws.portal.content.available">
    
    <property name="portal.freezone" value="${jbossws.portal.content}/freezone"/>
    <property name="portal.userguide" value="${portal.freezone}/user-guide"/>
    <property name="portal.downloads" value="${jbossws.portal.content}/downloads"/>
    
    <!-- Copy downloads -->
    <copy todir="${portal.downloads}" overwrite="true">
      <fileset dir="${core.dir}/output">
        <include name="jbossws-src-${version.id}.zip"/>
        <include name="jbossws-native-${version.id}.zip"/>
      </fileset>
    </copy>
    
    <!-- Copy Release Notes -->
    <copy tofile="${portal.downloads}/ReleaseNotes-${version.id}.txt" file="${core.dir}/output/jbossws-native-${version.id}/docs/ReleaseNotes.txt" overwrite="true"/>
    <copy tofile="${portal.downloads}/Install-${version.id}.txt" file="${core.dir}/output/jbossws-native-${version.id}/docs/Install.txt" overwrite="true"/>
  </target>
  
  <target name="check-portal-content" depends="prepare" unless="jbossws.portal.content.available">
    <echo message="*********************************************"/>
    <echo message="* Not available: ${jbossws.portal.content}"/>
    <echo message="*********************************************"/>
  </target>
  
  <!-- ================================================================== -->
  <!-- Build source distributions                                                -->
  <!-- ================================================================== -->

  <!-- Build the src dist -->
  <target name="build-src-dist" description="Build the source distribution">
    <property name="build.src.dist" value="${core.dir}/output/src-dist"/>
    <delete dir="${build.src.dist}/jbossws-src-${version.id}"/>
    <mkdir dir="${build.src.dist}/jbossws-src-${version.id}"/>
    <copy todir="${build.src.dist}/jbossws-src-${version.id}">
      <fileset dir="${basedir}">
        <exclude name="**/*.md5"/>
        <exclude name="**/output*/**"/>
        <exclude name="**/thirdparty/**"/>
        <exclude name="mergeinfo.txt"/>
      </fileset>
    </copy>
    <zip destfile="${core.dir}/output/jbossws-src-${version.id}.zip" basedir="${build.src.dist}"
      includes="jbossws-src-${version.id}/**"/>
  </target>
  
</project>
