Alan Viverette | 05f668c | 2017-02-03 16:54:44 -0500 | [diff] [blame] | 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 | |
| 17 | import org.gradle.internal.os.OperatingSystem |
| 18 | |
Xavier Ducrohet | b98bb46 | 2014-10-27 21:12:20 -0700 | [diff] [blame] | 19 | buildscript { |
| 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 Viverette | 05f668c | 2017-02-03 16:54:44 -0500 | [diff] [blame] | 26 | classpath 'com.android.tools.build:gradle:2.3.0' |
Xavier Ducrohet | b98bb46 | 2014-10-27 21:12:20 -0700 | [diff] [blame] | 27 | } |
| 28 | } |
| 29 | |
Alan Viverette | 05f668c | 2017-02-03 16:54:44 -0500 | [diff] [blame] | 30 | apply from: 'version.gradle' |
| 31 | |
| 32 | final String platform = OperatingSystem.current().isMacOsX() ? 'darwin' : 'linux' |
| 33 | System.setProperty('android.dir', "${rootDir}/../../") |
| 34 | final String fullSdkPath = "${rootDir}/../../prebuilts/fullsdk-${platform}" |
| 35 | if (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 Ducrohet | b98bb46 | 2014-10-27 21:12:20 -0700 | [diff] [blame] | 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 | */ |
| 57 | if (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 | |
| 65 | ext.supportRepoOut = new File(buildDir, 'support_repo') |
| 66 | |
Xavier Ducrohet | b98bb46 | 2014-10-27 21:12:20 -0700 | [diff] [blame] | 67 | // upload anchor for subprojects to upload their artifacts |
| 68 | // to the local repo. |
Aurimas Liutikas | fd97bb8 | 2017-04-28 11:38:10 -0700 | [diff] [blame] | 69 | task dist(type: Zip) { |
Alan Viverette | 05f668c | 2017-02-03 16:54:44 -0500 | [diff] [blame] | 70 | group = BasePlugin.BUILD_GROUP |
| 71 | description 'Builds distribution artifacts.' |
Aurimas Liutikas | fd97bb8 | 2017-04-28 11:38:10 -0700 | [diff] [blame] | 72 | |
| 73 | from project.ext.supportRepoOut |
| 74 | into 'm2repository' |
| 75 | destinationDir project.ext.distDir |
| 76 | baseName = String.format("top-of-tree-m2repository-%s", project.multidexVersion) |
| 77 | |
| 78 | doLast { |
| 79 | logger.warn "Compressed maven artifacts to ${archivePath}" |
| 80 | } |
Xavier Ducrohet | b98bb46 | 2014-10-27 21:12:20 -0700 | [diff] [blame] | 81 | } |
| 82 | |
| 83 | subprojects { |
| 84 | // Change buildDir first so that all plugins pick up the new value. |
Alan Viverette | 05f668c | 2017-02-03 16:54:44 -0500 | [diff] [blame] | 85 | project.buildDir = project.file("${project.parent.buildDir}/../${project.name}/build") |
Xavier Ducrohet | b98bb46 | 2014-10-27 21:12:20 -0700 | [diff] [blame] | 86 | |
| 87 | apply plugin: 'maven' |
| 88 | |
Alan Viverette | 05f668c | 2017-02-03 16:54:44 -0500 | [diff] [blame] | 89 | version = rootProject.multidexVersion |
Xavier Ducrohet | b98bb46 | 2014-10-27 21:12:20 -0700 | [diff] [blame] | 90 | group = 'com.android.support' |
| 91 | |
Aurimas Liutikas | a5272c3 | 2017-06-07 15:31:04 -0700 | [diff] [blame] | 92 | dist.dependsOn project.tasks.uploadArchives |
Xavier Ducrohet | b98bb46 | 2014-10-27 21:12:20 -0700 | [diff] [blame] | 93 | |
| 94 | project.plugins.whenPluginAdded { plugin -> |
| 95 | if ("com.android.build.gradle.LibraryPlugin".equals(plugin.class.name)) { |
| 96 | project.android.buildToolsVersion = rootProject.buildToolsVersion |
| 97 | } |
| 98 | } |
| 99 | } |