學習【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的值
但它不是一個屬性值,不能通過前置定義的方式替換,暫時沒有想到解決方案