summaryrefslogtreecommitdiff
path: root/build.gradle
blob: 45d505b3d6f883471e66b0b8f8ef150f4f312711 (plain)
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
/*
 * Copyright (C) 2017 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.
 */

import org.gradle.internal.os.OperatingSystem

buildscript {
    repositories {
        maven { url '../../prebuilts/gradle-plugin' }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'
    }
}

apply from: 'version.gradle'

String platform = OperatingSystem.current().isMacOsX() ? 'darwin' : 'linux'
File fullSdkPath = file("${rootDir}/../../prebuilts/fullsdk-${platform}")
if (!fullSdkPath.exists()) {
    throw GradleException("missing fullsdk")
}

gradle.ext.currentSdk = 28
ext.buildToolsVersion = '27.0.3'
project.ext.fullSdkPath = fullSdkPath
project.ext.androidJar = files("${fullSdkPath}/platforms/android-${gradle.currentSdk}/android.jar")

File props = file("local.properties")
props.write "sdk.dir=${fullSdkPath.getAbsolutePath()}"

/*
 * With the build server you are given two env variables.
 * The OUT_DIR is a temporary directory you can use to put things during the build.
 * The DIST_DIR is where you want to save things from the build.
 *
 * The build server will copy the contents of DIST_DIR to somewhere and make it available.
 */
if (System.env.DIST_DIR != null && System.env.OUT_DIR != null) {
    buildDir = new File(System.env.OUT_DIR + '/gradle/frameworks/support/build').getCanonicalFile()
    project.ext.distDir = new File(System.env.DIST_DIR).getCanonicalFile()
} else {
    buildDir = file('../../out/host/gradle/frameworks/support/build')
    project.ext.distDir = file('../../out/dist')
}

ext.supportRepoOut = new File(buildDir, 'support_repo')

// upload anchor for subprojects to upload their artifacts
// to the local repo.
task dist(type: Zip)  {
    group = BasePlugin.BUILD_GROUP
    description 'Builds distribution artifacts.'

    from project.ext.supportRepoOut
    into 'm2repository'
    destinationDir project.ext.distDir
    baseName = String.format("top-of-tree-m2repository-%s", project.multidexVersion)

    doLast {
        logger.warn "Compressed maven artifacts to ${archivePath}"
    }
}

subprojects {
    // Change buildDir first so that all plugins pick up the new value.
    project.buildDir = project.file("${project.parent.buildDir}/../${project.name}/build")

    apply plugin: 'maven'

    version = rootProject.multidexVersion
    group = 'androidx.multidex'

    dist.dependsOn project.tasks.uploadArchives

    project.plugins.whenPluginAdded { plugin ->
        if ("com.android.build.gradle.LibraryPlugin".equals(plugin.class.name)) {
            project.android.buildToolsVersion = rootProject.buildToolsVersion
        }
    }
}