<target name="cloudify.zip" depends="prepare.env, cloudify.install, prepare.cloudify.package.without.unzip" />
Target:prepare.env——主要完成Xap的准备
完成工作:1)删除“./tmp”里的所有文件
2)创建新的“./tmp”目录
3)查看Xap,${xap.files.tmp.dir}/ ${xap.installation.dir}-b${gs.build.number}.zip是否存在,将结果存放到appropriate.xap.zip.present中。
其中${tmp.dir}=./temp
${xap.files.tmp.dir}=./xap.files.tmp.dir
${xap.installation.dir}=gigaspaces-xap-premium-${gs.version}-${gs.milestone}
${gs.version}=9.6.0
${gs.milestone}=m1
${gs.build.number}=9480-641
检查的文件是:.\xap.files.tmp.dir\gigaspaces-xap-premium-9.6.0-m1-b9480-641.zip
4)调用下载,会根据刚才的3)的结果来判断是否下载(1.1.)
5)将Xap解压到${tmp.dir}目录下。
其中:${tmp.dir}=./tmp
6)移动${tmp.dir}/${xap.installation.dir}到${tmp.dir}/${cloudify.installation.dir}
其中:即将文件夹gigaspaces-xap-premium-9.6.0-m1重名命为gigaspaces-cloudify-${cloudify.version}-${cloudify.milestone}
cloudify.version=2.6.0
cloudify.build.number=4980-309
cloudify.milestone=m1
7)将${tmp.dir}/${cloudify.installation.dir}目录下的脚本("**/*.sh, **/*groovy*")权限修改为775
<target name="prepare.env">
<loadproperties srcfile="${build.properties.file}"/>
<delete dir="${tmp.dir}"/>
<mkdir dir="${tmp.dir}"/>
<available file="${xap.files.tmp.dir}/${xap.zip.name}" property="appropriate.xap.zip.present"/>
<ant target="download.zip" />
<unzip src="${xap.files.tmp.dir}/${xap.zip.name}" dest="${tmp.dir}" />
<move file="${tmp.dir}/${xap.installation.dir}" tofile="${tmp.dir}/${cloudify.installation.dir}" />
<chmod dir="${tmp.dir}/${cloudify.installation.dir}" includes="**/*.sh, **/*groovy*" perm="775" />
</target>
完成工作:下载Xap,放在${xap.files.tmp.dir}目录下
<target name="download.zip" unless="appropriate.xap.zip.present">
<loadproperties srcfile="${build.properties.file}"/>
<mkdir dir="${xap.files.tmp.dir}" />
<echo message="Please wait. Downloading ${cloudify.cdn.publish.url}/com/gigaspaces/${s3.gs.publish.folder}/gigaspaces-xap-premium-${gs.version}-ga-b${gs.build.number}.zip." />
<get verbose="true" src="${cloudify.cdn.publish.url}/com/gigaspaces/xap-core/${s3.gs.publish.folder}/${xap.zip.name}" dest="${xap.files.tmp.dir}"/>
</target>
完成工作:将完成CLI、esc、esc-commands、USM、restful、dsl、rest-client、management-space这些模块的编译
1)在本地Respository中安装jar。在工作目录./下执行maven(maven.bat或maven),参数 clean install -Dmaven.test.skip=true
2)生成javadoc。在工作目录./下执行maven(maven.bat或maven),参数 javadoc:javadoc -Dmaven.test.skip=true
3)生成restful的Api。在${basedir}/../restful目录下,执行 maven javadoc:javadoc -Dmaven.test.skip=true
<target name="cloudify.install">
<exec dir="${basedir}" executable="${mvn.executable}" failonerror="true">
<arg line="clean install -Dmaven.test.skip=true"/>
</exec>
<exec dir="${basedir}" executable="${mvn.executable}" failonerror="true">
<arg line="javadoc:javadoc -Dmaven.test.skip=true"/>
</exec>
<exec dir="${basedir}/../restful" executable="${mvn.executable}" failonerror="true">
<arg line="javadoc:javadoc -Dmaven.test.skip=true"/>
</exec>
</target>
完成工作:
1)执行update.gs.runtime,将Cloudify版本信息加入运行环境
2)执行remove.xap.related.modules,删除./tmp/gigaspaces-cloudify-2.6.0-m1中原xap中的一些模块
3)执行update.lus.groups,更新LUS Groups
4)添加cloudify的各个模块,到. /tmp/gigaspaces-cloudify-2.6.0-m1/中
5)将一些recipe放到目标目录下,fetch.recipes.cloudify
6)移除dynamic_props.js
7)拷入notice.txt
8)dos2unix操作
9)准备发布版()
10)打包
11)删除临时文件 ./tmp
<target name="prepare.cloudify.package.without.unzip">
<loadproperties srcfile="${build.properties.file}"/>
<ant target="update.gs.runtime" />
<ant target="remove.xap.related.modules" />
<ant target="update.lus.groups"/>
<add.cloudify.modules/>
<ant target="fetch.recipes.cloudify" />
<ant target="replace.xap.content.with.cloudify.related"/>
<ant target="replace.cloudify.notice"/>
<dos2unix dir="${tmp.dir}/${cloudify.installation.dir}" />
<!-- conditional task (with property: publish.cloudify.build) -->
<ant target="prepare.cloudify.for.publish" />
<ant target="archive.cloudify.versions"/>
<delete dir="${tmp.dir}"/>
</target>
1)拷贝${gigaspaces.related.folder}/src/java下的com/j_spaces/kernel/${platform.verion.file.name}文件到临时源码目录
其中:${gigaspaces.related.folder} =${package.build}/gigaspaces
${package.build}=./package_build
实际上,是将./package_build/gigaspaces/src/java/com/j_spaces/kernel/CloudifyVersion.java文件拷到 src-tmp-dir
2)javac 编译这个类文件
3)将其打包为jar,如果存在则更新或覆盖,打包到./tmp/gigaspaces-cloudify-2.6.0-m1/lib/required/gs-runtime.jar中
4)将其打包为jar,如果存在则更新或覆盖,打包到./tmp/gigaspaces-cloudify-2.6.0-m1/lib/platform/boot/gs.boot.jar中
5)删除临时源文件和目标文件。
<target name="update.gs.runtime">
<!-- define properties for temp directories -->
<property name="src.tmp.dir" value="src-tmp-dir"/>
<property name="dst.tmp.dir" value="dst-tmp-dir"/>
<!-- create temp directories -->
<mkdir dir="${src.tmp.dir}"/>
<mkdir dir="${dst.tmp.dir}"/>
<copy todir="${src.tmp.dir}">
<fileset dir="${gigaspaces.related.folder}/src/java">
<include name="com/j_spaces/kernel/${platform.verion.file.name}"/>
</fileset>
</copy>
<javac
classpath="${tmp.dir}/${cloudify.installation.dir}/lib/required/${gs.runtime.jar}"
nowarn="on"
srcdir="${src.tmp.dir}"
destdir="${dst.tmp.dir}"
debug="on"
memoryMaximumSize="512m"
fork="yes"
source="1.6">
</javac>
<jar jarfile="${tmp.dir}/${cloudify.installation.dir}/lib/required/${gs.runtime.jar}" update="true">
<fileset dir="${dst.tmp.dir}"/>
</jar>
<jar jarfile="${tmp.dir}/${cloudify.installation.dir}/lib/platform/boot/${gs.boot.jar}" update="true">
<fileset dir="${dst.tmp.dir}"/>
</jar>
<!-- delete temp folders -->
<delete dir="${src.tmp.dir}"/>
<delete dir="${dst.tmp.dir}"/>
</target>
完成工作:1)删除docs
2)删除examples
3)删除tools/benchmark、apache、alert-integration
4)删除gslicense.xml
5)删除bin目录下的一些命令
<target name="remove.xap.related.modules">
<delete dir="${tmp.dir}/${cloudify.installation.dir}/docs" />
<delete file="${tmp.dir}/${cloudify.installation.dir}/lib/optional/openspaces/gs-openspaces-sources.zip" />
<delete dir="${tmp.dir}/${cloudify.installation.dir}/examples" />
<delete dir="${tmp.dir}/${cloudify.installation.dir}/tools/benchmark"/>
<delete dir="${tmp.dir}/${cloudify.installation.dir}/tools/apache"/>
<delete dir="${tmp.dir}/${cloudify.installation.dir}/tools/alert-integration"/>
<delete file="${tmp.dir}/${cloudify.installation.dir}/gslicense.xml"/>
<delete>
<fileset dir="${tmp.dir}/${cloudify.installation.dir}/bin" includes="gs-focalserver.*, gsInstance.*,
startJiniTxMahalo.*, puInstance.*, gs-memcached.*, gs-ui.*"/>
</delete>
</target>
完成工作:将./tmp/下的所有sh、bat、xml中的LOOKUPGROUPS=(.*)替换为LOOKUPGROUPS=“${lookup.group}”
<target name="update.lus.groups">
<echo message="Updating LUS Groups in directory: ${tmp.dir}/${cloudify.installation.dir} ..."/>
<property name="lookup.group" value="gigaspaces-${CLOUDIFY}-${cloudify.version}-${cloudify.milestone}"/>
<replaceregexp match="LOOKUPGROUPS=(.*)" replace="LOOKUPGROUPS="${lookup.group}"">
<fileset dir="${tmp.dir}/${cloudify.installation.dir}" includes="**/*.sh, **/*.bat, **/*.xml"/>
</replaceregexp>
</target>
完成工作:
1)添加USM组件,从./../USM/target/usm.jar拷贝到./tmp/gigaspaces-cloudify-2.6.0-m1/lib/platform/usm/中
1.1)添加esm组件,从./../esc/target/esc/lib/*.jar拷贝到./tmp/gigaspaces-cloudify-2.6.0-m1/lib/platform/esm/中
2)添加dsl组件,./../dsl/target/dsl.jar拷贝到./tmp/gigaspaces-cloudify-2.6.0-m1/lib/platform/cloudify/
3)添加CLI组件,./../CLI/target/cli.jar和./../CLI/cloudify.*拷贝到./tmp/gigaspaces-cloudify-2.6.0-m1/tools/cli/
3.1)添加cli命令到根中的bin,将./package.build/gigaspaces/bin/cloudify.*拷贝到./tmp/gigaspaces-cloudify-2.6.0-m1/bin
4)添加management-space组件,./../management-space/target/management-space.jar拷贝到./tmp/gigaspaces-cloudify-2.6.0-m1/tools/management-space/
5)添加Rest组件,./../restful/target/rest.war拷贝到./tmp/gigaspaces-cloudify-2.6.0-m1/tools/rest/
5.1)添加rest安全配置,./../restful/src/main/webapp/WEB-INF/spring-security.xml拷贝到./tmp/gigaspaces-cloudify-2.6.0-m1/config/security/
5.2)添加WebUI配置,./package.build/gs-webui/config/*.xml拷贝到./tmp/gigaspaces-cloudify-2.6.0-m1/config/
6)添加esc-command组件,./../esc-commands/target/esc-commands.jar拷贝到./tmp/gigaspaces-cloudify-2.6.0-m1/tools/cli/plugins/esc/
6.1)对不同云的支持,./../esc/src/main/resources/clouds/**/*拷贝到./tmp/gigaspaces-cloudify-2.6.0-m1/clouds/
<macrodef name="add.cloudify.modules">
<attribute name="installation.dir" default="${tmp.dir}/${cloudify.installation.dir}"/>
<sequential>
<echo message="Copy USM component"/>
<copy todir="@{installation.dir}/lib/platform/usm" overwrite="true">
<fileset dir="${usm.local.copy}/target/" includes="usm.jar" excludes=".svn"/>
</copy>
<copy todir="@{installation.dir}/lib/platform/esm" overwrite="true">
<fileset dir="${esc.local.copy}/target/esc/lib" includes="*.jar" excludes=".svn"/>
</copy>
<echo message="Copy dsl component"/>
<mkdir dir="@{installation.dir}/lib/platform/cloudify"/>
<copy todir="@{installation.dir}/lib/platform/cloudify" overwrite="true">
<fileset dir="${dsl.local.copy}/target/" includes="dsl.jar" excludes=".svn"/>
</copy>
<echo message="Copy CLOUDIFY CLI component"/>
<copy todir="@{installation.dir}/tools/cli/" overwrite="true">
<fileset dir="${cli.local.copy}/target/" includes="cli.jar" excludes=".svn"/>
<fileset dir="${cli.local.copy}/" includes="cloudify.*" excludes=".svn"/>
</copy>
<copy todir="@{installation.dir}/bin" overwrite="true">
<fileset dir="${gigaspaces.related.folder}/bin" includes="cloudify.*" excludes=".svn"/>
</copy>
<echo message="Copy management-space component"/>
<mkdir dir="@{installation.dir}/tools/management-space/" />
<copy todir="@{installation.dir}/tools/management-space/" overwrite="true">
<fileset dir="${management-space.local.copy}/target/" includes="management-space.jar" excludes=".svn"/>
</copy>
<echo message="Copy CLOUDIFY Rest component"/>
<copy todir="@{installation.dir}/tools/rest/" overwrite="true">
<fileset dir="${restful.local.copy}/target/" includes="rest.war" excludes=".svn"/>
</copy>
<copy todir="@{installation.dir}/config/security/" overwrite="true">
<fileset dir="${restful.local.copy}/src/main/webapp/WEB-INF" includes="spring-security.xml"/>
</copy>
<copy todir="@{installation.dir}/config" overwrite="true">
<fileset dir="${gs-webui.related.folder}/config" includes="*.xml"/>
</copy>
<echo message="Copy CLOUDIFY esc-command component"/>
<copy todir="@{installation.dir}/tools/cli/plugins/esc" overwrite="true">
<fileset dir="${esc-commands.local.copy}/target" includes="esc-commands.jar" excludes=".svn"/>
</copy>
<mkdir dir="@{installation.dir}/clouds/"/>
<copy todir="@{installation.dir}/clouds/" overwrite="true">
<fileset dir="${esc.local.copy}/src/main/resources/clouds" includes="**/*" excludes=".svn"/>
</copy>
</sequential>
</macrodef>
完成工作:1)如果./../../cloudify-recipes目录存在进行后继工作。
2)。。。,我这里不存在前面这个目录
<condition property="recipes.available" value="true">
<available type="dir" file="${recipes.local.copy}"/>
</condition>
<target name="fetch.recipes.cloudify" if="recipes.available">
<echo message="Create and Copy recipes component for Cloudify"/>
<exec executable="${mvn.executable}" dir="${recipes.local.copy}">
<arg line="clean package" />
</exec>
<unzip src="${recipes.local.copy}/target/recipes.zip" dest="${tmp.dir}/${cloudify.installation.dir}/recipes" />
</target>
1)将./package_build/gigaspaces/START_HERE.htm拷贝到./tmp/gigaspaces-cloudify-2.6.0-m1/
2)将dynamic_props.js移除,重新打包gs-webui-2.6.0-SNAPSHOT.war
<target name="replace.xap.content.with.cloudify.related">
<copy todir="${tmp.dir}/${cloudify.installation.dir}" file="${gigaspaces.related.folder}/START_HERE.htm" overwrite="true"/>
<!-- replace dynamic_props.js in gs-webui war. WAS task doesn't update exisitng warfile
properly if the files that are intended to be added to warfile already appear in it. This is the reason for
temp file creation. -->
<war warfile="${tmp.dir}/${cloudify.installation.dir}/tools/gs-webui/tmp.${gs.webui.war}" needxmlfile="false">
<zipfileset src="${tmp.dir}/${cloudify.installation.dir}/tools/gs-webui/${gs.webui.war}"
includes="**/*" excludes="dynamic_props.js" filemode="775"/>
<zipfileset dir="${gs-webui.related.folder}/war" />
</war>
<delete file="${tmp.dir}/${cloudify.installation.dir}/tools/gs-webui/${gs.webui.war}"/>
<move file="${tmp.dir}/${cloudify.installation.dir}/tools/gs-webui/tmp.${gs.webui.war}" tofile="${tmp.dir}/${cloudify.installation.dir}/tools/gs-webui/${gs.webui.war}"/>
</target>
完成工作:拷入notice.txt文件
<target name="replace.cloudify.notice">
<copy todir="${tmp.dir}/${cloudify.installation.dir}" file="${gigaspaces.related.folder}/notice.txt" overwrite="true"/>
</target>
<dos2unix dir="${tmp.dir}/${cloudify.installation.dir}" />
<macrodef name="dos2unix">
<attribute name="dir"/>
<sequential>
<!-- Replaces EOLs with LF characters and removes eof characters
from the shell scripts. Tabs and spaces are left as is. -->
<fixcrlf srcdir="@{dir}"
eol="lf"
eof="remove"
includes="**/*.sh"
defaultexcludes="no"
/>
<!-- Replaces all EOLs with cr-lf pairs in the batch files.
Tabs and spaces are left as is. EOF characters are left alone if run on DOS systems,
and are removed if run on Unix systems. -->
<fixcrlf srcdir="@{dir}"
eol="crlf"
includes="**/*.bat"
defaultexcludes="no"
/>
</sequential>
</macrodef>
1)更新本地文件中的cloudifyUrl
2)提交文件
<target name="prepare.cloudify.for.publish" description="publish cloudify build to gigaspaces repository" if="publish.cloudify.build">
<ant target="update.cloudify.service.configuration.url"/>
<ant target="commit.service.configuration" />
</target>
完成工作:encode cloudify.url,更新源文件中的cloudifyUrl
1)cloudify.url =http://repository.cloudifysource.org/org/cloudifysource/2.6.0-SNAPSHOT/gigaspaces-cloudify-2.6.0-m1-b4980-309.zip
2)groovy.dir=./tmp/gigaspaces-cloudify-2.6.0-m1/tools/groovy/bin
3)groovy.path=${groovy.dir}/groovy(.bat)
4)执行groovy -e "println(java.net.URLEncoder.encode('${cloudify.url}'))"
5)替换./tmp/gigaspaces-cloudify-2.6.0-m1/clouds/目录下的**/*-cloud.groovy 中的cloudifyUrl
6)替换${esc.local.copy}/src/main/resources/clouds/目录下的**/*-cloud.groovy 中的cloudifyUrl
<target name="update.cloudify.service.configuration.url" if="release.build">
<echo message="Updating ServiceConfiguration in directory: ${tmp.dir}/${cloudify.installation.dir}/clouds/ ..."/>
<property name="cloudify.url" value="${cloudify.cdn.publish.url}/${cloudify.put.target}" />
<!-- Here we encode cloudify.url -->
<property name="groovy.dir" value="${tmp.dir}/${cloudify.installation.dir}/tools/groovy/bin" />
<condition property="groovy.path" value="${groovy.dir}/groovy.bat">
<os family="windows"/>
</condition>
<condition property="groovy.path" value="${groovy.dir}/groovy">
<os family="unix"/>
</condition>
<exec executable="${groovy.path}" outputproperty="cloudify.url.encoded">
<env key="JAVA_HOME" value="${java.home}" />
<arg value="-e" />
<arg value=""println(java.net.URLEncoder.encode('${cloudify.url}'))"" />
</exec>
<!-- Update files in ${tmp.dir}/${cloudify.installation.dir} and in source folders -->
<replaceregexp byline="true"
match="cloudifyUrl "(.*)""
replace="cloudifyUrl "${cloudify.url}"" >
<fileset
dir="${tmp.dir}/${cloudify.installation.dir}/clouds/"
includes="**/*-cloud.groovy" />
<fileset
dir="${esc.local.copy}/src/main/resources/clouds"
includes="**/*-cloud.groovy" />
</replaceregexp>
</target>
完成工作:提交文件
1)执行 git checkout ${branchname} 工作目录./../esc
2)执行 git pull
3)执行 git add .
4)执行 git commit –m Update cloudify url
5)执行 git push
<target name="commit.service.configuration">
<exec executable="git" dir="${esc.local.copy}">
<arg value="checkout" />
<arg value="${branchname}" />
</exec>
<exec executable="git" dir="${esc.local.copy}">
<arg line="pull" />
</exec>
<exec executable="git" dir="${esc.local.copy}">
<arg line="add ." />
</exec>
<exec executable="git" dir="${esc.local.copy}">
<arg value="commit" />
<arg value="-m" />
<arg value="Update cloudify url" />
</exec>
<exec executable="git" dir="${esc.local.copy}">
<arg value="push" />
</exec>
</target>
完成工作:打包,添加javadoc
1) 删除 ./releases/build_4980-309/目录
2) 创建 ./releases/build_4980-309/cloudify/1.5/目录
3) 将 ./tmp/**/*打包为./releases/build_4980-309/cloudify/1.5/gigaspaces-cloudify-2.6.0-m1-b4980-309.zip
4) 将zip打包成tar
5) 添加apidocs包到./releases/build_4980-309/docs/cloudify-javadoc.zip
6) 添加rest文档restdoclet.html
<target name="archive.cloudify.versions">
<delete dir="${releases.dir}/build_${cloudify.build.number}"/>
<mkdir dir="${releases.dir}/build_${cloudify.build.number}/${cloudify}/1.5"/>
<zip destfile="${releases.dir}/build_${cloudify.build.number}/${cloudify}/1.5/gigaspaces-${cloudify}-${cloudify.version}-${cloudify.milestone}-b${cloudify.build.number}.zip">
<zipfileset dir="${tmp.dir}" includes="**/*" filemode="775"/>
</zip>
<tar destfile="${releases.dir}/build_${cloudify.build.number}/${cloudify}/1.5/gigaspaces-${cloudify}-${cloudify.version}-${cloudify.milestone}-b${cloudify.build.number}.tar.gz" compression="gzip">
<zipfileset src="${releases.dir}/build_${cloudify.build.number}/${cloudify}/1.5/gigaspaces-${cloudify}-${cloudify.version}-${cloudify.milestone}-b${cloudify.build.number}.zip"/>
</tar>
<!-- Add Cloudify Javadoc archive to Cloudify/docs folder. If the folder doesn't exist please run: mvn javadoc:javadoc -->
<mkdir dir="${releases.dir}/build_${cloudify.build.number}/docs" />
<zip file="${releases.dir}/build_${cloudify.build.number}/docs/${cloudify}-javadoc.zip">
<fileset dir="${basedir}/target/site/apidocs"/>
</zip>
<mkdir dir="${releases.dir}/build_${cloudify.build.number}/docs/restdoclet" />
<copy todir="${releases.dir}/build_${cloudify.build.number}/docs/restdoclet" >
<fileset file="${restful.local.copy}/target/site/restdoclet/restdoclet.html"/>
<fileset file="${restful.local.copy}/src/main/webapp/resources/restdoclet/restdoclet.css"/>
</copy>
</target>