一梭灿、?Gradle中compile, provided, compile files, compile project區(qū)別
在一個(gè)Android項(xiàng)目的build.gradle中莲镣,dependencies閉包中有以下四種形式的聲明:
compile 'com.android.support:appcompat-v7:22.2.1'
provided 'com.squareup.dagger:dagger-compiler:1.2.1'
compile files('libs/picasso-2.4.0.jar')
compile project(':androidPullToRefresh')
1汁汗,3,4本質(zhì)上是一樣的,區(qū)別在于:
1 是從repository(默認(rèn)是jCenter())里下載一個(gè)依賴包進(jìn)行編譯并打包;
3 是從本地的libs目錄下尋找picasso-2.4.0.jar這個(gè)文件進(jìn)行編譯并打包,類似的命令有compile fileTree(dir: 'libs', include: '.jar')*——將libs目錄下所有jar文件進(jìn)行編譯并打包;
4 是將另一個(gè)module(等同eclipse中的library)進(jìn)行編譯并打包漂彤。
至于provided,是提供給那些只編譯不打包場景的命令灾搏。就是我在編譯的時(shí)候?qū)δ骋粋€(gè)jar文件有依賴显歧,但是最終打包apk文件時(shí),我不想把這個(gè)jar文件放進(jìn)去确镊,可以用這個(gè)命令士骤。