2013年8月17日 星期六

About Library Dependency Manager on Android Project

You Gave Me Your Wings. 
   開發專案過程中,管理library(不論是3rd party或自製)的問題常常存在,在JAVA的世界可以用ivy、maven或Gradle(有些也包含build script的功能),而在Objective-c可以用CocoPads。

   但最近聽到蠻多人用git的submodlue來管理,連sublime text及vim的plugin都用這招管;就Android開發而言,用Maven及Ivy體系就有點綁手綁腳,因為並不是每個library都會放到repository server(除非你想自己host一個,並且手動up-to-date)。

   而git的submodlue可能會比較合適,畢竟比較好用的library大部分在Github上都有維護,例如:AndroidQueryPullToRefreshActiveAndroid等等。唯一的缺點大概是每次都要自己compile library project,時間會拉的有點長;不過ADT更新到r17時有改變link library project的policy(如下段文章所示),以後R.java及resource都不會bind到library的jar檔,這大概宣示非自己compile source code不可。

Important: If you are still referencing jar libraries manually instead of putting them under libs/ be aware of the following:
  • If the project is a Library project, these jar libraries will not be automatically visible to application projects. You should really move these to libs/
  • If the project is an application, this can work but you must make sure to mark the jar files as exported.

   至於Gradle可以多一些期盼(自己還沒有很認真在玩,但groovy語法我是很熟悉),連web framework: Grails也預計在3.0版(最近在2.3 release)後使用它!