You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
133 lines
4.2 KiB
133 lines
4.2 KiB
buildscript { |
|
ext.addRepos(repositories) |
|
dependencies { |
|
classpath 'com.google.guava:guava:18.0' |
|
} |
|
} |
|
import com.google.common.io.Files |
|
import com.google.common.base.Charsets |
|
import com.google.common.hash.HashCode |
|
import com.google.common.hash.HashFunction |
|
import com.google.common.hash.Hashing |
|
import java.nio.charset.Charset |
|
|
|
|
|
ext.extraVersion = 22 |
|
ext.supportRepoOut = '' |
|
ext.buildToolsVersion = '22.1.0' |
|
ext.buildNumber = Integer.toString(ext.extraVersion) |
|
|
|
/* |
|
* 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() |
|
|
|
// the build server does not pass the build number so we infer it from the last folder of the dist path. |
|
ext.buildNumber = project.ext.distDir.getName() |
|
} else { |
|
buildDir = file('../../out/host/gradle/frameworks/support/build') |
|
project.ext.distDir = file('../../out/dist') |
|
} |
|
project.ext.distDir.mkdirs() |
|
ext.supportRepoOut = new File(buildDir, 'support_repo') |
|
|
|
// Main task called by the build server. |
|
task(createArchive) << { |
|
} |
|
createArchive.doLast { |
|
println "support repo out ${project.ext.supportRepoOut}" |
|
println "dist dir ${project.ext.distDir}" |
|
|
|
} |
|
|
|
// 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("sdk-repo-linux-m2repository-%s", project.ext.buildNumber) |
|
} |
|
createArchive.dependsOn createRepository |
|
// prepare repository with older versions |
|
task unzipRepo(type: Copy) { |
|
from "${dataBindingConfig.externalPrebuiltsBase}/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) << { |
|
} |
|
|
|
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>\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 |
|
|
|
|
|
def getSha1(File inputFile) { |
|
HashFunction hashFunction = Hashing.sha1() |
|
HashCode hashCode = hashFunction.hashString(inputFile.getAbsolutePath(), Charset.forName("UTF-8")) |
|
return hashCode.toString() |
|
} |
|
|
|
task(bundleSupportLib) << { |
|
|
|
} |
|
createRepository.dependsOn prepareRepo |
|
createRepository.dependsOn unzipRepo |
|
createRepository.dependsOn bundleSupportLib
|
|
|