ira*_*hil 3 android android-build
当我使用Ant在命令行中构建一个Android项目时,我想在AndroidManifest.xml文件中更新android:versionCode和android:versionName.有没有我可以使用属性文件注入版本号?
您可以通过多种方式设置版本信息,
要作为命令行参数传递,
<target name="set-version-using-commandline-args">
<!-- Load properties from "version.properties" file -->
<replaceregexp file="AndroidManifest.xml" match="android:versionCode(.*)"
replace='android:versionCode="${Version.Code}"'/>
<replaceregexp file="AndroidManifest.xml" match="android:versionName(.*)"
replace='android:versionName="${Version.Name}"'/>
</target>
Run Code Online (Sandbox Code Playgroud)
然后像这样运行ant build,
ant -DVersion.Code=100 -DVersion.Name=5.0.0.1201011 debug
Run Code Online (Sandbox Code Playgroud)
如果要使用属性文件传递版本信息,请使用此目标,
<target name="set-version-using-file">
<!-- Load properties from "version.properties" file -->
<property file="version.properties" />
<replaceregexp file="AndroidManifest.xml" match="android:versionCode(.*)"
replace='android:versionCode="${Version.Code}"'/>
<replaceregexp file="AndroidManifest.xml" match="android:versionName(.*)"
replace='android:versionName="${Version.Name}"'/>
</target>
Run Code Online (Sandbox Code Playgroud)
有关详细说明,请参阅此博客文章.Android:如何版本命令行构建?
| 归档时间: |
|
| 查看次数: |
4880 次 |
| 最近记录: |