blob: 3a5ed75bec864e27f9c61247a0fc1be0ec63059d [file] [log] [blame]
Alan Viverette05f668c2017-02-03 16:54:44 -05001/*
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
Xavier Ducrohetb98bb462014-10-27 21:12:20 -070019buildscript {
20 repositories {
21 maven { url '../../prebuilts/gradle-plugin' }
22 maven { url '../../prebuilts/tools/common/m2/repository' }
23 maven { url '../../prebuilts/tools/common/m2/internal' }
24 }
25 dependencies {
Alan Viverette05f668c2017-02-03 16:54:44 -050026 classpath 'com.android.tools.build:gradle:2.3.0'
Xavier Ducrohetb98bb462014-10-27 21:12:20 -070027 }
28}
29
Alan Viverette05f668c2017-02-03 16:54:44 -050030apply from: 'version.gradle'
31
32final String platform = OperatingSystem.current().isMacOsX() ? 'darwin' : 'linux'
33System.setProperty('android.dir', "${rootDir}/../../")
34final String fullSdkPath = "${rootDir}/../../prebuilts/fullsdk-${platform}"
35if (file(fullSdkPath).exists()) {
36 gradle.ext.currentSdk = 26
37 ext.buildToolsVersion = '26.0.0'
38 project.ext.androidJar = files("${fullSdkPath}/platforms/android-${gradle.currentSdk}/android.jar")
39 System.setProperty('android.home', "${rootDir}/../../prebuilts/fullsdk-${platform}")
40 File props = file("local.properties")
41 props.write "sdk.dir=${fullSdkPath}"
42} else {
43 gradle.ext.currentSdk = 'current'
44 ext.buildToolsVersion = '26.0.0'
45 project.ext.androidJar = files("${project.rootDir}/../../prebuilts/sdk/current/android.jar")
46 File props = file("local.properties")
47 props.write "android.dir=../../"
48}
Xavier Ducrohetb98bb462014-10-27 21:12:20 -070049
50/*
51 * With the build server you are given two env variables.
52 * The OUT_DIR is a temporary directory you can use to put things during the build.
53 * The DIST_DIR is where you want to save things from the build.
54 *
55 * The build server will copy the contents of DIST_DIR to somewhere and make it available.
56 */
57if (System.env.DIST_DIR != null && System.env.OUT_DIR != null) {
58 buildDir = new File(System.env.OUT_DIR + '/gradle/frameworks/support/build').getCanonicalFile()
59 project.ext.distDir = new File(System.env.DIST_DIR).getCanonicalFile()
60} else {
61 buildDir = file('../../out/host/gradle/frameworks/support/build')
62 project.ext.distDir = file('../../out/dist')
63}
64
65ext.supportRepoOut = new File(buildDir, 'support_repo')
66
Xavier Ducrohetb98bb462014-10-27 21:12:20 -070067// upload anchor for subprojects to upload their artifacts
68// to the local repo.
Alan Viverette05f668c2017-02-03 16:54:44 -050069task(dist) {
70 group = BasePlugin.BUILD_GROUP
71 description 'Builds distribution artifacts.'
Xavier Ducrohetb98bb462014-10-27 21:12:20 -070072}
73
74subprojects {
75 // Change buildDir first so that all plugins pick up the new value.
Alan Viverette05f668c2017-02-03 16:54:44 -050076 project.buildDir = project.file("${project.parent.buildDir}/../${project.name}/build")
Xavier Ducrohetb98bb462014-10-27 21:12:20 -070077
78 apply plugin: 'maven'
79
Alan Viverette05f668c2017-02-03 16:54:44 -050080 version = rootProject.multidexVersion
Xavier Ducrohetb98bb462014-10-27 21:12:20 -070081 group = 'com.android.support'
82
83 task release(type: Upload) {
84 configuration = configurations.archives
85 repositories {
86 mavenDeployer {
Alan Viverette05f668c2017-02-03 16:54:44 -050087 repository(url: uri("$rootProject.supportRepoOut"))
Xavier Ducrohetb98bb462014-10-27 21:12:20 -070088 }
89 }
90 }
91
Alan Viverette05f668c2017-02-03 16:54:44 -050092 task createArtifactZip(type: Zip, dependsOn: release) {
93 from release.artifacts
94 into archivesBaseName
95 destinationDir project.parent.distDir
96 baseName = archivesBaseName
97
98 doLast {
99 logger.warn "Compressed maven artifacts to ${archivePath}"
100 }
101 }
102
103 dist.dependsOn createArtifactZip
Xavier Ducrohetb98bb462014-10-27 21:12:20 -0700104
105 project.plugins.whenPluginAdded { plugin ->
106 if ("com.android.build.gradle.LibraryPlugin".equals(plugin.class.name)) {
107 project.android.buildToolsVersion = rootProject.buildToolsVersion
108 }
109 }
110}