任务。
65 |
66 | `assembleDebug`和`assembleRelease`两个Task在上面已经提到过,这里要讲这两个Task从哪里被创建。当`debug`和`release`构建类型被预创建的时候,它们的tasks就会自动创建对应的这个两个Task。
67 |
68 | 上面提到的build.gradle代码片段中也会实现`assembleJnidebug` task,并且`assemble`会像依赖于`assembleDebug`和`assembleRelease`一样依赖于`assembleJnidebug`。
69 |
70 | 提示:你可以在终端下输入gradle aJ去运行`assembleJnidebug task`。
71 |
72 | 可能会使用到的情况:
73 |
74 | * release模式不需要,只有debug模式下才使用到的权限
75 | * 自定义的debug实现
76 | * 为debug模式使用不同的资源(例如当资源的值由绑定的证书决定)
77 |
78 | _BuildType_的代码和资源通过以下方式被使用:
79 |
80 | * manifest将被混合进app的manifest
81 | * 代码行为只是另一个资源文件夹
82 | * 资源将叠加到main的资源中,并替换已存在的资源。
83 |
--------------------------------------------------------------------------------
/basic_project/configuring_the_structure.md:
--------------------------------------------------------------------------------
1 | # Configuring the Structure
2 |
3 | 当默认的项目结构不适用的时候,你可能需要去配置它。根据Gradle文档,重新为Java项目配置_sourceSets_可以使用以下方法:
4 |
5 | sourceSets {
6 | main {
7 | java {
8 | srcDir 'src/java'
9 | }
10 | resources {
11 | srcDir 'src/resources'
12 | }
13 | }
14 | }
15 |
16 | ---
17 |
18 | > 注意:`srcDir`将会被添加到指定的已存在的源文件夹中(这在Gradle文档中没有提到,但是实际上确实会这样执行)。
19 |
20 | ---
21 |
22 | 替换默认的源代码文件夹,你可能想要使用能够传入一个路径数组的`srcDirs`来替换单一的`srcDir`。以下是使用调用对象的另一种不同方法:
23 |
24 | sourceSets {
25 | main.java.srcDirs = ['src/java']
26 | main.resources.srcDirs = ['src/resources']
27 | }
28 |
29 | 想要获取更多信息,可以参考Gradle文档中关于[Java Pluign](http://gradle.org/docs/current/userguide/java_plugin.html)的部分。
30 |
31 | Android Plugin使用的是类似的语法。但是由于它使用的是自己的_sourceSets_,这些配置将会被添加在`android`对象中。
32 |
33 | 以下是一个示例,它使用了旧项目结构中的main源码,并且将`androidTest` _sourceSet_组件重新映射到_tests_文件夹。
34 |
35 | android {
36 | sourceSets {
37 | main {
38 | manifest.srcFile 'AndroidManifest.xml'
39 | java.srcDirs = ['src']
40 | resources.srcDirs = ['src']
41 | aidl.srcDirs = ['src']
42 | renderscript.srcDirs = ['src']
43 | res.srcDirs = ['res']
44 | assets.srcDirs = ['assets']
45 | }
46 |
47 | androidTest.setRoot('tests')
48 | }
49 | }
50 |
51 | ---
52 |
53 | > 注意:由于旧的项目结构将所有的源文件(java,aidl,renderscripthe和java资源文件)都放在同一个目录里面,所以我们需要将这些_sourceSet_组件重新映射到`src`目录下。
54 |
55 | ---
56 |
57 | > 注意:`setRoot()`方法将移动整个组件(包括它的子文件夹)到一个新的文件夹。示例中将会移动`src/androidTest/*`到`tests/*`下。
58 | 以上这些是Android特有的,如果配置在Java的_sourceSets_里面将不会有作用。
59 |
60 | ---
61 |
62 | 以上也是将旧构建系统项目迁移到新构建系统需要做的迁移工作。
63 |
--------------------------------------------------------------------------------
/basic_project/general_tasks.md:
--------------------------------------------------------------------------------
1 | # General Tasks(通用任务)
2 |
3 | 添加一个插件到构建文件中将会自动创建一系列构建任务(build tasks)去执行(注:gradle属于任务驱动型构建工具,它的构建过程是基于Task的)。Java plugin和Android plugin都会创建以下task:
4 |
5 | * `assemble`
6 | 这个task将会组合项目的所有输出。
7 |
8 | * `check`
9 | 这个task将会执行所有检查。
10 |
11 | * `build`
12 | 这个task将会执行assemble和check两个task的所有工作
13 |
14 | * `clean`
15 | 这个task将会清空项目的输出。
16 |
17 | 实际上`assemble`,`check`,`build`这三个task不做任何事情。它们只是一个Task标志,用来告诉android plugin添加实际需要执行的task去完成这些工作。
18 |
19 | 这就允许你去调用相同的task,而不需要考虑当前是什么类型的项目,或者当前项目添加了什么plugin。
20 | 例如,添加了_findbugs_ plugin将会创建一个新的task并且让`check` task依赖于这个新的task。当`check` task被调用的时候,这个新的task将会先被调用。
21 |
22 | 在命令行环境中,你可以执行以下命令来获取更多高级别的task:
23 |
24 | gradle tasks
25 |
26 | 查看所有task列表和它们之间的依赖关系可以执行以下命令:
27 |
28 | gradle tasks --all
29 |
30 | ---
31 |
32 | > 注意:Gradle会自动监视一个task声明的所有输入和输出。
33 | 两次执行`build` task并且期间项目没有任何改动,gradle将会使用UP-TO-DATE通知所有task。这意味着第二次build执行的时候不会请求任何task执行。这允许task之间互相依赖,而不会导致不需要的构建请求被执行。
34 |
35 | ---
36 |
--------------------------------------------------------------------------------
/basic_project/java_project_tasksjavatask.md:
--------------------------------------------------------------------------------
1 | # Java project tasks(Java项目的Task)
2 |
3 | Java plugin主要创建了两个task,依赖于main task(一个标识性的task):
4 | * `assemble`
5 | * `jar`
6 | 这个task创建所有输出
7 | * `check`
8 | * `test`
9 | 这个task执行所有的测试。
10 |
11 | `jar` task自身直接或者间接依赖于其他task:`classes` task将会被调用于编译java源码。
12 | `testClasses` task用于编译测试,但是它很少被调用,因为`test` task依赖于它(类似于`classes` task)。
13 |
14 | 通常情况下,你只需要调用到`assemble`和`check`,不需要其他task。
15 |
16 | 你可以在Gradle文档中查看[java plugin](http://gradle.org/docs/current/userguide/java_plugin.html)的全部task。
17 |
--------------------------------------------------------------------------------
/basic_project/manifest_entries_manifest.md:
--------------------------------------------------------------------------------
1 | # Manifest entries (Manifest属性)
2 |
3 | 通过DSL可以配置一下manifest选项:
4 |
5 | * minSdkVersion
6 | * targetSdkVersion
7 | * versionName
8 | * applicationId (有效的包名 -- 更多详情请查阅[ApplicationId 对比 PackageName](http://tools.android.com/tech-docs/new-build-system/applicationid-vs-packagename))
9 | * package Name for the test application
10 | * Instrumentation test runner
11 |
12 | 例如:
13 |
14 | android {
15 | compileSdkVersion 19
16 | buildToolsVersion "19.0.0"
17 |
18 | defaultConfig {
19 | versionCode 12
20 | versionName "2.0"
21 | minSdkVersion 16
22 | targetSdkVersion 16
23 | }
24 | }
25 |
26 | 在`android`元素中的`defaultConfig`元素中定义所有配置。
27 |
28 | 之前的Android Plugin版本使用packageName来配置manifest文件中的packageName属性。从0.11.0版本开始,你需要在build.gradle文件中使用applicationId来配置manifest文件中的packageName属性。
29 | 这是为了消除应用程序的packageName(也是程序的ID)和java包名所引起的混乱。
30 |
31 | 在构建文件中定义的强大之处在于它是动态的。
32 | 例如,可以从一个文件中或者其它自定义的逻辑代码中读取版本信息:
33 |
34 |
35 | def computeVersionName() {
36 | ...
37 | }
38 |
39 | android {
40 | compileSdkVersion 19
41 | buildToolsVersion "19.0.0"
42 |
43 | defaultConfig {
44 | versionCode 12
45 | versionName computeVersionName()
46 | minSdkVersion 16
47 | targetSdkVersion 16
48 | }
49 | }
50 |
51 | 注意:不要使用与在给定范围内的getter方法可能引起冲突的方法名。例如,在defaultConfig{...}中调用getVersionName()将会自动调用defaultConfig.getVersionName()方法,你自定义的getVersionName()方法就被取代掉了。
52 |
53 | 如果一个属性没有使用DSL进行设置,一些默认的属性值将会被使用。以下表格是可能使用到的值:
54 |
55 | Property Name |Default value in DSL object|Default value
56 | ------------- |:-------------: | -----:
57 | `versionCode` |-1 |value from manifest if present
58 | `versionName` |null |value from manifest if present
59 | `minSdkVersion` |-1 |value from manifest if present
60 | `targetSdkVersion`|-1 |value from manifest if present
61 | `applicationId` |null |value from manifest if present
62 | `testApplicationId` |null |applicationId + “.test”
63 | `testInstrumentationRunner` |null|android.test.InstrumentationTestRunner
64 | `signingConfig` |null |null
65 | `proguardFile` |N/A (set only) |N/A (set only)
66 | `proguardFiles` |N/A (set only) |N/A (set only)
67 |
68 | 如果你在构建脚本中使用自定义代码逻辑请求这些属性,那么第二列的值将非常重要。例如,你可能会写:
69 |
70 | if (android.defaultConfig.testInstrumentationRunner == null) {
71 | // assign a better default...
72 | }
73 |
74 | 如果这个值一直保持null,那么在构建执行期间将会实际替换成第三列的默认值。但是在DSL元素中并没有包含这个默认值,所以,你无法查询到这个值。
75 | 除非是真的需要,这是为了预防解析应用的manifest文件。
76 |
--------------------------------------------------------------------------------
/basic_project/project_structure.md:
--------------------------------------------------------------------------------
1 | # Project Structure(项目结构)
2 |
3 | 上面提到的基本的构建文件需要一个默认的文件夹结构。Gradle遵循约定优先于配置的概念,在可能的情况尽可能提供合理的默认配置参数。
4 |
5 | 基本的项目开始于两个名为“source sets”的组件,即main source code和test code。它们分别位于:
6 |
7 | * src/main/
8 | * src/androidTest/
9 |
10 | 里面每一个存在的文件夹对应相应的源组件。
11 | 对于Java plugin和Android plugin来说,它们的Java源代码和资源文件路径如下:
12 |
13 | * java/
14 | * resources/
15 |
16 | 但对于Android plugin来说,它还拥有以下特有的文件和文件夹结构:
17 |
18 | * AndroidManifest.xml
19 | * res/
20 | * assets/
21 | * aidl/
22 | * rs/
23 | * jni/
24 |
25 | ---
26 |
27 | > 注意:src/androidTest/AndroidManifest.xml是不需要的,它会自动被创建。
28 |
29 | ---
30 |
--------------------------------------------------------------------------------
/basic_project/running_proguard_proguard.md:
--------------------------------------------------------------------------------
1 | # Running Proguard(运行 Proguard)
2 |
3 | 从Gradle Plugin for ProGuard version 4.10之后就开始支持ProGuard。ProGuard插件是自动添加进来的。如果_Build Type_的_runProguard_属性被设置为true,对应的task将会自动创建。
4 |
5 | android {
6 | buildTypes {
7 | release {
8 | runProguard true
9 | proguardFile getDefaultProguardFile('proguard-android.txt')
10 | }
11 | }
12 |
13 | productFlavors {
14 | flavor1 {
15 | }
16 | flavor2 {
17 | proguardFile 'some-other-rules.txt'
18 | }
19 | }
20 | }
21 |
22 | 发布版本将会使用它的Build Type中声明的规则文件,product flavor(定制的产品版本)将会使用对应flavor中声明的规则文件。
23 |
24 | 这里有两个默认的规则文件:
25 |
26 | * proguard-android.txt
27 | * proguard-android-optimize.txt
28 |
29 | 这两个文件都在SDK的路径下。使用_getDefaultProguardFile()_可以获取这些文件的完整路径。它们除了是否要进行优化之外,其它都是相同的。
30 |
--------------------------------------------------------------------------------
/basic_project/signing_configurations.md:
--------------------------------------------------------------------------------
1 | # signing configurations(签名配置)
2 |
3 | 对一个应用程序签名需要以下:
4 |
5 | * 一个Keystory
6 | * 一个keystory密码
7 | * 一个key的别名
8 | * 一个key的密码
9 | * 存储类型
10 |
11 | 位置,键名,两个密码,还有存储类型一起形成了签名配置。
12 |
13 | 默认情况下,`debug`被配置成使用一个debug keystory。
14 | debug keystory使用了默认的密码和默认key及默认的key密码。
15 | debug keystory的位置在$HOME/.android/debug.keystroe,如果对应位置不存在这个文件将会自动创建一个。
16 |
17 | `debug` _Build Type_(构建类型) 会自动使用`debug` _SigningConfig_ (签名配置)。
18 |
19 | 可以创建其他配置或者自定义内建的默认配置。通过`signingConfigs`这个DSL容器来配置:
20 |
21 | android {
22 | signingConfigs {
23 | debug {
24 | storeFile file("debug.keystore")
25 | }
26 |
27 | myConfig {
28 | storeFile file("other.keystore")
29 | storePassword "android"
30 | keyAlias "androiddebugkey"
31 | keyPassword "android"
32 | }
33 | }
34 |
35 | buildTypes {
36 | foo {
37 | debuggable true
38 | jniDebugBuild true
39 | signingConfig signingConfigs.myConfig
40 | }
41 | }
42 | }
43 |
44 | 以上代码片段修改debug keystory的路径到项目的根目录下。在这个例子中,这将自动影响其他使用到`debug`构建类型的构建类型。
45 |
46 | 这里也创建了一个新的`Single Config`(签名配置)和一个使用这个新签名配置的新的`Build Type`(构建类型)。
47 |
48 | ---
49 | > 注意:只有默认路径下的debug keystory不存在时会被自动创建。更改debug keystory的路径并不会自动在新路径下创建debug keystory。如果创建一个新的不同名字的_SignConfig_,但是使用默认的debug keystore路径来创建一个非默认的名字的SigningConing,那么还是会在默认路径下创建debug keystory。换句话说,会不会自动创建是根据keystory的路径来判断,而不是配置的名称。
50 |
51 | ---
52 |
53 | > 注意:虽然经常使用项目根目录的相对路径作为keystore的路径,但是也可以使用绝对路径,尽管这并不推荐(除了自动创建出来的debug keystore)。
54 |
55 | ---
56 |
57 | > __注意:如果你将这些文件添加到版本控制工具中,你可能不希望将密码直接写到这些文件中。下面Stack Overflow链接提供从控制台或者环境变量中获取密码的方法:
58 | http://stackoverflow.com/questions/18328730/how-to-create-a-release-signed-apk-file-using-gradle
59 | 我们以后还会在这个指南中添加更多的详细信息。__
60 |
61 | ---
62 |
--------------------------------------------------------------------------------
/basic_project/simple_build_files.md:
--------------------------------------------------------------------------------
1 | # Simple build files(简单的构建文件)
2 |
3 | 一个最简单的Gradle纯Java项目的build.gradle文件包含以下内容:
4 |
5 | apply plugin: 'java'
6 |
7 | 这里引入了Gradle的Java插件。这个插件提供了所有构建和测试Java应用程序所需要的东西。
8 |
9 | 最简单的Android项目的build.gradle文件包含以下内容:
10 |
11 | buildscript {
12 | repositories {
13 | mavenCentral()
14 | }
15 |
16 | dependencies {
17 | classpath 'com.android.tools.build:gradle:0.11.1'
18 | }
19 | }
20 |
21 | apply plugin: 'android'
22 |
23 | android {
24 | compileSdkVersion 19
25 | buildToolsVersion "19.0.0"
26 | }
27 |
28 | 这里包括了Android build file的3个主要部分:
29 |
30 | `buildscrip{...}`这里配置了驱动构建过程的代码。
31 |
32 | 在这个部分,它声明了使用Maven仓库,并且声明了一个maven文件的依赖路径。这个文件就是包含了0.11.1版本android gradle插件的库。
33 |
34 | ---
35 |
36 | > 注意:这里的配置只影响控制构建过程的代码,不影响项目源代码。项目本身需要声明自己的仓库和依赖关系,稍后将会提到这部分。
37 |
38 | ---
39 |
40 | 接下来,跟前面提到的Java Plugin一样添加了`android` plugin。
41 |
42 | 最后,`andorid{...}`配置了所有android构建过程需要的参数。这里也是Android DSL的入口点。
43 |
44 | 默认情况下,只需要配置目标编译SDK版本和编译工具版本,即`compileSdkVersion`和`buildToolsVersion`属性。
45 | 这个`complieSdkVersion`属性相当于旧构建系统中project.properites文件中的`target`属性。这个新的属性可以跟旧的`target`属性一样指定一个int或者String类型的值。
46 |
47 | ---
48 |
49 | > 重要:你只能添加`android` plugin。同时添加`java` plugin会导致构建错误。
50 |
51 | ---
52 |
53 | > 注意:你同样需要在相同路径下添加一个local.properties文件,并使用sdk.dir属性来设置SDK路径。
54 | 另外,你也可以通过设置`ANDROID_HOME`环境变量,这两种方式没有什么不同,根据你自己的喜好选择其中一种设置。
55 |
56 | ---
57 |
--------------------------------------------------------------------------------
/book.json:
--------------------------------------------------------------------------------
1 | {
2 | "github": "avatarqing",
3 | "githubHost": "https://github.com/",
4 | "plugins": [
5 | "ga",
6 | "disqus"
7 | ],
8 | "pluginsConfig": {
9 | "ga": {
10 | "token": "UA-52789423-7"
11 | },
12 | "disqus": {
13 | "shortName": "AvatarQing"
14 | }
15 | }
16 | }
--------------------------------------------------------------------------------
/build_variants/README.md:
--------------------------------------------------------------------------------
1 | # Build Variants(构建变种版本)
2 |
3 | 新构建系统的一个目标就是允许为同一个应用创建不同的版本。
4 |
5 | 这里有两个主要的使用情景:
6 |
7 | 1. 同一个应用的不同版本。
8 | 例如一个免费的版本和一个收费的专业版本。
9 | 2. 同一个应用需要打包成不同的apk以发布Google Play Store。
10 | [点击此处][1]查看更多详细信息。
11 | 3. 综合1和2两种情景。
12 |
13 | 这个目标就是要让在同一个项目里生成不同的APK成为可能,以取代以前需要使用一个库项目和两个及两个以上的应用项目分别生成不同APK的做法。
14 |
15 | [1]: http://developer.android.com/google/play/publishing/multiple-apks.html
16 |
--------------------------------------------------------------------------------
/build_variants/build_type__+_product_flavor_=_build_variant+=.md:
--------------------------------------------------------------------------------
1 | # Build Type + Product Flavor = Build Variant(构建类型+定制产品=构建变种版本)
2 |
3 | 正如前面章节所提到的,每一个_Build Type_都会生成一个新的APK。
4 |
5 | _Product Flavor_同样也会做这些事情:项目的输出将会拼接所有可能的_Build Type_和_Product Flavor_(如果有Flavor定义存在的话)的组合。
6 |
7 | 每一种组合(包含_Build Type_和_Product Flavor_)就是一个_Build Variant_(构建变种版本)。
8 |
9 | 例如,在上面的Flavor声明例子中与默认的`debug`和`release`两个_Build Type_将会生成4个_Build Variant_:
10 |
11 | * Flavor1 - debug
12 | * Flavor1 - release
13 | * Flavor2 - debug
14 | * Flavor2 - release
15 |
16 | 项目中如果没有定义flavor同样也会有_Build Variant_,只是使用的是默认的flavor和配置。`default`(默认)的flavor/config是没有名字的,所以生成的Build Variant列表看起来就跟_Build Type_列表一样。
17 |
--------------------------------------------------------------------------------
/build_variants/building_and_tasks.md:
--------------------------------------------------------------------------------
1 | # Building and Tasks(构建和任务)
2 |
3 | 我们前面提到每一个_Build Type_会创建自己的assemble< name >task,但是_Build Variant_是_Build Type_和_Product Flavor_的组合。
4 |
5 | 当使用_Product Flavor_的时候,将会创建更多的assemble-type task。分别是:
6 |
7 | 1. assemble< Variant Name >
8 | 允许直接构建一个Variant版本,例如`assembleFlavor1Debug`。
9 | 2. assemble< Build Type Name >
10 | 允许构建指定Build Type的所有APK,例如`assembleDebug`将会构建Flavor1Debug和Flavor2Debug两个Variant版本。
11 | 3. assemble< Product Flavor Name >
12 | 允许构建指定flavor的所有APK,例如`assembleFlavor1`将会构建Flavor1Debug和Flavor1Release两个Variant版本。
13 |
14 | 另外`assemble` task会构建所有可能组合的Variant版本。
15 |
--------------------------------------------------------------------------------
/build_variants/multi-flavor_variants.md:
--------------------------------------------------------------------------------
1 | # Multi-flavor variants
2 |
3 | 在一些情况下,一个应用可能需要基于多个标准来创建多个版本。例如,Google Play中的multi-apk支持4个不同的过滤器。区分创建的不同APK的每一个过滤器要求能够使用多维的Product Flavor。
4 |
5 | 假如有个游戏需要一个免费版本和一个付费的版本,并且需要在multi-apk支持中使用ABI过滤器(译注:ABI,应用二进制接口,优点是不需要改动应用的任何代码就能够将应用迁移到任何支持相同ABI的平台上)。这个游戏应用需要3个ABI和两个特定应用版本,因此就需要生成6个APK(没有因计算不同_Build Types_生成的Variant版本)。
6 | 然而,注意到在这个例子中,为三个ABI构建的付费版本源代码都是相同,因此创建6个flavor来实现不是一个好办法。
7 | 相反的,使用两个flavor维度,并且自动构建所有可能的Variant组合。
8 |
9 | 这个功能的实现就是使用Flavor Groups。每一个Group代表一个维度,并且flavor都被分配到一个指定的Group中。
10 |
11 | android {
12 | ...
13 |
14 | flavorGroups "abi", "version"
15 |
16 | productFlavors {
17 | freeapp {
18 | flavorGroup "version"
19 | ...
20 | }
21 |
22 | x86 {
23 | flavorGroup "abi"
24 | ...
25 | }
26 |
27 | ...
28 | }
29 | }
30 |
31 | `andorid.flavorGroups`数组按照先后排序定义了可能使用的group。每一个_Product Flavor_都被分配到一个group中。
32 |
33 | 上面的例子中将_Product Flavor_分为两组(即两个维度),为别为abi维度[x86,arm,mips]和version维度[freeapp,paidapp],再加上默认的_Build Type_有[debug,release],这将会组合生成以下的Build Variant:
34 |
35 | * x86-freeapp-debug
36 | * x86-freeapp-release
37 | * arm-freeapp-debug
38 | * arm-freeapp-release
39 | * mips-freeapp-debug
40 | * mips-freeapp-release
41 | * x86-paidapp-debug
42 | * x86-paidapp-release
43 | * arm-paidapp-debug
44 | * arm-paidapp-release
45 | * mips-paidapp-debug
46 | * mips-paidapp-release
47 |
48 | `android.flavorGroups`中定义的group排序非常重要(Variant命名和优先级等)。
49 |
50 | 每一个Variant版本的配置由几个`Product Flavor`对象决定:
51 |
52 | * android.defaultConfig
53 | * 一个来自abi组中的对象
54 | * 一个来自version组中的对象
55 |
56 | flavorGroups中的排序决定了哪一个flavor覆盖哪一个,这对于资源来说非常重要,因为一个flavor中的值会替换定义在低优先级的flavor中的值。
57 |
58 | flavor groups使用最高的优先级定义,因此在上面例子中的优先级为:
59 |
60 | abi > version > defaultConfig
61 |
62 | Multi-flavors项目同样拥有额外的sourceSet,类似于Variant的sourceSet,只是少了Build Type:
63 |
64 | * `android.sourceSets.x86Freeapp`
65 | 位于src/x86Freeapp/
66 | * `android.sourceSets.armPaidapp`
67 | 位于src/armPaidapp/
68 | * 等等...
69 |
70 | 这允许在flavor-combination的层次上进行定制。它们拥有过比基础的flavor sourceSet更高的优先级,但是优先级低于Build Type的sourceSet。
71 |
--------------------------------------------------------------------------------
/build_variants/product_flavor_configurationproduct_flavor.md:
--------------------------------------------------------------------------------
1 | # Product Flavor Configuration(Product Flavor的配置)
2 |
3 | 每一个flavor都是通过闭包来配置的:
4 |
5 | android {
6 | ...
7 |
8 | defaultConfig {
9 | minSdkVersion 8
10 | versionCode 10
11 | }
12 |
13 | productFlavors {
14 | flavor1 {
15 | packageName "com.example.flavor1"
16 | versionCode 20
17 | }
18 |
19 | flavor2 {
20 | packageName "com.example.flavor2"
21 | minSdkVersion 14
22 | }
23 | }
24 | }
25 |
26 | 注意_ProductFlavor_类型的`android.productFlavors.*`对象与`android.defaultConfig`对象的类型是相同的。这意味着它们共享相同的属性。
27 |
28 | `defaultConfig`为所有的flavor提供基本的配置,每一个flavor都可以重设这些配置的值。在上面的例子中,最终的配置结果将会是:
29 |
30 | * `flavor1`
31 | * `packageName`: com.example.flavor1
32 | * `minSdkVersion`: 8
33 | * `versionCode`: 20
34 | * `flavor2`
35 | * `packageName`: com.example.flavor2
36 | * `minSdkVersion`: 14
37 | * `versionCode`: 10
38 |
39 | 通常情况下,_Build Type_的配置会覆盖其它的配置。例如,_Build Type_的`packageNameSuffix`会被追加到_Product Flavor_的`packageName`上面。
40 |
41 | 也有一些情况是一些设置可以同时在_Build Type_和_Product Flavor_中设置。在这种情况下,按照个别为主的原则决定。
42 |
43 | 例如,`signingConfig`就这种属性的一个例子。
44 | `signingConfig`允许通过设置`android.buildTypes.release.signingConfig`来为所有的`release`包共享相同的_SigningConfig_。也可以通过设置`android.productFlavors.*.signingConfig`来为每一个release包指定它们自己的_SigningConfig_。
45 |
--------------------------------------------------------------------------------
/build_variants/product_flavors.md:
--------------------------------------------------------------------------------
1 | # Product flavors(不同定制的产品)
2 |
3 | 一个product flavor定义了从项目中构建了一个应用的自定义版本。一个单一的项目可以同时定义多个不同的flavor来改变应用的输出。
4 |
5 | 这个新的设计概念是为了解决不同的版本之间的差异非常小的情况。虽然最项目终生成了多个定制的版本,但是它们本质上都是同一个应用,那么这种做法可能是比使用库项目更好的实现方式。
6 |
7 | Product flavor需要在`productFlavors`这个DSL容器中声明:
8 |
9 | android {
10 | ....
11 |
12 | productFlavors {
13 | flavor1 {
14 | ...
15 | }
16 |
17 | flavor2 {
18 | ...
19 | }
20 | }
21 | }
22 |
23 | 这里创建了两个flavor,名为`flavor1`和`flavor2`。
24 |
25 | ---
26 |
27 | > 注意:flavor的命名不能与已存在的_Build Type_或者`androidTest`这个_sourceSet_有冲突。
28 |
--------------------------------------------------------------------------------
/build_variants/sourcesets_and_dependencies.md:
--------------------------------------------------------------------------------
1 | # Sourcesets and Dependencies(源组件和依赖关系)
2 |
3 | 与_Build Type_类似,_Product Flavor_也会通过它们自己的_sourceSet_提供代码和资源。
4 |
5 | 上面的例子将会创建4个_sourceSet_:
6 |
7 | * `android.sourceSets.flavor1`
8 | 位于src/flavor1/
9 | * `android.sourceSets.flavor2`
10 | 位于src/flavor2/
11 | * `android.sourceSets.androidTestFlavor1`
12 | 位于src/androidTestFlavor1/
13 | * `android.sourceSets.androidTestFlavor2`
14 | 位于src/androidTestFlavor2/
15 |
16 | 这些_sourceSet_用于与`android.sourceSets.main`和_Build Type_的_sourceSet_来构建APK。
17 |
18 | 下面的规则用于处理所有使用的sourceSet来构建一个APK:
19 |
20 | * 多个文件夹中的所有的源代码(src/*/java)都会合并起来生成一个输出。
21 | * 所有的Manifest文件都会合并成一个Manifest文件。类似于_Build Type_,允许_Product Flavor_可以拥有不同的的组件和权限声明。
22 | * 所有使用的资源(Android res和assets)遵循的优先级为_Build Type_会覆盖_Product Flavor_,最终覆盖`main` _sourceSet_的资源。
23 | * 每一个_Build Variant_都会根据资源生成自己的R类(或者其它一些源代码)。Variant互相之间没有什么是共享的。
24 |
25 | 最终,类似_Build Type_,_Product Flavor_也可以有它们自己的依赖关系。例如,如果使用flavor来生成一个基于广告的应用版本和一个付费的应用版本,其中广告版本可能需要依赖于一个广告SDK,但是另一个不需要。
26 |
27 | dependencies {
28 | flavor1Compile "..."
29 | }
30 |
31 | 在这个例子中,src/flavor1/AndroidManifest.xml文件中可能需要声明访问网络的权限。
32 |
33 | 每一个Variant也会创建额外的sourceSet:
34 |
35 | * `android.sourceSets.flavor1Debug`
36 | 位于src/flavor1Debug/
37 | * `android.sourceSets.flavor1Release`
38 | 位于src/flavor1Release/
39 | * `android.sourceSets.flavor2Debug`
40 | 位于src/flavor2Debug/
41 | * `android.sourceSets.flavor2Release`
42 | 位于src/flavor2Release/
43 |
44 | 这些sourceSet拥有比Build Type的sourceSet更高的优先级,并允许在Variant的层次上做一些定制。
45 |
--------------------------------------------------------------------------------
/build_variants/testing.md:
--------------------------------------------------------------------------------
1 | # Testing(测试)
2 |
3 | 测试multi-flavors项目非常类似于测试简单的项目。
4 |
5 | `androidTest` _sourceSet_用于定义所有flavor共用的测试,但是每一个flavor也可以有它自己特有的测试。
6 |
7 | 正如前面提到的,每一个flavor都会创建自己的测试sourceSet:
8 |
9 | * `android.sourceSets.androidTestFlavor1`
10 | 位于src/androidTestFlavor1/
11 | * `android.sourceSets.androidTestFlavor2`
12 | 位于src/androidTestFlavor2/
13 |
14 | 同样的,它们也可以拥有自己的依赖关系:
15 |
16 | dependencies {
17 | androidTestFlavor1Compile "..."
18 | }
19 |
20 | 这些测试可以通过main的标志性`deviceCheck` task或者main的`androidTest` task(当flavor被使用的时候这个task相当于一个标志性task)来执行。
21 |
22 | 每一个flavor也拥有它们自己的task来这行这些测试:androidTest< VariantName >。例如:
23 |
24 | * `androidTestFlavor1Debug`
25 | * `androidTestFlavor2Debug`
26 |
27 | 同样的,每一个Variant版本也会创建对应的测试APK构建task和安装或卸载task:
28 |
29 | * `assembleFlavor1Test`
30 | * `installFlavor1Debug`
31 | * `installFlavor1Test`
32 | * `uninstallFlavor1Debug`
33 | * ...
34 |
35 | 最终的HTML报告支持根据flavor合并生成。
36 | 下面是测试结果和报告文件的路径,第一个是每一个flavor版本的结果,后面的是合并起来的结果:
37 |
38 | * build/androidTest-results/flavors/< FlavorName >
39 | * build/androidTest-results/all/
40 | * build/reports/androidTests/flavors< FlavorName >
41 | * build/reports/androidTests/all/
42 |
--------------------------------------------------------------------------------
/cover.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AvatarQing/Gradle-Plugin-User-Guide-Chinese-Verision/e47e460d1f26e920bf5d779cd7ed21c3891f7add/cover.jpg
--------------------------------------------------------------------------------
/cover_small.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AvatarQing/Gradle-Plugin-User-Guide-Chinese-Verision/e47e460d1f26e920bf5d779cd7ed21c3891f7add/cover_small.png
--------------------------------------------------------------------------------
/dependenciesandroid_libraries_and_multi-project_setupandroid/README.md:
--------------------------------------------------------------------------------
1 | # Dependencies,Android Libraries and Multi-project setup(依赖关系,Android库和多项目设置)
2 |
3 | Gradle项目可以依赖于其它组件。这些组件可以是外部二进制包,或者是其它的Gradle项目。
4 |
--------------------------------------------------------------------------------
/dependenciesandroid_libraries_and_multi-project_setupandroid/creating_a_library_project.md:
--------------------------------------------------------------------------------
1 | # Creating a Library Project(创建一个库项目)
2 |
3 | 一个库项目与通常的Android项目非常类似,只是有一点小区别。
4 |
5 | 尽管构建库项目不同于构建应用程序,它们使用了不同的plugin。但是在内部这些plugin共享了大部分相同的代码,并且它们都由相同的com.android.tools.build.gradle.jar提供。
6 |
7 | buildscript {
8 |
9 | repositories {
10 | mavenCentral()
11 | }
12 |
13 |
14 | dependencies {
15 | classpath 'com.android.tools.build:gradle:0.5.6'
16 | }
17 |
18 | }
19 |
20 | apply plugin: 'android-library'
21 |
22 | android {
23 | compileSdkVersion 15
24 | }
25 |
26 | 这里创建了一个使用API 15编译_SourceSet_的库项目,并且依赖关系的配置方法与应用程序项目的配置方法一样,同样也支持自定义配置。
27 |
--------------------------------------------------------------------------------
/dependenciesandroid_libraries_and_multi-project_setupandroid/dependencies_on_binary_packages.md:
--------------------------------------------------------------------------------
1 | # Dependencies on binary packages(依赖二进制包)
2 |
--------------------------------------------------------------------------------
/dependenciesandroid_libraries_and_multi-project_setupandroid/differences_between_a_project_and_a_library_project.md:
--------------------------------------------------------------------------------
1 | # Differences between a Project and a Library Project(普通项目和库项目之间的区别)
2 |
3 | 一个库项目的main输出是一个.aar包(它代表Android的归档文件)。它组合了编译代码(例如jar包或者是本地的.so文件)和资源(manifest,res,assets)。
4 | 一个库项目同样也可以独立于应用程序生成一个测试用的apk来测试。
5 |
6 | 标识Task同样适用于库项目(`assembleDebug`,`assembleRelease`),因此在命令行上与构建一个项目没有什么不同。
7 |
8 | 其余的部分,库项目与应用程序项目一样。它们都拥有build type和product flavor,也可以生成多个aar版本。
9 | 记住大部分Build Type的配置不适用于库项目。但是你可以根据库项目是否被其它项目使用或者是否用来测试来使用自定义的sourceSet改变库项目的内容。
10 |
--------------------------------------------------------------------------------
/dependenciesandroid_libraries_and_multi-project_setupandroid/library_projects.md:
--------------------------------------------------------------------------------
1 | # Library projects(库项目)
2 |
3 | 在上面的多项目配置中,`:libraries:lib1`和`:libraries:lib2`可能是一个Java项目,并且`:app`这个Android项目将会使用它们的jar包输出。
4 |
5 | 但是,如果你想要共享代码来访问Android API或者使用Android样式的资源,那么这些库就不能是通常的Java项目,而应该是Android库项目。
6 |
--------------------------------------------------------------------------------
/dependenciesandroid_libraries_and_multi-project_setupandroid/library_publication.md:
--------------------------------------------------------------------------------
1 | # Library Publication(库项目发布)
2 |
3 | 一般情况下一个库只会发布它的_release_ Variant(变种)版本。这个版本将会被所有引用它的项目使用,而不管它们本身自己构建了什么版本。这是由于Gradle的限制,我们正在努力消除这个问题,所以这只是临时的限制。
4 |
5 | 你可以控制哪一个Variant版本作为发行版:
6 |
7 | android {
8 | defaultPublishConfig "debug"
9 | }
10 |
11 | 注意这里的发布配置名称引用的是完整的Variant版本名称。_Relesae_,_debug_只适用于项目中没有其它特性版本的时候使用。如果你想要使用其它Variant版本取代默认的发布版本,你可以:
12 |
13 | android {
14 | defaultPublishConfig "flavor1Debug"
15 | }
16 |
17 | 将库项目的所有Variant版本都发布也是可能的。我们计划在一般的项目依赖项目(类似于上述所说的)情况下允许这种做法,但是由于Gradle的限制(我们也在努力修复这个问题)现在还不太可能。
18 | 默认情况下没有启用发布所有Variant版本。可以通过以下启用:
19 |
20 | android {
21 | publishNonDefault true
22 | }
23 |
24 | 理解发布多个Variant版本意味着发布多个arr文件而不是一个arr文件包含所有Variant版本是非常重要的。每一个arr包都包含一个单一的Variant版本。
25 | 发布一个变种版本意味着构建一个可用的arr文件作为Gradle项目的输出文件。无论是发布到一个maven仓库,还是其它项目需要创建一个这个库项目的依赖都可以使用到这个文件。
26 |
27 | Gradle有一个默认文件的概念。当添加以下配置后就会被使用到:
28 |
29 | compile project(':libraries:lib2')
30 |
31 | 创建一个其它发布文件的依赖,你需要指定具体使用哪一个:
32 |
33 | dependencies {
34 | flavor1Compile project(path: ':lib1', configuration: 'flavor1Release')
35 | flavor2Compile project(path: ':lib1', configuration: 'flavor2Release')
36 | }
37 |
38 | ---
39 |
40 | > 重要:注意已发布的配置是一个完整的Variant版本,其中包括了build type,并且需要像以上一样被引用。
41 |
42 | ---
43 |
44 | > 重要:当启用非默认发布,maven发布插件将会发布其它Variant版本作为扩展包(按分类器分类)。这意味着不能真正的兼容发布到maven仓库。你应该另外发布一个单一的Variant版本到仓库中,或者允许发布所有配置以支持跨项目依赖。
45 |
46 | ---
47 |
--------------------------------------------------------------------------------
/dependenciesandroid_libraries_and_multi-project_setupandroid/local_packages.md:
--------------------------------------------------------------------------------
1 | # Local packages(本地包)
2 |
3 | 配置一个外部库的jar包依赖,你需要在`compile`配置中添加一个依赖。
4 |
5 | dependencies {
6 | compile files('libs/foo.jar')
7 | }
8 |
9 | android {
10 | ...
11 | }
12 |
13 | ---
14 |
15 | > 注意:这个`dependencies` DSL标签是标准Gradle API中的一部分,所以它不属于`android`标签。
16 |
17 | ---
18 |
19 | 这个`compile`配置将被用于编译main application。它里面的所有东西都被会被添加到编译的classpath中,__同时__也会被打包进最终的APK。
20 | 以下是添加依赖时可能用到的其它一些配置选项:
21 |
22 | * `compile`
23 | main application(主module)。
24 | * `androidTestCompile`
25 | test application(测试module)。
26 | * `debugCompile`
27 | debug Build Type(debug类型的编译)。
28 | * `releaseCompile`
29 | release Build Type(发布类型的编译)。
30 |
31 | 因为没有可能去构建一个没有关联任何_Build Type_(构建类型)的APK,APK默认配置了两个或两个以上的编译配置:`compile`和< buildtype >Compile.
32 | 创建一个新的_Build Type_将会自动创建一个基于它名字的新配置。
33 |
34 | 这对于debug版本需要使用一个自定义库(为了反馈实例化的崩溃信息等)但发布版本不需要,或者它们依赖于同一个库的不同版本时会非常有用。
35 |
--------------------------------------------------------------------------------
/dependenciesandroid_libraries_and_multi-project_setupandroid/multi_project_setup.md:
--------------------------------------------------------------------------------
1 | # Multi project setup(多项目设置)
2 |
3 | Gradle项目也可以通过使用多项目配置依赖于其它Gradle项目。
4 |
5 | 多项目配置的实现通常是在一个根项目路径下将所有项目作为子文件夹包含进去。
6 |
7 |
8 | 例如,给定以下项目结构:
9 |
10 | MyProject/
11 | + app/
12 | + libraries/
13 | + lib1/
14 | + lib2/
15 |
16 | 我们可以定义3个项目。Grand将会按照以下名字映射它们:
17 |
18 | :app
19 | :libraries:lib1
20 | :libraries:lib2
21 |
22 | 每一个项目都拥有自己的build.gradle文件来声明自己如何构建。
23 | 另外,在根目录下还有一个_setting.gradle_文件用于声明所有项目。
24 | 这些文件的结构如下:
25 |
26 | MyProject/
27 | | settings.gradle
28 | + app/
29 | | build.gradle
30 | + libraries/
31 | + lib1/
32 | | build.gradle
33 | + lib2/
34 | | build.gradle
35 |
36 | 其中setting.gradle的内容非常简单:
37 |
38 | include ':app', ':libraries:lib1', ':libraries:lib2'
39 |
40 | 这里定义了哪一个文件夹才是真正的Gradle项目。
41 |
42 | 其中`:app`项目可能依赖于这些库,这是通过以下依赖配置声明的:
43 |
44 | dependencies {
45 | compile project(':libraries:lib1')
46 | }
47 |
48 | 更多关于多项目配置的信息请参考[这里][1]。
49 |
50 | [1]: http://gradle.org/docs/current/userguide/multi_project_builds.html
51 |
--------------------------------------------------------------------------------
/dependenciesandroid_libraries_and_multi-project_setupandroid/referencing_a_library.md:
--------------------------------------------------------------------------------
1 | # Referencing a Library(引用一个库项目)
2 |
3 | 引用一个库项目的方法与引用其它项目的方法一样:
4 |
5 | dependencies {
6 | compile project(':libraries:lib1')
7 | compile project(':libraries:lib2')
8 | }
9 |
10 | ---
11 |
12 | > 注意:如果你要引用多个库,那么排序将非常重要。这类似于旧构建系统里面的project.properties文件中的依赖排序。
13 |
14 | ---
15 |
--------------------------------------------------------------------------------
/dependenciesandroid_libraries_and_multi-project_setupandroid/remote_artifacts.md:
--------------------------------------------------------------------------------
1 | # Remote artifacts(远程文件)
2 |
3 | Gradle支持从Maven或者Ivy仓库中拉取文件。
4 |
5 | 首先必须将仓库添加到列表中,然后必须在依赖中声明Maven或者Ivy声明的文件。
6 |
7 | repositories {
8 | mavenCentral()
9 | }
10 |
11 |
12 | dependencies {
13 | compile 'com.google.guava:guava:11.0.2'
14 | }
15 |
16 | android {
17 | ...
18 | }
19 |
20 | ---
21 |
22 | > 注意:`mavenCentral()`是指定仓库URL的简单方法。Gradle支持远程和本地仓库。
23 |
24 | ---
25 |
26 | > 注意:Gradle会遵循依赖关系的传递性。这意味着如果一个依赖本身依赖于其它东西,这些东西也会一并被拉取回来。
27 |
28 | ---
29 |
30 | 更多关于设置依赖关系的信息,请参考[Gradle用户指南][1]和[DSL][2]文档。
31 |
32 | [1]: http://gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
33 | [2]: http://gradle.org/docs/current/dsl/org.gradle.api.artifacts.dsl.DependencyHandler.html
34 |
--------------------------------------------------------------------------------
/introduction/README.md:
--------------------------------------------------------------------------------
1 | # Introduction(简介)
2 | 本文档适用于0.9版本的Gradle plugin。由于我们在1.0版本之前介绍的不兼容,所以早期版本可能与本文档有所不同。
3 |
--------------------------------------------------------------------------------
/introduction/goals_of_the_new_build_systemgradle.md:
--------------------------------------------------------------------------------
1 | # Goals of the new Build System(gradle构建系统的目标)
2 | 采用Gradle作为新构建系统的目标:
3 |
4 | * 让重用代码和资源变得更加容易。
5 | * 让创建同一应用程序的不同版本变得更加容易,无论是多个apk发布版本还是同一个应用的不同定制版本。
6 | * 让构建过程变得更加容易配置,扩展和定制。
7 | * 整合优秀的IDE
8 |
--------------------------------------------------------------------------------
/introduction/why_gradlegradle.md:
--------------------------------------------------------------------------------
1 | # Why Gradle?(为什么使用gradle)
2 | Gradle是一个优秀的构建系统和构建工具,它允许通过插件创建自定义的构建逻辑。
3 | 我们基于Gradle以下的一些特点而选择了它:
4 |
5 | * 采用了Domain Specific Language(DSL语言)来描述和控制构建逻辑。
6 | * 构建文件基于Groovy,并且允许通过混合声明DSL元素和使用代码来控制DSL元素以控制自定义的构建逻辑。
7 | * 支持Maven或者Ivy的依赖管理。
8 | * 非常灵活。允许使用最好的实现,但是不会强制实现的方式。
9 | * 插件可以提供自己的DSL和API以供构建文件使用。
10 | * 良好的API工具供IDE集成。
11 |
--------------------------------------------------------------------------------
/node_modules/gitbook-plugin-disqus/.gitignore:
--------------------------------------------------------------------------------
1 | # Logs
2 | logs
3 | *.log
4 |
5 | # Runtime data
6 | pids
7 | *.pid
8 | *.seed
9 |
10 | # Directory for instrumented libs generated by jscoverage/JSCover
11 | lib-cov
12 |
13 | # Coverage directory used by tools like istanbul
14 | coverage
15 |
16 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
17 | .grunt
18 |
19 | # Compiled binary addons (http://nodejs.org/api/addons.html)
20 | build/Release
21 |
22 | # Dependency directory
23 | # Deployed apps should consider commenting this line out:
24 | # see https://npmjs.org/doc/faq.html#Should-I-check-my-node_modules-folder-into-git
25 | node_modules
26 |
--------------------------------------------------------------------------------
/node_modules/gitbook-plugin-disqus/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "{}"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright 2014 FriendCode Inc.
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------
/node_modules/gitbook-plugin-disqus/README.md:
--------------------------------------------------------------------------------
1 | Disqus integration for GitBook
2 | ==============
3 |
4 | You can use install it via **NPM**:
5 |
6 | ```
7 | $ npm install gitbook-plugin-disqus
8 | ```
9 |
10 | And use it for your book with:
11 |
12 | ```
13 | $ gitbook build ./ --plugins=disqus
14 | ```
15 |
16 |
17 | You can set the Disqus shortname using the plugins configuration in the book.json:
18 |
19 | ```
20 | {
21 | plugins: ["disqus"],
22 | pluginsConfig: {
23 | "disqus": {
24 | "shortName": "XXXXXXX"
25 | }
26 | }
27 | }
28 | ```
29 |
30 |
--------------------------------------------------------------------------------
/node_modules/gitbook-plugin-disqus/book/plugin.js:
--------------------------------------------------------------------------------
1 | require(["gitbook", "jQuery"], function(gitbook, $) {
2 | var resetDisqus = function() {
3 | var $disqusDiv = $("", {
4 | "id": "disqus_thread"
5 | });
6 | $(".book-body .page-inner").append($disqusDiv);
7 |
8 | if (typeof DISQUS !== "undefined") {
9 | DISQUS.reset({
10 | reload: true,
11 | config: function () {
12 | this.language = "en";
13 | this.page.url = window.location.href;
14 | }
15 | });
16 | }
17 | }
18 |
19 | gitbook.events.bind("start", function(e, config) {
20 | config.disqus = config.disqus || {};
21 | var disqus_shortname = config.disqus.shortName;
22 |
23 | /* * * DON'T EDIT BELOW THIS LINE * * */
24 | (function() {
25 | var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
26 | dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js';
27 | (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
28 | })();
29 |
30 | resetDisqus();
31 | });
32 |
33 | gitbook.events.bind("page.change", resetDisqus);
34 | });
--------------------------------------------------------------------------------
/node_modules/gitbook-plugin-disqus/index.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | book: {
3 | assets: "./book",
4 | js: [
5 | "plugin.js"
6 | ]
7 | }
8 | };
--------------------------------------------------------------------------------
/node_modules/gitbook-plugin-disqus/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "gitbook-plugin-disqus",
3 | "description": "Disqus integration into GitBook",
4 | "main": "index.js",
5 | "version": "0.0.1",
6 | "engines": {
7 | "gitbook": "*"
8 | },
9 | "homepage": "https://github.com/GitbookIO/plugin-disqus",
10 | "repository": {
11 | "type": "git",
12 | "url": "https://github.com/GitbookIO/plugin-disqus.git"
13 | },
14 | "license": "Apache 2",
15 | "bugs": {
16 | "url": "https://github.com/GitbookIO/plugin-disqus/issues"
17 | }
18 | }
--------------------------------------------------------------------------------
/node_modules/gitbook-plugin-ga/.npmignore:
--------------------------------------------------------------------------------
1 | # Logs
2 | logs
3 | *.log
4 |
5 | # Runtime data
6 | pids
7 | *.pid
8 | *.seed
9 |
10 | # Directory for instrumented libs generated by jscoverage/JSCover
11 | lib-cov
12 |
13 | # Coverage directory used by tools like istanbul
14 | coverage
15 |
16 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
17 | .grunt
18 |
19 | # Compiled binary addons (http://nodejs.org/api/addons.html)
20 | build/Release
21 |
22 | # Dependency directory
23 | # Deployed apps should consider commenting this line out:
24 | # see https://npmjs.org/doc/faq.html#Should-I-check-my-node_modules-folder-into-git
25 | node_modules
26 |
--------------------------------------------------------------------------------
/node_modules/gitbook-plugin-ga/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "{}"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright {yyyy} {name of copyright owner}
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
--------------------------------------------------------------------------------
/node_modules/gitbook-plugin-ga/README.md:
--------------------------------------------------------------------------------
1 | Google Analytics tracking for GitBook
2 | ==============
3 |
4 | You can use install it via **NPM**:
5 |
6 | ```
7 | $ npm install gitbook-plugin-ga
8 | ```
9 |
10 | And use it for your book with in the book.json:
11 |
12 | ```
13 | {
14 | "plugins": ["ga"]
15 | }
16 | ```
17 |
18 | You can set the Google Analytics tracking ID using the plugins configuration in the book.json:
19 |
20 | ```
21 | {
22 | "plugins": ["ga"],
23 | "pluginsConfig": {
24 | "ga": {
25 | "token": "UA-XXXX-Y"
26 | }
27 | }
28 | }
29 | ```
30 |
31 | You can customize the tracker object by passing additional configuration options. You can either pass in `auto`, `none` or an object:
32 |
33 | ```
34 | {
35 | "plugins": ["ga"],
36 | "pluginsConfig": {
37 | "ga": {
38 | "token": "UA-XXXX-Y",
39 | "configuration": {
40 | "cookieName": "new_cookie_name",
41 | "cookieDomain": "mynew.domain.com"
42 | }
43 | }
44 | }
45 | }
46 | ```
47 |
48 | For an overview of all available configuration parameters, please refer to the [analytics.js field reference](https://developers.google.com/analytics/devguides/collection/analyticsjs/field-reference#create).
49 |
--------------------------------------------------------------------------------
/node_modules/gitbook-plugin-ga/book/plugin.js:
--------------------------------------------------------------------------------
1 | require(["gitbook"], function(gitbook) {
2 | gitbook.events.bind("start", function(e, config) {
3 | config.ga = config.ga || {};
4 | });
5 |
6 | gitbook.events.bind("page.change", function() {
7 | ga('send', 'pageview');
8 | });
9 |
10 | gitbook.events.bind("exercise.submit", function(e, data) {
11 |
12 | });
13 | });
--------------------------------------------------------------------------------
/node_modules/gitbook-plugin-ga/index.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | book: {
3 | assets: "./book",
4 | js: [
5 | "plugin.js"
6 | ],
7 | html: {
8 | "body:end": function() {
9 | var config = this.options.pluginsConfig.ga || {};
10 |
11 | if (!config.token) {
12 | throw "Need to option 'token' for Google Analytics plugin";
13 | }
14 |
15 | if (!config.configuration) {
16 | config.configuration = 'auto';
17 | }
18 |
19 | if(typeof config.configuration === 'object' && config.configuration !== null) {
20 | configuration = JSON.stringify(config.configuration);
21 | }
22 | else if (['auto', 'none'].indexOf(config.configuration) != -1) {
23 | configuration = "'" + config.configuration + "'";
24 | }
25 |
26 | return "";
32 | }
33 | }
34 | }
35 | };
36 |
--------------------------------------------------------------------------------
/node_modules/gitbook-plugin-ga/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "gitbook-plugin-ga",
3 | "description": "Google Analytics tracking for your gitbook",
4 | "main": "index.js",
5 | "version": "0.2.0",
6 | "engines": {
7 | "gitbook": ">=0.4.6"
8 | },
9 | "homepage": "https://github.com/GitbookIO/plugin-ga",
10 | "repository": {
11 | "type": "git",
12 | "url": "https://github.com/GitbookIO/plugin-ga.git"
13 | },
14 | "license": "Apache 2",
15 | "bugs": {
16 | "url": "https://github.com/GitbookIO/plugin-ga/issues"
17 | },
18 | "_id": "gitbook-plugin-ga@0.2.0",
19 | "dist": {
20 | "shasum": "456ef5daa08103c47cc38628667a1d34098bfd01",
21 | "tarball": "http://registry.npmjs.org/gitbook-plugin-ga/-/gitbook-plugin-ga-0.2.0.tgz"
22 | },
23 | "_from": "gitbook-plugin-ga@",
24 | "_npmVersion": "1.4.3",
25 | "_npmUser": {
26 | "name": "samypesse",
27 | "email": "samypesse@gmail.com"
28 | },
29 | "maintainers": [
30 | {
31 | "name": "samypesse",
32 | "email": "samypesse@gmail.com"
33 | }
34 | ],
35 | "directories": {},
36 | "_shasum": "456ef5daa08103c47cc38628667a1d34098bfd01",
37 | "_resolved": "https://registry.npmjs.org/gitbook-plugin-ga/-/gitbook-plugin-ga-0.2.0.tgz",
38 | "readme": "ERROR: No README data found!"
39 | }
40 |
--------------------------------------------------------------------------------
/requirements/README.md:
--------------------------------------------------------------------------------
1 | # Requirements(要求)
2 |
3 | * Gradle 1.10 或者 Gradle 1.11 或者 Gradle 1.12,并使用0.11.1插件版本。
4 | * SDK build tools 要求版本19.0.0。一些新的特征可能需要更高版本。
5 |
--------------------------------------------------------------------------------
/testing/README.md:
--------------------------------------------------------------------------------
1 | # Testing(测试)
2 |
3 | 构建一个测试程序已经被集成到应用项目中,没有必要再专门建立一个测试项目。
4 |
--------------------------------------------------------------------------------
/testing/basics_and_configuration.md:
--------------------------------------------------------------------------------
1 | # Basics and Configuration(基本知识和配置)
2 |
3 | 正如前面所提到的,紧邻`main` _sourceSet_的就是`androidTest` _sourceSet_,默认路径在src/androidTest/下。
4 | 在这个测试_sourceSet_中会构建一个使用Android测试框架,并且可以部署到设备上的测试apk来测试应用程序。这里面包含单元测试,集成测试,和后续UI自动化测试。
5 | 这个测试sourceSet不应该包含AndroidManifest.xml文件,因为这个文件会自动生成。
6 |
7 | 下面这些值可能会在测试应用配置中使用到:
8 |
9 | * `testPackageName`
10 | * `testInstrumentationRunner`
11 | * `testHandleProfiling`
12 | * `testfunctionalTest`
13 |
14 | 正如前面所看到的,这些配置在defaultConfig对象中配置:
15 |
16 | android {
17 | defaultConfig {
18 | testPackageName "com.test.foo"
19 | testInstrumentationRunner "android.test.InstrumentationTestRunner"
20 | testHandleProfiling true
21 | testFunctionalTest true
22 | }
23 | }
24 |
25 | 在测试应用程序的manifest文件中,instrumentation节点的targetPackage属性值会自动使用测试应用的package名称设置,即使这个名称是通过`defaultConfig`或者_Build Type_对象自定义的。这也是manifest文件需要自动生成的一个原因。
26 |
27 | 另外,这个测试_sourceSet_也可以拥有自己的依赖。
28 | 默认情况下,应用程序和他的依赖会自动添加的测试应用的classpath中,但是也可以通过以下来扩展:
29 |
30 | dependencies {
31 | androidTestCompile 'com.google.guava:guava:11.0.2'
32 | }
33 |
34 | 测试应用通过`assembleTest` task来构建。`assembleTest`不依赖于main中的`assemble` task,需要手动设置运行,不能自动运行。
35 |
36 | 目前只有一个_Build Type_被测试。默认情况下是`debug` _Build Type_,但是这也可以通过以下自定义配置:
37 |
38 | android {
39 | ...
40 | testBuildType "staging"
41 | }
42 |
--------------------------------------------------------------------------------
/testing/lint_supportlint.md:
--------------------------------------------------------------------------------
1 | # Lint support(Lint支持)
2 |
3 | > Lint支持,译者注:Lint是一个可以检查Android项目中存在的问题的工具
4 |
5 | 从0.7.0版本开始,你可以为项目中一个特定的Variant(变种)版本运行lint,也可以为所有Variant版本都运行lint。它将会生成一个报告描述哪一个Variant版本中存在着问题。
6 |
7 | 你可以通过以下lint选项配置lint。通常情况下你只需要配置其中一部分,以下列出了所有可使用的选项:
8 |
9 | android {
10 | lintOptions {
11 | // set to true to turn off analysis progress reporting by lint
12 | quiet true
13 | // if true, stop the gradle build if errors are found
14 | abortOnError false
15 | // if true, only report errors
16 | ignoreWarnings true
17 | // if true, emit full/absolute paths to files with errors (true by default)
18 | //absolutePaths true
19 | // if true, check all issues, including those that are off by default
20 | checkAllWarnings true
21 | // if true, treat all warnings as errors
22 | warningsAsErrors true
23 | // turn off checking the given issue id's
24 | disable 'TypographyFractions','TypographyQuotes'
25 | // turn on the given issue id's
26 | enable 'RtlHardcoded','RtlCompat', 'RtlEnabled'
27 | // check *only* the given issue id's
28 | check 'NewApi', 'InlinedApi'
29 | // if true, don't include source code lines in the error output
30 | noLines true
31 | // if true, show all locations for an error, do not truncate lists, etc.
32 | showAll true
33 | // Fallback lint configuration (default severities, etc.)
34 | lintConfig file("default-lint.xml")
35 | // if true, generate a text report of issues (false by default)
36 | textReport true
37 | // location to write the output; can be a file or 'stdout'
38 | textOutput 'stdout'
39 | // if true, generate an XML report for use by for example Jenkins
40 | xmlReport false
41 | // file to write report to (if not specified, defaults to lint-results.xml)
42 | xmlOutput file("lint-report.xml")
43 | // if true, generate an HTML report (with issue explanations, sourcecode, etc)
44 | htmlReport true
45 | // optional path to report (default will be lint-results.html in the builddir)
46 | htmlOutput file("lint-report.html")
47 |
48 | // set to true to have all release builds run lint on issues with severity=fatal
49 | // and abort the build (controlled by abortOnError above) if fatal issues are found
50 | checkReleaseBuilds true
51 | // Set the severity of the given issues to fatal (which means they will be
52 | // checked during release builds (even if the lint target is not included)
53 | fatal 'NewApi', 'InlineApi'
54 | // Set the severity of the given issues to error
55 | error 'Wakelock', 'TextViewEdits'
56 | // Set the severity of the given issues to warning
57 | warning 'ResourceAsColor'
58 | // Set the severity of the given issues to ignore (same as disabling the check)
59 | ignore 'TypographyQuotes'
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/testing/multi-projects_reports.md:
--------------------------------------------------------------------------------
1 | # Multi-projects reports(多项目报告)
2 |
3 | 在一个配置了多个应用或者多个库项目的多项目里,当同时运行所有测试的时候,生成一个报告文件记录所有的测试可能是非常有用的。
4 |
5 | 为了实现这个目的,需要使用同一个依赖文件(译注:指的是使用android gradle插件的依赖文件)中的另一个插件。可以通过以下方式添加:
6 |
7 | buildscript {
8 | repositories {
9 | mavenCentral()
10 | }
11 |
12 | dependencies {
13 | classpath 'com.android.tools.build:gradle:0.5.6'
14 | }
15 | }
16 |
17 | apply plugin: 'android-reporting'
18 |
19 | 这必须添加到项目的根目录下,例如与settings.gradle文件同个目录的build.gradle文件中。
20 |
21 | 之后,在命令行中导航到项目根目录下,输入以下命令就可以运行所有测试并合并所有报告:
22 |
23 | gradle deviceCheck mergeAndroidReports --continue
24 |
25 | ---
26 |
27 | > 注意:这里的--continue选项将允许所有测试,即使子项目中的任何一个运行失败都不会停止。如果没有这个选项,第一个失败测试将会终止全部测试的运行,这可能导致一些项目没有执行过它们的测试。
28 |
29 | ---
30 |
--------------------------------------------------------------------------------
/testing/running_tests.md:
--------------------------------------------------------------------------------
1 | # Running tests(运行测试)
2 |
3 | 正如前面提到的,标志性task `connectedCheck`要求一个连接的设备来启动。
4 | 这个过程依赖于`androidTest` task,因此将会运行`androidTest`。这个task将会执行下面内容:
5 |
6 | * 确认应用和测试应用都被构建(依赖于`assembleDebug`和`assembleTest`)。
7 | * 安装这两个应用。
8 | * 运行这些测试。
9 | * 卸载这两个应用。
10 |
11 | 如果有多于一个连接设备,那么所有测试都会同时运行在所有连接设备上。如果其中一个测试失败,不管是哪一个设备算失败。
12 |
13 | 所有测试结果都被保存为XML文档,路径为:
14 |
15 | _build/androidTest-results_
16 |
17 | (这类似于JUnit的运行结果保存在build/test-results)
18 |
19 | 同样,这也可以自定义配置:
20 |
21 | android {
22 | ...
23 |
24 | testOptions {
25 | resultsDir = "$project.buildDir/foo/results"
26 | }
27 | }
28 |
29 | 这里的`android.testOptions.resultsDir`将由`Project.file(String)`获得。
30 |
--------------------------------------------------------------------------------
/testing/single_projects.md:
--------------------------------------------------------------------------------
1 | # Single projects(独立项目)
2 |
3 | 一个项目将会自动生成测试运行。默认位置为:build/reports/androidTests
4 |
5 | 这非常类似于JUnit的报告所在位置build/reports/tests,其它的报告通常位于build/reports/< plugin >/。
6 |
7 | 这个路径也可以通过以下方式自定义:
8 |
9 | android {
10 | ...
11 |
12 | testOptions {
13 | reportDir = "$project.buildDir/foo/report"
14 | }
15 | }
16 |
17 | 报告将会合并运行在不同设备上的测试结果。
18 |
--------------------------------------------------------------------------------
/testing/test_reports.md:
--------------------------------------------------------------------------------
1 | # Test reports(测试报告)
2 |
3 | 当运行单元测试的时候,Gradle会输出一份HTML格式的报告以方便查看结果。
4 | Android plugin也是基于此,并且扩展了HTML报告文件,它将所有连接设备的报告都合并到一个文件里面。
5 |
--------------------------------------------------------------------------------
/testing/testing_android_librariesandroid.md:
--------------------------------------------------------------------------------
1 | # Testing Android Libraries(测试Android库)
2 |
3 | 测试Android库项目的方法与应用项目的方法类似。
4 |
5 | 唯一的不同在于整个库(包括它的依赖)都是自动作为依赖库被添加到测试应用中。结果就是测试APK不单只包含它的代码,还包含了库项目自己和库的所有依赖。
6 | 库的manifest被组合到测试应用的manifest中(作为一些项目引用这个库的壳)。
7 |
8 | `androidTest` task的变改只是安装(或者卸载)测试APK(因为没有其它APK被安装)。
9 |
10 | 其它的部分都是类似的。
11 |
--------------------------------------------------------------------------------