2015-03-02 24 views
0

我们正在使用WL Enterprise ver 6.2.0.1开发WL项目,使用ANT脚本完成文件(Native [ipa/apk]和Hybrid [.wlapp])的构建。在Worklight上自动增加应用程序版本

有没有一种方法可以在构建过程中自动递增应用程序版本(application-descriptor.xml)?

是否有我们可以用来完成此任务的脚本?

回答

0

稍微不同的方式,但这个样本(读“原样”)的代码应该为你提供足够的创建自己的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='\1${buildNumber}\2' 
          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> 

它需要使用蚂蚁的contrib的。

+0

谢谢,我会试试看。 – 2015-03-03 13:16:16

相关问题