Xavier Ducrohet | 86fb8ef | 2013-02-22 15:04:37 -0800 | [diff] [blame] | 1 | buildscript { |
| 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 Ducrohet | 21648b3 | 2014-04-10 17:09:18 -0700 | [diff] [blame] | 8 | classpath 'com.android.tools.build:gradle:0.10.0' |
Xavier Ducrohet | 86fb8ef | 2013-02-22 15:04:37 -0800 | [diff] [blame] | 9 | } |
| 10 | } |
| 11 | |
Xavier Ducrohet | af763ca | 2014-06-17 11:46:00 -0700 | [diff] [blame] | 12 | ext.supportVersion = '21.0.0-rc1' |
| 13 | ext.extraVersion = 6 |
Xavier Ducrohet | 020e432 | 2014-03-18 16:41:30 -0700 | [diff] [blame] | 14 | ext.supportRepoOut = '' |
Jeff Davidson | 84faec5 | 2014-06-18 09:10:36 -0700 | [diff] [blame] | 15 | ext.buildToolsVersion = '19.0.3' |
Xavier Ducrohet | 86fb8ef | 2013-02-22 15:04:37 -0800 | [diff] [blame] | 16 | |
Xavier Ducrohet | 020e432 | 2014-03-18 16:41:30 -0700 | [diff] [blame] | 17 | /* |
| 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 | */ |
| 24 | if (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 Ducrohet | 86fb8ef | 2013-02-22 15:04:37 -0800 | [diff] [blame] | 31 | |
Xavier Ducrohet | 020e432 | 2014-03-18 16:41:30 -0700 | [diff] [blame] | 32 | ext.supportRepoOut = new File(buildDir, 'support_repo') |
Xavier Ducrohet | 86fb8ef | 2013-02-22 15:04:37 -0800 | [diff] [blame] | 33 | |
Xavier Ducrohet | 9220b5b | 2014-03-21 15:30:01 -0700 | [diff] [blame] | 34 | // Main task called by the build server. |
| 35 | task(createArchive) << { |
Xavier Ducrohet | 020e432 | 2014-03-18 16:41:30 -0700 | [diff] [blame] | 36 | } |
| 37 | |
Xavier Ducrohet | 9220b5b | 2014-03-21 15:30:01 -0700 | [diff] [blame] | 38 | |
| 39 | // upload anchor for subprojects to upload their artifacts |
| 40 | // to the local repo. |
| 41 | task(mainUpload) << { |
| 42 | } |
| 43 | |
| 44 | // repository creation task |
| 45 | task createRepository(type: Zip, dependsOn: mainUpload) { |
Xavier Ducrohet | 020e432 | 2014-03-18 16:41:30 -0700 | [diff] [blame] | 46 | from project.ext.supportRepoOut |
| 47 | destinationDir project.ext.distDir |
Xavier Ducrohet | 9dc4480 | 2014-03-20 14:15:16 -0700 | [diff] [blame] | 48 | into 'm2repository' |
Xavier Ducrohet | 9220b5b | 2014-03-21 15:30:01 -0700 | [diff] [blame] | 49 | baseName = String.format("android_m2repository_r%02d", project.ext.extraVersion) |
Xavier Ducrohet | 020e432 | 2014-03-18 16:41:30 -0700 | [diff] [blame] | 50 | } |
Xavier Ducrohet | 9220b5b | 2014-03-21 15:30:01 -0700 | [diff] [blame] | 51 | createArchive.dependsOn createRepository |
Xavier Ducrohet | 020e432 | 2014-03-18 16:41:30 -0700 | [diff] [blame] | 52 | |
Xavier Ducrohet | 9220b5b | 2014-03-21 15:30:01 -0700 | [diff] [blame] | 53 | // prepare repository with older versions |
Xavier Ducrohet | 64fe232 | 2014-06-16 17:59:34 -0700 | [diff] [blame] | 54 | task unzipRepo(type: Copy) { |
Xavier Ducrohet | 86fb8ef | 2013-02-22 15:04:37 -0800 | [diff] [blame] | 55 | from "$rootDir/../../prebuilts/maven_repo/android" |
Xavier Ducrohet | 855a922 | 2014-01-02 19:00:43 -0800 | [diff] [blame] | 56 | into project.ext.supportRepoOut |
Xavier Ducrohet | 86fb8ef | 2013-02-22 15:04:37 -0800 | [diff] [blame] | 57 | } |
| 58 | |
Xavier Ducrohet | 64fe232 | 2014-06-16 17:59:34 -0700 | [diff] [blame] | 59 | unzipRepo.doFirst { |
Xavier Ducrohet | 020e432 | 2014-03-18 16:41:30 -0700 | [diff] [blame] | 60 | project.ext.supportRepoOut.deleteDir() |
| 61 | project.ext.supportRepoOut.mkdirs() |
| 62 | } |
| 63 | |
Xavier Ducrohet | 64fe232 | 2014-06-16 17:59:34 -0700 | [diff] [blame] | 64 | // anchor for prepare repo. This is post unzip + sourceProp. |
| 65 | task(prepareRepo) << { |
| 66 | } |
| 67 | |
Xavier Ducrohet | 9220b5b | 2014-03-21 15:30:01 -0700 | [diff] [blame] | 68 | import com.google.common.io.Files |
| 69 | import com.google.common.base.Charsets |
| 70 | |
| 71 | task(createXml) << { |
| 72 | def repoArchive = createRepository.archivePath |
| 73 | def repoArchiveName = createRepository.archiveName |
| 74 | def size = repoArchive.length() |
| 75 | def sha1 = getSha1(repoArchive) |
| 76 | |
| 77 | def xml = |
| 78 | "<sdk:sdk-addon xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:sdk=\"http://schemas.android.com/sdk/android/addon/6\">\n\ |
| 79 | <sdk:extra>\n\ |
| 80 | <sdk:revision>\n\ |
| 81 | <sdk:major>${project.ext.extraVersion}</sdk:major>\n\ |
| 82 | </sdk:revision>\n\ |
| 83 | <sdk:vendor-display>Android</sdk:vendor-display>\n\ |
| 84 | <sdk:vendor-id>android</sdk:vendor-id>\n\ |
| 85 | <sdk:name-display>Local Maven repository for Support Libraries</sdk:name-display>\n\ |
| 86 | <sdk:path>m2repository</sdk:path>\n\ |
| 87 | <sdk:archives>\n\ |
| 88 | <sdk:archive os=\"any\" arch=\"any\">\n\ |
| 89 | <sdk:size>${size}</sdk:size>\n\ |
| 90 | <sdk:checksum type=\"sha1\">${sha1}</sdk:checksum>\n\ |
| 91 | <sdk:url>${repoArchiveName}</sdk:url>\n\ |
| 92 | </sdk:archive>\n\ |
| 93 | </sdk:archives>\n\ |
| 94 | </sdk:extra>\n\ |
| 95 | </sdk:sdk-addon>" |
| 96 | |
| 97 | Files.write(xml, new File(project.ext.distDir, 'repo-extras.xml'), Charsets.UTF_8) |
| 98 | } |
| 99 | createArchive.dependsOn createXml |
| 100 | |
Xavier Ducrohet | 64fe232 | 2014-06-16 17:59:34 -0700 | [diff] [blame] | 101 | task(createSourceProp) << { |
| 102 | def sourceProp = |
| 103 | "Extra.VendorDisplay=Android\n\ |
| 104 | Extra.Path=m2repository\n\ |
| 105 | Archive.Arch=ANY\n\ |
| 106 | Extra.NameDisplay=Android Support Repository\n\ |
| 107 | Archive.Os=ANY\n\ |
| 108 | Pkg.Revision=${project.ext.extraVersion}.0.0\n\ |
| 109 | Extra.VendorId=android" |
| 110 | |
| 111 | Files.write(sourceProp, new File(project.ext.supportRepoOut, 'source.properties'), Charsets.UTF_8) |
| 112 | } |
| 113 | createSourceProp.dependsOn unzipRepo |
| 114 | prepareRepo.dependsOn createSourceProp |
| 115 | |
Xavier Ducrohet | 9220b5b | 2014-03-21 15:30:01 -0700 | [diff] [blame] | 116 | |
| 117 | import com.google.common.hash.HashCode |
| 118 | import com.google.common.hash.HashFunction |
| 119 | import com.google.common.hash.Hashing |
| 120 | |
| 121 | def getSha1(File inputFile) { |
| 122 | HashFunction hashFunction = Hashing.sha1() |
| 123 | HashCode hashCode = hashFunction.hashString(inputFile.getAbsolutePath()) |
| 124 | return hashCode.toString() |
| 125 | } |
| 126 | |
Xavier Ducrohet | 86fb8ef | 2013-02-22 15:04:37 -0800 | [diff] [blame] | 127 | subprojects { |
| 128 | // Change buildDir first so that all plugins pick up the new value. |
Xavier Ducrohet | 616b95d | 2014-02-12 09:09:43 -0800 | [diff] [blame] | 129 | project.buildDir = project.file("$project.parent.buildDir/../$project.name/build") |
Xavier Ducrohet | 86fb8ef | 2013-02-22 15:04:37 -0800 | [diff] [blame] | 130 | |
| 131 | apply plugin: 'maven' |
| 132 | |
Xavier Ducrohet | 855a922 | 2014-01-02 19:00:43 -0800 | [diff] [blame] | 133 | version = rootProject.ext.supportVersion |
Xavier Ducrohet | 86fb8ef | 2013-02-22 15:04:37 -0800 | [diff] [blame] | 134 | group = 'com.android.support' |
| 135 | |
| 136 | task release(type: Upload) { |
| 137 | configuration = configurations.archives |
| 138 | repositories { |
| 139 | mavenDeployer { |
Xavier Ducrohet | 855a922 | 2014-01-02 19:00:43 -0800 | [diff] [blame] | 140 | repository(url: uri("$rootProject.ext.supportRepoOut")) |
Xavier Ducrohet | 86fb8ef | 2013-02-22 15:04:37 -0800 | [diff] [blame] | 141 | } |
| 142 | } |
| 143 | } |
Xavier Ducrohet | 020e432 | 2014-03-18 16:41:30 -0700 | [diff] [blame] | 144 | |
Xavier Ducrohet | 9220b5b | 2014-03-21 15:30:01 -0700 | [diff] [blame] | 145 | // before the upload, make sure the repo is ready. |
Xavier Ducrohet | 020e432 | 2014-03-18 16:41:30 -0700 | [diff] [blame] | 146 | release.dependsOn rootProject.tasks.prepareRepo |
Xavier Ducrohet | 9220b5b | 2014-03-21 15:30:01 -0700 | [diff] [blame] | 147 | // make the mainupload depend on this one. |
Xavier Ducrohet | 020e432 | 2014-03-18 16:41:30 -0700 | [diff] [blame] | 148 | mainUpload.dependsOn release |
Jeff Davidson | 84faec5 | 2014-06-18 09:10:36 -0700 | [diff] [blame] | 149 | |
| 150 | project.plugins.whenPluginAdded { plugin -> |
| 151 | if ("com.android.build.gradle.LibraryPlugin".equals(plugin.class.name)) { |
| 152 | project.android.buildToolsVersion = rootProject.buildToolsVersion |
| 153 | } |
| 154 | } |
Xavier Ducrohet | 86fb8ef | 2013-02-22 15:04:37 -0800 | [diff] [blame] | 155 | } |
| 156 | |
| 157 | FileCollection getAndroidPrebuilt(String apiLevel) { |
| 158 | files("$rootDir/../../prebuilts/sdk/$apiLevel/android.jar") |
| 159 | } |
Xavier Ducrohet | 855a922 | 2014-01-02 19:00:43 -0800 | [diff] [blame] | 160 | |