blob: 2f18675d3ab6c4c34824e4b0704bee0718fd9235 [file] [log] [blame]
Xavier Ducrohet86fb8ef2013-02-22 15:04:37 -08001buildscript {
2 repositories {
3 maven { url '../../prebuilts/gradle-plugin' }
4 maven { url '../../prebuilts/tools/common/m2/repository' }
5 maven { url '../../prebuilts/tools/common/m2/internal' }
6 }
7 dependencies {
Xavier Ducrohet21648b32014-04-10 17:09:18 -07008 classpath 'com.android.tools.build:gradle:0.10.0'
Xavier Ducrohet86fb8ef2013-02-22 15:04:37 -08009 }
10}
11
Xavier Ducrohet21648b32014-04-10 17:09:18 -070012ext.supportVersion = '19.2.0'
13ext.extraVersion = 6
Xavier Ducrohet020e4322014-03-18 16:41:30 -070014ext.supportRepoOut = ''
Jeff Davidson84faec52014-06-18 09:10:36 -070015ext.buildToolsVersion = '19.0.3'
Xavier Ducrohet86fb8ef2013-02-22 15:04:37 -080016
Xavier Ducrohet020e4322014-03-18 16:41:30 -070017/*
18 * With the build server you are given two env variables.
19 * The OUT_DIR is a temporary directory you can use to put things during the build.
20 * The DIST_DIR is where you want to save things from the build.
21 *
22 * The build server will copy the contents of DIST_DIR to somewhere and make it available.
23 */
24if (System.env.DIST_DIR != null && System.env.OUT_DIR != null) {
25 buildDir = file(System.env.OUT_DIR + '/gradle/frameworks/support/build')
26 project.ext.distDir = file(System.env.DIST_DIR)
27} else {
28 buildDir = file('../../out/host/gradle/frameworks/support/build')
29 project.ext.distDir = file('../../out/dist')
30}
Xavier Ducrohet86fb8ef2013-02-22 15:04:37 -080031
Xavier Ducrohet020e4322014-03-18 16:41:30 -070032ext.supportRepoOut = new File(buildDir, 'support_repo')
Xavier Ducrohet86fb8ef2013-02-22 15:04:37 -080033
Xavier Ducrohet9220b5b2014-03-21 15:30:01 -070034// Main task called by the build server.
35task(createArchive) << {
Xavier Ducrohet020e4322014-03-18 16:41:30 -070036}
37
Xavier Ducrohet9220b5b2014-03-21 15:30:01 -070038
39// upload anchor for subprojects to upload their artifacts
40// to the local repo.
41task(mainUpload) << {
42}
43
44// repository creation task
45task createRepository(type: Zip, dependsOn: mainUpload) {
Xavier Ducrohet020e4322014-03-18 16:41:30 -070046 from project.ext.supportRepoOut
47 destinationDir project.ext.distDir
Xavier Ducrohet9dc44802014-03-20 14:15:16 -070048 into 'm2repository'
Xavier Ducrohet9220b5b2014-03-21 15:30:01 -070049 baseName = String.format("android_m2repository_r%02d", project.ext.extraVersion)
Xavier Ducrohet020e4322014-03-18 16:41:30 -070050}
Xavier Ducrohet9220b5b2014-03-21 15:30:01 -070051createArchive.dependsOn createRepository
Xavier Ducrohet020e4322014-03-18 16:41:30 -070052
Xavier Ducrohet9220b5b2014-03-21 15:30:01 -070053// prepare repository with older versions
Xavier Ducrohet020e4322014-03-18 16:41:30 -070054task prepareRepo(type: Copy) {
Xavier Ducrohet86fb8ef2013-02-22 15:04:37 -080055 from "$rootDir/../../prebuilts/maven_repo/android"
Xavier Ducrohet855a9222014-01-02 19:00:43 -080056 into project.ext.supportRepoOut
Xavier Ducrohet86fb8ef2013-02-22 15:04:37 -080057}
58
Xavier Ducrohet020e4322014-03-18 16:41:30 -070059prepareRepo.doFirst {
60 project.ext.supportRepoOut.deleteDir()
61 project.ext.supportRepoOut.mkdirs()
62}
63
Xavier Ducrohet9220b5b2014-03-21 15:30:01 -070064import com.google.common.io.Files
65import com.google.common.base.Charsets
66
67task(createXml) << {
68 def repoArchive = createRepository.archivePath
69 def repoArchiveName = createRepository.archiveName
70 def size = repoArchive.length()
71 def sha1 = getSha1(repoArchive)
72
73 def xml =
74"<sdk:sdk-addon xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:sdk=\"http://schemas.android.com/sdk/android/addon/6\">\n\
75 <sdk:extra>\n\
76 <sdk:revision>\n\
77 <sdk:major>${project.ext.extraVersion}</sdk:major>\n\
78 </sdk:revision>\n\
79 <sdk:vendor-display>Android</sdk:vendor-display>\n\
80 <sdk:vendor-id>android</sdk:vendor-id>\n\
81 <sdk:name-display>Local Maven repository for Support Libraries</sdk:name-display>\n\
82 <sdk:path>m2repository</sdk:path>\n\
83 <sdk:archives>\n\
84 <sdk:archive os=\"any\" arch=\"any\">\n\
85 <sdk:size>${size}</sdk:size>\n\
86 <sdk:checksum type=\"sha1\">${sha1}</sdk:checksum>\n\
87 <sdk:url>${repoArchiveName}</sdk:url>\n\
88 </sdk:archive>\n\
89 </sdk:archives>\n\
90 </sdk:extra>\n\
91</sdk:sdk-addon>"
92
93 Files.write(xml, new File(project.ext.distDir, 'repo-extras.xml'), Charsets.UTF_8)
94}
95createArchive.dependsOn createXml
96
97
98import com.google.common.hash.HashCode
99import com.google.common.hash.HashFunction
100import com.google.common.hash.Hashing
101
102def getSha1(File inputFile) {
103 HashFunction hashFunction = Hashing.sha1()
104 HashCode hashCode = hashFunction.hashString(inputFile.getAbsolutePath())
105 return hashCode.toString()
106}
107
Xavier Ducrohet86fb8ef2013-02-22 15:04:37 -0800108subprojects {
109 // Change buildDir first so that all plugins pick up the new value.
Xavier Ducrohet616b95d2014-02-12 09:09:43 -0800110 project.buildDir = project.file("$project.parent.buildDir/../$project.name/build")
Xavier Ducrohet86fb8ef2013-02-22 15:04:37 -0800111
112 apply plugin: 'maven'
113
Xavier Ducrohet855a9222014-01-02 19:00:43 -0800114 version = rootProject.ext.supportVersion
Xavier Ducrohet86fb8ef2013-02-22 15:04:37 -0800115 group = 'com.android.support'
116
117 task release(type: Upload) {
118 configuration = configurations.archives
119 repositories {
120 mavenDeployer {
Xavier Ducrohet855a9222014-01-02 19:00:43 -0800121 repository(url: uri("$rootProject.ext.supportRepoOut"))
Xavier Ducrohet86fb8ef2013-02-22 15:04:37 -0800122 }
123 }
124 }
Xavier Ducrohet020e4322014-03-18 16:41:30 -0700125
Xavier Ducrohet9220b5b2014-03-21 15:30:01 -0700126 // before the upload, make sure the repo is ready.
Xavier Ducrohet020e4322014-03-18 16:41:30 -0700127 release.dependsOn rootProject.tasks.prepareRepo
Xavier Ducrohet9220b5b2014-03-21 15:30:01 -0700128 // make the mainupload depend on this one.
Xavier Ducrohet020e4322014-03-18 16:41:30 -0700129 mainUpload.dependsOn release
Jeff Davidson84faec52014-06-18 09:10:36 -0700130
131 project.plugins.whenPluginAdded { plugin ->
132 if ("com.android.build.gradle.LibraryPlugin".equals(plugin.class.name)) {
133 project.android.buildToolsVersion = rootProject.buildToolsVersion
134 }
135 }
Xavier Ducrohet86fb8ef2013-02-22 15:04:37 -0800136}
137
138FileCollection getAndroidPrebuilt(String apiLevel) {
139 files("$rootDir/../../prebuilts/sdk/$apiLevel/android.jar")
140}
Xavier Ducrohet855a9222014-01-02 19:00:43 -0800141