| | 26 | |
| | 27 | |
| | 28 | |
| | 29 | == 例子 == |
| | 30 | |
| | 31 | 以聚超值为例子,因为要多个项目构成,需要settings.gradle 这个文件 ,[http://www.cnblogs.com/CloudTeng/p/3418425.html 参考][[BR]] |
| | 32 | |
| | 33 | settings.gradle |
| | 34 | {{{ |
| | 35 | include ':pcgCommon', ':Juchaozhi' |
| | 36 | }}} |
| | 37 | local.properties ,用于配置sdk.dir |
| | 38 | {{{ |
| | 39 | sdk.dir=/Volumes/DATA/tools/android-sdk-macosx |
| | 40 | }}} |
| | 41 | root项目下有两个项目 pcgCommon和Juchaozhi [[BR]] |
| | 42 | root 项目build.gradle |
| | 43 | |
| | 44 | {{{ |
| | 45 | buildscript { |
| | 46 | repositories { |
| | 47 | jcenter() |
| | 48 | } |
| | 49 | dependencies { |
| | 50 | classpath 'com.android.tools.build:gradle:0.12.+' |
| | 51 | |
| | 52 | // NOTE: Do not place your application dependencies here; they belong |
| | 53 | // in the individual module build.gradle files |
| | 54 | } |
| | 55 | } |
| | 56 | |
| | 57 | allprojects { |
| | 58 | repositories { |
| | 59 | jcenter() |
| | 60 | } |
| | 61 | } |
| | 62 | }}} |
| | 63 | |
| | 64 | pcgCommon build.gradle |
| | 65 | |
| | 66 | {{{ |
| | 67 | buildscript { |
| | 68 | repositories { |
| | 69 | mavenCentral() |
| | 70 | } |
| | 71 | dependencies { |
| | 72 | classpath 'com.android.tools.build:gradle:0.12.+' |
| | 73 | } |
| | 74 | } |
| | 75 | |
| | 76 | apply plugin: 'android-library' |
| | 77 | |
| | 78 | |
| | 79 | android { |
| | 80 | compileSdkVersion 17 |
| | 81 | buildToolsVersion = 20 |
| | 82 | |
| | 83 | sourceSets { |
| | 84 | main { |
| | 85 | manifest.srcFile 'AndroidManifest.xml' |
| | 86 | java.srcDirs = ['src'] |
| | 87 | resources.srcDirs = ['src'] |
| | 88 | aidl.srcDirs = ['src'] |
| | 89 | renderscript.srcDirs = ['src'] |
| | 90 | res.srcDirs = ['res'] |
| | 91 | assets.srcDirs = ['assets'] |
| | 92 | } |
| | 93 | |
| | 94 | instrumentTest.setRoot('tests') |
| | 95 | |
| | 96 | debug.setRoot('build-types/debug') |
| | 97 | release.setRoot('build-types/release') |
| | 98 | } |
| | 99 | } |
| | 100 | |
| | 101 | dependencies { |
| | 102 | compile fileTree(dir: 'libs', include: '*.jar') |
| | 103 | } |
| | 104 | }}} |