1/*
2 * Copyright (C) 2017 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17import org.gradle.internal.os.OperatingSystem
18
19buildscript {
20    repositories {
21        maven { url '../../prebuilts/gradle-plugin' }
22    }
23    dependencies {
24        classpath 'com.android.tools.build:gradle:3.0.1'
25    }
26}
27
28apply from: 'version.gradle'
29
30String platform = OperatingSystem.current().isMacOsX() ? 'darwin' : 'linux'
31File fullSdkPath = file("${rootDir}/../../prebuilts/fullsdk-${platform}")
32if (!fullSdkPath.exists()) {
33    throw GradleException("missing fullsdk")
34}
35
36gradle.ext.currentSdk = 28
37ext.buildToolsVersion = '27.0.3'
38project.ext.fullSdkPath = fullSdkPath
39project.ext.androidJar = files("${fullSdkPath}/platforms/android-${gradle.currentSdk}/android.jar")
40
41File props = file("local.properties")
42props.write "sdk.dir=${fullSdkPath.getAbsolutePath()}"
43
44/*
45 * With the build server you are given two env variables.
46 * The OUT_DIR is a temporary directory you can use to put things during the build.
47 * The DIST_DIR is where you want to save things from the build.
48 *
49 * The build server will copy the contents of DIST_DIR to somewhere and make it available.
50 */
51if (System.env.DIST_DIR != null && System.env.OUT_DIR != null) {
52    buildDir = new File(System.env.OUT_DIR + '/gradle/frameworks/support/build').getCanonicalFile()
53    project.ext.distDir = new File(System.env.DIST_DIR).getCanonicalFile()
54} else {
55    buildDir = file('../../out/host/gradle/frameworks/support/build')
56    project.ext.distDir = file('../../out/dist')
57}
58
59ext.supportRepoOut = new File(buildDir, 'support_repo')
60
61// upload anchor for subprojects to upload their artifacts
62// to the local repo.
63task dist(type: Zip)  {
64    group = BasePlugin.BUILD_GROUP
65    description 'Builds distribution artifacts.'
66
67    from project.ext.supportRepoOut
68    into 'm2repository'
69    destinationDir project.ext.distDir
70    baseName = String.format("top-of-tree-m2repository-%s", project.multidexVersion)
71
72    doLast {
73        logger.warn "Compressed maven artifacts to ${archivePath}"
74    }
75}
76
77subprojects {
78    // Change buildDir first so that all plugins pick up the new value.
79    project.buildDir = project.file("${project.parent.buildDir}/../${project.name}/build")
80
81    apply plugin: 'maven'
82
83    version = rootProject.multidexVersion
84    group = 'androidx.multidex'
85
86    dist.dependsOn project.tasks.uploadArchives
87
88    project.plugins.whenPluginAdded { plugin ->
89        if ("com.android.build.gradle.LibraryPlugin".equals(plugin.class.name)) {
90            project.android.buildToolsVersion = rootProject.buildToolsVersion
91        }
92    }
93}
94