diff options
author | Alan Viverette <alanv@google.com> | 2017-02-03 16:54:44 -0500 |
---|---|---|
committer | Alan Viverette <alanv@google.com> | 2017-03-10 13:37:25 -0500 |
commit | 05f668cdd54faba1e63a817b5a5541187323ce97 (patch) | |
tree | 717d70f2518171416bc9442645bc02a266509e2b /build.gradle | |
parent | 802420556e424ddb3ca499b49cb9d27daf3927bf (diff) | |
download | multidex-05f668cdd54faba1e63a817b5a5541187323ce97.tar.gz |
Clean up multidex gradle build, bump version to 1.0.2 for release
Bug: 36122649
Test: ./gradlew dist test connectedAndroidTest
Change-Id: I79578f683146a3ea16521cd090d113698a14c5f5
Diffstat (limited to 'build.gradle')
-rw-r--r-- | build.gradle | 161 |
1 files changed, 56 insertions, 105 deletions
diff --git a/build.gradle b/build.gradle index f8306d5..3a5ed75 100644 --- a/build.gradle +++ b/build.gradle @@ -1,3 +1,21 @@ +/* + * Copyright (C) 2017 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import org.gradle.internal.os.OperatingSystem + buildscript { repositories { maven { url '../../prebuilts/gradle-plugin' } @@ -5,14 +23,29 @@ buildscript { maven { url '../../prebuilts/tools/common/m2/internal' } } dependencies { - classpath 'com.android.tools.build:gradle:0.10.0' + classpath 'com.android.tools.build:gradle:2.3.0' } } -ext.supportVersion = '1.0.1' -ext.extraVersion = 10 -ext.supportRepoOut = '' -ext.buildToolsVersion = '19.0.3' +apply from: 'version.gradle' + +final String platform = OperatingSystem.current().isMacOsX() ? 'darwin' : 'linux' +System.setProperty('android.dir', "${rootDir}/../../") +final String fullSdkPath = "${rootDir}/../../prebuilts/fullsdk-${platform}" +if (file(fullSdkPath).exists()) { + gradle.ext.currentSdk = 26 + ext.buildToolsVersion = '26.0.0' + project.ext.androidJar = files("${fullSdkPath}/platforms/android-${gradle.currentSdk}/android.jar") + System.setProperty('android.home', "${rootDir}/../../prebuilts/fullsdk-${platform}") + File props = file("local.properties") + props.write "sdk.dir=${fullSdkPath}" +} else { + gradle.ext.currentSdk = 'current' + ext.buildToolsVersion = '26.0.0' + project.ext.androidJar = files("${project.rootDir}/../../prebuilts/sdk/current/android.jar") + File props = file("local.properties") + props.write "android.dir=../../" +} /* * With the build server you are given two env variables. @@ -31,120 +64,43 @@ if (System.env.DIST_DIR != null && System.env.OUT_DIR != null) { ext.supportRepoOut = new File(buildDir, 'support_repo') -// Main task called by the build server. -task(createArchive) << { -} - // upload anchor for subprojects to upload their artifacts // to the local repo. -task(mainUpload) << { -} - -// repository creation task -task createRepository(type: Zip, dependsOn: mainUpload) { - from project.ext.supportRepoOut - destinationDir project.ext.distDir - into 'm2repository' - baseName = String.format("android_m2repository_r%02d", project.ext.extraVersion) -} -createArchive.dependsOn createRepository - -// prepare repository with older versions -task unzipRepo(type: Copy) { - from "$rootDir/../../prebuilts/maven_repo/android" - into project.ext.supportRepoOut -} - -unzipRepo.doFirst { - project.ext.supportRepoOut.deleteDir() - project.ext.supportRepoOut.mkdirs() -} - -// anchor for prepare repo. This is post unzip + sourceProp. -task(prepareRepo) << { -} - -import com.google.common.io.Files -import com.google.common.base.Charsets - -task(createXml) << { - def repoArchive = createRepository.archivePath - def repoArchiveName = createRepository.archiveName - def size = repoArchive.length() - def sha1 = getSha1(repoArchive) - - def xml = -"<sdk:sdk-addon xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:sdk=\"http://schemas.android.com/sdk/android/addon/6\">\n\ - <sdk:extra>\n\ - <sdk:revision>\n\ - <sdk:major>${project.ext.extraVersion}</sdk:major>\n\ - </sdk:revision>\n\ - <sdk:vendor-display>Android</sdk:vendor-display>\n\ - <sdk:vendor-id>android</sdk:vendor-id>\n\ - <sdk:name-display>Local Maven repository for Support Libraries</sdk:name-display>\n\ - <sdk:path>m2repository</sdk:path>\n\ - <sdk:archives>\n\ - <sdk:archive os=\"any\" arch=\"any\">\n\ - <sdk:size>${size}</sdk:size>\n\ - <sdk:checksum type=\"sha1\">${sha1}</sdk:checksum>\n\ - <sdk:url>${repoArchiveName}</sdk:url>\n\ - </sdk:archive>\n\ - </sdk:archives>\n\ - </sdk:extra>\n\ -</sdk:sdk-addon>" - - Files.write(xml, new File(project.ext.distDir, 'repo-extras.xml'), Charsets.UTF_8) -} -createArchive.dependsOn createXml - -task(createSourceProp) << { - def sourceProp = -"Extra.VendorDisplay=Android\n\ -Extra.Path=m2repository\n\ -Archive.Arch=ANY\n\ -Extra.NameDisplay=Android Support Repository\n\ -Archive.Os=ANY\n\ -Pkg.Revision=${project.ext.extraVersion}.0.0\n\ -Extra.VendorId=android" - - Files.write(sourceProp, new File(project.ext.supportRepoOut, 'source.properties'), Charsets.UTF_8) -} -createSourceProp.dependsOn unzipRepo -prepareRepo.dependsOn createSourceProp - - -import com.google.common.hash.HashCode -import com.google.common.hash.HashFunction -import com.google.common.hash.Hashing - -def getSha1(File inputFile) { - HashFunction hashFunction = Hashing.sha1() - HashCode hashCode = hashFunction.hashString(inputFile.getAbsolutePath()) - return hashCode.toString() +task(dist) { + group = BasePlugin.BUILD_GROUP + description 'Builds distribution artifacts.' } subprojects { // Change buildDir first so that all plugins pick up the new value. - project.buildDir = project.file("$project.parent.buildDir/../$project.name/build") + project.buildDir = project.file("${project.parent.buildDir}/../${project.name}/build") apply plugin: 'maven' - version = rootProject.ext.supportVersion + version = rootProject.multidexVersion group = 'com.android.support' task release(type: Upload) { configuration = configurations.archives repositories { mavenDeployer { - repository(url: uri("$rootProject.ext.supportRepoOut")) + repository(url: uri("$rootProject.supportRepoOut")) } } } - // before the upload, make sure the repo is ready. - release.dependsOn rootProject.tasks.prepareRepo - // make the mainupload depend on this one. - mainUpload.dependsOn release + task createArtifactZip(type: Zip, dependsOn: release) { + from release.artifacts + into archivesBaseName + destinationDir project.parent.distDir + baseName = archivesBaseName + + doLast { + logger.warn "Compressed maven artifacts to ${archivePath}" + } + } + + dist.dependsOn createArtifactZip project.plugins.whenPluginAdded { plugin -> if ("com.android.build.gradle.LibraryPlugin".equals(plugin.class.name)) { @@ -152,8 +108,3 @@ subprojects { } } } - -FileCollection getAndroidPrebuilt(String apiLevel) { - files("$rootDir/../../prebuilts/sdk/$apiLevel/android.jar") -} - |