blob: a95df22c48d290e35f0c540066ff966f014479eb [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 Ducrohet020e4322014-03-18 16:41:30 -07008 classpath 'com.android.tools.build:gradle:0.9.+'
Xavier Ducrohet86fb8ef2013-02-22 15:04:37 -08009 }
10}
11
Xavier Ducrohet020e4322014-03-18 16:41:30 -070012ext.supportVersion = '19.1.0'
Xavier Ducrohet9220b5b2014-03-21 15:30:01 -070013ext.extraVersion = 5
Xavier Ducrohet020e4322014-03-18 16:41:30 -070014ext.supportRepoOut = ''
Xavier Ducrohet86fb8ef2013-02-22 15:04:37 -080015
Xavier Ducrohet020e4322014-03-18 16:41:30 -070016/*
17 * With the build server you are given two env variables.
18 * The OUT_DIR is a temporary directory you can use to put things during the build.
19 * The DIST_DIR is where you want to save things from the build.
20 *
21 * The build server will copy the contents of DIST_DIR to somewhere and make it available.
22 */
23if (System.env.DIST_DIR != null && System.env.OUT_DIR != null) {
24 buildDir = file(System.env.OUT_DIR + '/gradle/frameworks/support/build')
25 project.ext.distDir = file(System.env.DIST_DIR)
26} else {
27 buildDir = file('../../out/host/gradle/frameworks/support/build')
28 project.ext.distDir = file('../../out/dist')
29}
Xavier Ducrohet86fb8ef2013-02-22 15:04:37 -080030
Xavier Ducrohet020e4322014-03-18 16:41:30 -070031ext.supportRepoOut = new File(buildDir, 'support_repo')
Xavier Ducrohet86fb8ef2013-02-22 15:04:37 -080032
Xavier Ducrohet9220b5b2014-03-21 15:30:01 -070033// Main task called by the build server.
34task(createArchive) << {
Xavier Ducrohet020e4322014-03-18 16:41:30 -070035}
36
Xavier Ducrohet9220b5b2014-03-21 15:30:01 -070037
38// upload anchor for subprojects to upload their artifacts
39// to the local repo.
40task(mainUpload) << {
41}
42
43// repository creation task
44task createRepository(type: Zip, dependsOn: mainUpload) {
Xavier Ducrohet020e4322014-03-18 16:41:30 -070045 from project.ext.supportRepoOut
46 destinationDir project.ext.distDir
Xavier Ducrohet9dc44802014-03-20 14:15:16 -070047 into 'm2repository'
Xavier Ducrohet9220b5b2014-03-21 15:30:01 -070048 baseName = String.format("android_m2repository_r%02d", project.ext.extraVersion)
Xavier Ducrohet020e4322014-03-18 16:41:30 -070049}
Xavier Ducrohet9220b5b2014-03-21 15:30:01 -070050createArchive.dependsOn createRepository
Xavier Ducrohet020e4322014-03-18 16:41:30 -070051
Xavier Ducrohet9220b5b2014-03-21 15:30:01 -070052// prepare repository with older versions
Xavier Ducrohet020e4322014-03-18 16:41:30 -070053task prepareRepo(type: Copy) {
Xavier Ducrohet86fb8ef2013-02-22 15:04:37 -080054 from "$rootDir/../../prebuilts/maven_repo/android"
Xavier Ducrohet855a9222014-01-02 19:00:43 -080055 into project.ext.supportRepoOut
Xavier Ducrohet86fb8ef2013-02-22 15:04:37 -080056}
57
Xavier Ducrohet020e4322014-03-18 16:41:30 -070058prepareRepo.doFirst {
59 project.ext.supportRepoOut.deleteDir()
60 project.ext.supportRepoOut.mkdirs()
61}
62
Xavier Ducrohet9220b5b2014-03-21 15:30:01 -070063import com.google.common.io.Files
64import com.google.common.base.Charsets
65
66task(createXml) << {
67 def repoArchive = createRepository.archivePath
68 def repoArchiveName = createRepository.archiveName
69 def size = repoArchive.length()
70 def sha1 = getSha1(repoArchive)
71
72 def xml =
73"<sdk:sdk-addon xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:sdk=\"http://schemas.android.com/sdk/android/addon/6\">\n\
74 <sdk:extra>\n\
75 <sdk:revision>\n\
76 <sdk:major>${project.ext.extraVersion}</sdk:major>\n\
77 </sdk:revision>\n\
78 <sdk:vendor-display>Android</sdk:vendor-display>\n\
79 <sdk:vendor-id>android</sdk:vendor-id>\n\
80 <sdk:name-display>Local Maven repository for Support Libraries</sdk:name-display>\n\
81 <sdk:path>m2repository</sdk:path>\n\
82 <sdk:archives>\n\
83 <sdk:archive os=\"any\" arch=\"any\">\n\
84 <sdk:size>${size}</sdk:size>\n\
85 <sdk:checksum type=\"sha1\">${sha1}</sdk:checksum>\n\
86 <sdk:url>${repoArchiveName}</sdk:url>\n\
87 </sdk:archive>\n\
88 </sdk:archives>\n\
89 </sdk:extra>\n\
90</sdk:sdk-addon>"
91
92 Files.write(xml, new File(project.ext.distDir, 'repo-extras.xml'), Charsets.UTF_8)
93}
94createArchive.dependsOn createXml
95
96
97import com.google.common.hash.HashCode
98import com.google.common.hash.HashFunction
99import com.google.common.hash.Hashing
100
101def getSha1(File inputFile) {
102 HashFunction hashFunction = Hashing.sha1()
103 HashCode hashCode = hashFunction.hashString(inputFile.getAbsolutePath())
104 return hashCode.toString()
105}
106
Xavier Ducrohet86fb8ef2013-02-22 15:04:37 -0800107subprojects {
108 // Change buildDir first so that all plugins pick up the new value.
Xavier Ducrohet616b95d2014-02-12 09:09:43 -0800109 project.buildDir = project.file("$project.parent.buildDir/../$project.name/build")
Xavier Ducrohet86fb8ef2013-02-22 15:04:37 -0800110
111 apply plugin: 'maven'
112
Xavier Ducrohet855a9222014-01-02 19:00:43 -0800113 version = rootProject.ext.supportVersion
Xavier Ducrohet86fb8ef2013-02-22 15:04:37 -0800114 group = 'com.android.support'
115
116 task release(type: Upload) {
117 configuration = configurations.archives
118 repositories {
119 mavenDeployer {
Xavier Ducrohet855a9222014-01-02 19:00:43 -0800120 repository(url: uri("$rootProject.ext.supportRepoOut"))
Xavier Ducrohet86fb8ef2013-02-22 15:04:37 -0800121 }
122 }
123 }
Xavier Ducrohet020e4322014-03-18 16:41:30 -0700124
Xavier Ducrohet9220b5b2014-03-21 15:30:01 -0700125 // before the upload, make sure the repo is ready.
Xavier Ducrohet020e4322014-03-18 16:41:30 -0700126 release.dependsOn rootProject.tasks.prepareRepo
Xavier Ducrohet9220b5b2014-03-21 15:30:01 -0700127 // make the mainupload depend on this one.
Xavier Ducrohet020e4322014-03-18 16:41:30 -0700128 mainUpload.dependsOn release
Xavier Ducrohet86fb8ef2013-02-22 15:04:37 -0800129}
130
131FileCollection getAndroidPrebuilt(String apiLevel) {
132 files("$rootDir/../../prebuilts/sdk/$apiLevel/android.jar")
133}
Xavier Ducrohet855a9222014-01-02 19:00:43 -0800134