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 maven { url '../../prebuilts/tools/common/m2/repository' } 23 maven { url '../../prebuilts/tools/common/m2/internal' } 24 } 25 dependencies { 26 classpath 'com.android.tools.build:gradle:2.3.0' 27 } 28} 29 30apply 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} 49 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 67// upload anchor for subprojects to upload their artifacts 68// to the local repo. 69task(dist) { 70 group = BasePlugin.BUILD_GROUP 71 description 'Builds distribution artifacts.' 72} 73 74subprojects { 75 // Change buildDir first so that all plugins pick up the new value. 76 project.buildDir = project.file("${project.parent.buildDir}/../${project.name}/build") 77 78 apply plugin: 'maven' 79 80 version = rootProject.multidexVersion 81 group = 'com.android.support' 82 83 task release(type: Upload) { 84 configuration = configurations.archives 85 repositories { 86 mavenDeployer { 87 repository(url: uri("$rootProject.supportRepoOut")) 88 } 89 } 90 } 91 92 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 104 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} 111