有关android工程的构建脚本(build.xml)的学习

学习【android-sdk-linux根目录】/tools/ant/build.xml,觉得如下几点很有用,记录之

1)ant脚本中属性值是于前置定义优化的原则,即属性发生重复定义时,前面定义的值不会被后面定义的覆盖;

2)需要注意javac的交叉编译参数(-bootclasspath <路径>        覆盖引导类文件的位置),注意到它可能很容易理解在J2SE平台下编译android平台的类文件是怎么做到的;

这里有介绍该参数的文章:http://docs.oracle.com/javase/6/docs/technotes/tools/solaris/javac.html#options

3)可利用ant -debug的参数来研究android的build.xml(这个强烈推荐使用),可以查看更多的日志输出,于便查看target运行时的参数;

使用事列:ant -debug release

如下为部份log

-compile:
Adding reference: project.javac.classpath
fileset: Setup scanner in dir /home/luogw/dev-tool/sdk/android-sdk-linux/tools/helloworld/src with patternSet{ includes: [] excludes: [] }
[javac] com/luo/HelloWorldActivity.java added as com/luo/HelloWorldActivity.class doesn't exist.
fileset: Setup scanner in dir /home/luogw/dev-tool/sdk/android-sdk-linux/tools/helloworld/gen with patternSet{ includes: [] excludes: [] }
[javac] /home/luogw/dev-tool/sdk/android-sdk-linux/tools/helloworld/gen/R.java.d skipped - don't know how to handle it
[javac] com/luo/BuildConfig.java added as com/luo/BuildConfig.class doesn't exist.
[javac] com/luo/R.java added as com/luo/R.class doesn't exist.
[javac] Compiling 3 source files to /home/luogw/dev-tool/sdk/android-sdk-linux/tools/helloworld/bin/classes
[javac] Using modern compiler
[javac] Compilation arguments:
[javac] '-d'
[javac] '/home/luogw/dev-tool/sdk/android-sdk-linux/tools/helloworld/bin/classes'
[javac] '-classpath'
[javac] '/home/luogw/dev-tool/sdk/android-sdk-linux/tools/helloworld/bin/classes:/home/luogw/dev-tool/sdk/android-sdk-linux/tools/support/annotations.jar'
[javac] '-sourcepath'
[javac] '/home/luogw/dev-tool/sdk/android-sdk-linux/tools/helloworld/src:/home/luogw/dev-tool/sdk/android-sdk-linux/tools/helloworld/gen'
[javac] '-target'
[javac] '1.5'
[javac] '-bootclasspath'
[javac] '/home/luogw/dev-tool/sdk/android-sdk-linux/platforms/android-10/android.jar'
[javac] '-encoding'
[javac] 'UTF-8'
[javac] '-g'
[javac] '-source'
[javac] '1.5'
[javac]
[javac] The ' characters around the executable and arguments are
[javac] not part of the command.
[javac] Files to be compiled:
[javac] /home/luogw/dev-tool/sdk/android-sdk-linux/tools/helloworld/src/com/luo/HelloWorldActivity.java
[javac] /home/luogw/dev-tool/sdk/android-sdk-linux/tools/helloworld/gen/com/luo/BuildConfig.java
[javac] /home/luogw/dev-tool/sdk/android-sdk-linux/tools/helloworld/gen/com/luo/R.java

4)//TODO

注:目前我有个需求:想替换build.xml脚本中的-bootclasspath的值

但它不是一个属性值,不能通过前置定义的方式替换,暂时没有想到解决方案

上一篇:ASP.NET Web Forms的改进


下一篇:为何img、input等内联元素可以设置宽、高