File: build.gradle

package info (click to toggle)
android-platform-tools-base 2.2.2-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 113,928 kB
  • sloc: java: 696,396; xml: 45,920; cpp: 2,526; ansic: 1,432; sh: 508; lisp: 110; javascript: 108; makefile: 17
file content (154 lines) | stat: -rw-r--r-- 5,557 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
/*
 * Copyright (C) 2015 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

apply from: "../commonHeader.gradle"
buildscript { apply from: "../commonBuildScript.gradle" }
apply from: "../commonLocalRepo.gradle"

def env = new Object() {
    Object project = new Object() {
        Object ext = new Object() {
            String buildVersion
            String baseVersion
            String apiVersion
            String nativeApiVersion
            String experimentalVersion
            String experimentalGradleVersion
            String versionModifier
        }
    }
}
apply from: "$System.env.CUSTOM_REPO/../../tools/buildSrc/base/version.gradle", to: env


import com.android.utils.FileUtils
import com.google.common.base.Charsets
import com.google.common.collect.ImmutableList
import com.google.common.io.CharSink
import com.google.common.io.Files

def PROJECT_ROOT = new File(System.getenv("CUSTOM_REPO")).getParentFile().getParentFile()

apply plugin: 'com.android.library'

android {
    compileSdkVersion 15
    buildToolsVersion rootProject.buildToolsVersion

    defaultConfig {
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        minSdkVersion 15
        targetSdkVersion 15
        versionCode 1
        versionName "1.0"
    }

    sourceSets {

        main.java.srcDir("src/androidTest/java")

        androidTest {
            java {
                setSrcDirs(["${PROJECT_ROOT}/tools/base/build-system/gradle-core/src/test/java"])
                filter.setIncludes(["com/android/build/gradle/internal/incremental/hotswap/*.java"])
            }
            assets {
                srcDir(file("build/generatedAssets/"))
            }
        }
    }
}

File instantRunServer = new File(
        PROJECT_ROOT,
        "out/build/base/instant-run/instant-run-server/build/libs/instant-run-server.jar")
if (!instantRunServer.exists()) {
    throw new RuntimeException("Instant run server library not found: " + instantRunServer)
}

dependencies {
    compile 'com.android.tools:annotations:' + env.project.ext.baseVersion
    compile 'com.google.guava:guava:17.0'
    compile files(instantRunServer)
    compile files("build/incremental-test-classes-jar/instrumentedBaseClasses.jar")

    compile 'com.android.support:support-v4:23.0.1'
    //provided gradleApi() // TODO: remove
    //androidTestCompile 'junit:junit:4.12'
    androidTestCompile 'com.google.code.findbugs:jsr305:1.3.9'
    androidTestCompile 'com.google.truth:truth:0.28'
    //androidTestCompile 'org.mockito:mockito-core:1.9.5'
    androidTestCompile 'com.google.guava:guava:17.0'
    compile 'com.android.support.test:runner:0.3'
    androidTestCompile 'com.android.support.test:rules:0.3'
}


def jarInstrumentedBaseClasses = task("jarInstrumentedBaseClasses", type: Jar) {
    from (files(new File(PROJECT_ROOT,
            "out/build/base/gradle-core/build/classes/incremental-test/baseInstrumented")))
    destinationDir = file("build/incremental-test-classes-jar/")
    archiveName = "instrumentedBaseClasses.jar"
}

class DexTask extends DefaultTask {

    @InputDirectory
    File classesFolder

    @OutputDirectory
    File outputFolder

    @TaskAction
    public void compileDexFiles() {
        File classesFolder = getClassesFolder()
        File outputFolder = getOutputFolder()
        def builder = project.getPlugins().findPlugin("com.android.library").androidBuilder
        builder.convertByteCode(ImmutableList.of(classesFolder),
                outputFolder,
                false /* multiDexEnabled */,
                null /*getMainDexListFile */,
                new com.android.build.gradle.internal.dsl.DexOptions(),
                false /* optimize */,
                new com.android.ide.common.process.LoggedProcessOutputHandler(
                        new com.android.build.gradle.internal.LoggerWrapper(getLogger())))
        Iterable<File> files =
                Files.fileTreeTraverser().preOrderTraversal(classesFolder).filter(Files.isFile());

        CharSink filesList = Files.asCharSink(new File(outputFolder, "classes.txt"), Charsets.UTF_8)
        Writer filesListWriter = filesList.openBufferedStream()
        for (File classFile : files) {
            filesListWriter.append(FileUtils.relativePath(classFile, classesFolder)).append('\n');
        }
        filesListWriter.close()
    }

}

def dexInstrumentedPatches = task("dexInstrumentedPatches")

for (File f: new File(PROJECT_ROOT, "out/build/base/gradle-core/build/classes/incremental-test/instrumentedPatches").listFiles()) {
    String patchName = f.getName()
    Task dexInstrumentedPatch = task("dexInstrumentedPatch" + patchName.capitalize(), type:DexTask) {
        classesFolder = f
        outputFolder = file("build/generatedAssets/incremental-test-classes-dex/" + patchName)
    }
    dexInstrumentedPatches.dependsOn dexInstrumentedPatch

}
project.afterEvaluate {
    tasks.getByPath(":preDebugBuild").dependsOn(dexInstrumentedPatches, jarInstrumentedBaseClasses)
}