com android build gradle libraryplugin,build.gradle

buildscript {

repositories {

maven { url '../../prebuilts/gradle-plugin' }

maven { url '../../prebuilts/tools/common/m2/repository' }

maven { url '../../prebuilts/tools/common/m2/internal' }

}

dependencies {

classpath 'com.android.tools.build:gradle:0.10.0'

}

}

ext.supportVersion = '21.0.0'

ext.extraVersion = 7

ext.supportRepoOut = ''

ext.buildToolsVersion = '19.0.3'

/*

* With the build server you are given two env variables.

* The OUT_DIR is a temporary directory you can use to put things during the build.

* The DIST_DIR is where you want to save things from the build.

*

* The build server will copy the contents of DIST_DIR to somewhere and make it available.

*/

if (System.env.DIST_DIR != null && System.env.OUT_DIR != null) {

buildDir = new File(System.env.OUT_DIR + '/gradle/frameworks/support/build').getCanonicalFile()

project.ext.distDir = new File(System.env.DIST_DIR).getCanonicalFile()

} else {

buildDir = file('../../out/host/gradle/frameworks/support/build')

project.ext.distDir = file('../../out/dist')

}

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 =

"\n\

\n\

\n\

${project.ext.extraVersion}\n\

\n\

Android\n\

android\n\

Local Maven repository for Support Libraries\n\

m2repository\n\

\n\

\n\

${size}\n\

${sha1}\n\

${repoArchiveName}\n\

\n\

\n\

\n\

"

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()

}

subprojects {

// Change buildDir first so that all plugins pick up the new value.

project.buildDir = project.file("$project.parent.buildDir/../$project.name/build")

apply plugin: 'maven'

version = rootProject.ext.supportVersion

group = 'com.android.support'

task release(type: Upload) {

configuration = configurations.archives

repositories {

mavenDeployer {

repository(url: uri("$rootProject.ext.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

project.plugins.whenPluginAdded { plugin ->

if ("com.android.build.gradle.LibraryPlugin".equals(plugin.class.name)) {

project.android.buildToolsVersion = rootProject.buildToolsVersion

}

}

}

FileCollection getAndroidPrebuilt(String apiLevel) {

files("$rootDir/../../prebuilts/sdk/$apiLevel/android.jar")

}

一键复制

编辑

Web IDE

原始数据

按行查看

历史

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值