supportBundle.gradle revision d6ddc647acae6d322cb7d41100c087530b249e80
1buildscript { 2 ext.addRepos(repositories) 3 dependencies { 4 classpath 'com.google.guava:guava:18.0' 5 } 6} 7import com.google.common.io.Files 8import com.google.common.base.Charsets 9import com.google.common.hash.HashCode 10import com.google.common.hash.HashFunction 11import com.google.common.hash.Hashing 12import java.nio.charset.Charset 13 14 15ext.extraVersion = 20 16ext.supportRepoOut = '' 17ext.buildToolsVersion = '22.1.0' 18ext.buildNumber = Integer.toString(ext.extraVersion) 19 20/* 21 * With the build server you are given two env variables. 22 * The OUT_DIR is a temporary directory you can use to put things during the build. 23 * The DIST_DIR is where you want to save things from the build. 24 * 25 * The build server will copy the contents of DIST_DIR to somewhere and make it available. 26 */ 27if (System.env.DIST_DIR != null && System.env.OUT_DIR != null) { 28 buildDir = new File(System.env.OUT_DIR + '/gradle/frameworks/support/build').getCanonicalFile() 29 project.ext.distDir = new File(System.env.DIST_DIR).getCanonicalFile() 30 31 // the build server does not pass the build number so we infer it from the last folder of the dist path. 32 ext.buildNumber = project.ext.distDir.getName() 33} else { 34 buildDir = file('../../out/host/gradle/frameworks/support/build') 35 project.ext.distDir = file('../../out/dist') 36} 37project.ext.distDir.mkdirs() 38 39ext.supportRepoOut = new File(buildDir, 'support_repo') 40 41// Main task called by the build server. 42task(createArchive) << { 43} 44 45 46// upload anchor for subprojects to upload their artifacts 47// to the local repo. 48task(mainUpload) << { 49} 50 51// repository creation task 52task createRepository(type: Zip, dependsOn: mainUpload) { 53 from project.ext.supportRepoOut 54 destinationDir project.ext.distDir 55 into 'm2repository' 56 baseName = String.format("sdk-repo-linux-m2repository-%s", project.ext.buildNumber) 57} 58createArchive.dependsOn createRepository 59 60// prepare repository with older versions 61task unzipRepo(type: Copy) { 62 from "$rootDir/../../prebuilts/maven_repo/android" 63 into project.ext.supportRepoOut 64} 65 66unzipRepo.doFirst { 67 project.ext.supportRepoOut.deleteDir() 68 project.ext.supportRepoOut.mkdirs() 69} 70 71// anchor for prepare repo. This is post unzip + sourceProp. 72task(prepareRepo) << { 73} 74 75task(createXml) << { 76 def repoArchive = createRepository.archivePath 77 def repoArchiveName = createRepository.archiveName 78 def size = repoArchive.length() 79 def sha1 = getSha1(repoArchive) 80 81 def xml = 82 "<sdk:sdk-addon xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:sdk=\"http://schemas.android.com/sdk/android/addon/6\">\n\ 83 <sdk:extra>\n\ 84 <sdk:revision>\n\ 85 <sdk:major>${project.ext.extraVersion}</sdk:major>\n\ 86 </sdk:revision>\n\ 87 <sdk:vendor-display>Android</sdk:vendor-display>\n\ 88 <sdk:vendor-id>android</sdk:vendor-id>\n\ 89 <sdk:name-display>Local Maven repository for Support Libraries</sdk:name-display>\n\ 90 <sdk:path>m2repository</sdk:path>\n\ 91 <sdk:archives>\n\ 92 <sdk:archive>\n\ 93 <sdk:size>${size}</sdk:size>\n\ 94 <sdk:checksum type=\"sha1\">${sha1}</sdk:checksum>\n\ 95 <sdk:url>${repoArchiveName}</sdk:url>\n\ 96 </sdk:archive>\n\ 97 </sdk:archives>\n\ 98 </sdk:extra>\n\ 99</sdk:sdk-addon>" 100 101 Files.write(xml, new File(project.ext.distDir, 'repo-extras.xml'), Charsets.UTF_8) 102} 103createArchive.dependsOn createXml 104 105task(createSourceProp) << { 106 def sourceProp = 107 "Extra.VendorDisplay=Android\n\ 108Extra.Path=m2repository\n\ 109Archive.Arch=ANY\n\ 110Extra.NameDisplay=Android Support Repository\n\ 111Archive.Os=ANY\n\ 112Pkg.Revision=${project.ext.extraVersion}.0.0\n\ 113Extra.VendorId=android" 114 115 Files.write(sourceProp, new File(project.ext.supportRepoOut, 'source.properties'), Charsets.UTF_8) 116} 117createSourceProp.dependsOn unzipRepo 118prepareRepo.dependsOn createSourceProp 119 120 121def getSha1(File inputFile) { 122 HashFunction hashFunction = Hashing.sha1() 123 HashCode hashCode = hashFunction.hashString(inputFile.getAbsolutePath(), Charset.forName("UTF-8")) 124 return hashCode.toString() 125} 126 127task(bundleSupportLib) << { 128 129} 130 131createRepository.dependsOn unzipRepo 132unzipRepo.dependsOn bundleSupportLib 133