在 Worklight 上自动增加应用程序版本
Automatically Increment application version on Worklight
我们正在使用 WL Enterprise 版本 6.2.0.1 开发 WL 项目,文件(本机 [ipa/apk] 和混合 [.wlapp])的构建是使用 ANT 脚本完成的。
有没有办法在构建期间自动增加 (application-descriptor.xml) 中的应用程序版本?
是否有我们可以用来完成此任务的脚本?
方法略有不同,但此示例(阅读 "as-is")代码应该足以让您创建自己的 ANT 目标来执行此操作:
<!-- =========================================================================== -->
<!-- Target: -update-build-number -->
<!-- =========================================================================== -->
<target name="-update-build-number">
<if>
<isset property="${prop.buildNmber}" />
<then>
<property name="buildNumber" value="${prop.buildNmber}" />
</then>
<else>
<tstamp>
<format property="buildNumber" pattern="${prop.buildNumberPattern}" />
</tstamp>
</else>
</if>
<echo message="Setting application build Number : ${buildNumber}" />
<if>
<istrue value="${prop.env.android}" />
<then>
<echo message="Updating Android build number" />
<replaceregexp file="${appdir}/android/nativeResources/AndroidManifest.xml"
match='(android:versionCode=").*(" .*$)'
replace='${buildNumber}'
byline="true" />
</then>
</if>
<if>
<istrue value="${prop.env.ipad}" />
<then>
<echo message="Updating IPad build number" />
<exec executable="/usr/libexec/PlistBuddy">
<arg value="-c"/>
<arg value="Set CFBundleVersion ${buildNumber}" />
<arg value="${appdir}/ipad/native/${prop.iosNativePrefix}${prop.appName}Ipad-Info.plist"/>
</exec>
</then>
</if>
<if>
<istrue value="${prop.env.iphone}" />
<then>
<echo message="Updating IPhone build number" />
<exec executable="/usr/libexec/PlistBuddy">
<arg value="-c"/>
<arg value="Set CFBundleVersion ${buildNumber}" />
<arg value="${appdir}/iphone/native/${prop.iosNativePrefix}${prop.appName}Iphone-Info.plist"/>
</exec>
</then>
</if>
<antcall target="-update-build-number-custom" />
</target>
需要使用ant-contrib
我们正在使用 WL Enterprise 版本 6.2.0.1 开发 WL 项目,文件(本机 [ipa/apk] 和混合 [.wlapp])的构建是使用 ANT 脚本完成的。
有没有办法在构建期间自动增加 (application-descriptor.xml) 中的应用程序版本?
是否有我们可以用来完成此任务的脚本?
方法略有不同,但此示例(阅读 "as-is")代码应该足以让您创建自己的 ANT 目标来执行此操作:
<!-- =========================================================================== -->
<!-- Target: -update-build-number -->
<!-- =========================================================================== -->
<target name="-update-build-number">
<if>
<isset property="${prop.buildNmber}" />
<then>
<property name="buildNumber" value="${prop.buildNmber}" />
</then>
<else>
<tstamp>
<format property="buildNumber" pattern="${prop.buildNumberPattern}" />
</tstamp>
</else>
</if>
<echo message="Setting application build Number : ${buildNumber}" />
<if>
<istrue value="${prop.env.android}" />
<then>
<echo message="Updating Android build number" />
<replaceregexp file="${appdir}/android/nativeResources/AndroidManifest.xml"
match='(android:versionCode=").*(" .*$)'
replace='${buildNumber}'
byline="true" />
</then>
</if>
<if>
<istrue value="${prop.env.ipad}" />
<then>
<echo message="Updating IPad build number" />
<exec executable="/usr/libexec/PlistBuddy">
<arg value="-c"/>
<arg value="Set CFBundleVersion ${buildNumber}" />
<arg value="${appdir}/ipad/native/${prop.iosNativePrefix}${prop.appName}Ipad-Info.plist"/>
</exec>
</then>
</if>
<if>
<istrue value="${prop.env.iphone}" />
<then>
<echo message="Updating IPhone build number" />
<exec executable="/usr/libexec/PlistBuddy">
<arg value="-c"/>
<arg value="Set CFBundleVersion ${buildNumber}" />
<arg value="${appdir}/iphone/native/${prop.iosNativePrefix}${prop.appName}Iphone-Info.plist"/>
</exec>
</then>
</if>
<antcall target="-update-build-number-custom" />
</target>
需要使用ant-contrib