| buildscript { |
| repositories { |
| maven { url "$project.rootDir/../../prebuilts/tools/common/offline-m2" } |
| } |
| dependencies { |
| classpath 'com.android.tools.build:gradle:2.2.0' |
| |
| // NOTE: Do not place your application dependencies here; they belong |
| // in the individual module build.gradle files |
| } |
| } |
| |
| import com.google.common.io.Files |
| import com.google.common.base.Charsets |
| |
| task('checkJavaVersion') << { |
| def jvmVersion = System.getProperty('java.version') |
| def requiredVersion = System.getenv('JAVA_FOR_TESTS') ?: '1.8' |
| if (!jvmVersion.startsWith(requiredVersion)) { |
| throw new RuntimeException("Tools need to be compiled with Java $requiredVersion, you are using Java $jvmVersion.") |
| } |
| } |
| final def checkJavaVersionTask = tasks['checkJavaVersion'] |
| |
| ext.version = '1.1.2' |
| |
| /* |
| * 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) { |
| ext.androidHostOut = file(System.env.OUT_DIR) |
| ext.androidHostDist = file(System.env.DIST_DIR) |
| ext.buildNumber = System.env.BUILD |
| } else { |
| // ext.androidHostOut is shared by all tools/{base,build,swt} gradle projects/ |
| ext.androidHostOut = file("$rootDir/../../out") |
| ext.androidHostDist = new File(ext.androidHostOut, "dist") |
| ext.buildNumber = null |
| } |
| |
| // rootProject.buildDir is specific to this gradle build. |
| buildDir = new File(ext.androidHostOut, "build/root") |
| ext.supportRepoOut = new File(buildDir, 'repo') |
| |
| ext.localRepo = project.hasProperty('localRepo') ? localRepo : "$ext.androidHostOut/repo" |
| |
| // basic task for custom distribution of project via the build server. |
| task dist << { |
| } |
| |
| project(':constraintlayout') { |
| ext.pomName = 'Android ConstraintLayout' |
| ext.pomDesc = 'ConstraintLayout for Android' |
| } |
| |
| project(':solver') { |
| ext.pomName = 'Android ConstraintLayout Solver' |
| ext.pomDesc = 'Solver for ConstraintLayout' |
| } |
| |
| subprojects { Project project -> |
| // Change buildDir first so that all plugins pick up the new value. |
| project.buildDir = project.file("$project.parent.buildDir/../$project.name/build") |
| |
| group = 'com.android.support.constraint' |
| version = rootProject.ext.version |
| |
| apply plugin: 'maven' |
| |
| repositories { |
| maven { url "$rootProject.projectDir/../../prebuilts/tools/common/m2/repository" } |
| } |
| |
| task release(type: Upload) { |
| configuration = configurations.archives |
| repositories { |
| mavenDeployer { |
| repository(url: uri("$rootProject.ext.supportRepoOut")) |
| if (project.getName() == 'constraintlayout' || project.getName() == 'solver') { |
| pom.project { |
| name project.ext.pomName |
| description project.ext.pomDesc |
| |
| url 'http://tools.android.com' |
| inceptionYear '2007' |
| |
| licenses { |
| license { |
| name 'The Apache Software License, Version 2.0' |
| url 'http://www.apache.org/licenses/LICENSE-2.0.txt' |
| distribution 'repo' |
| } |
| } |
| |
| scm { |
| url 'https://android.googlesource.com/platform/tools/sherpa' |
| connection 'git://android.googlesource.com/platform/tools/sherpa.git' |
| } |
| developers { |
| developer { |
| name 'The Android Open Source Project' |
| } |
| } |
| } |
| } |
| } |
| } |
| } |
| |
| def versionDir = { |
| def groupDir = new File(rootProject.ext.supportRepoOut, project.group.replace('.','/')) |
| def artifactDir = new File(groupDir, archivesBaseName) |
| return new File(artifactDir, version) |
| } |
| |
| def deployer = release.repositories.mavenDeployer |
| task generateSourceProps(dependsOn: release) << { |
| def content = "Maven.GroupId=$deployer.pom.groupId\n" + |
| "Maven.ArtifactId=$deployer.pom.artifactId\n" + |
| "Maven.Version=$deployer.pom.version\n" + |
| "Pkg.Desc=$project.ext.pomDesc $deployer.pom.version\n" + |
| "Pkg.Revision=1\n" + |
| "Extra.VendorId=android\n" + |
| "Extra.VendorDisplay=Android\n" + |
| "Maven.Dependencies=" + |
| String.join(",", project.configurations.compile.allDependencies.collect { |
| def p = parent.findProject(it.name) |
| return p ? "$p.group:$p.archivesBaseName:$p.version" : null |
| }.grep()) + |
| "\n" |
| Files.write(content, new File(versionDir(), 'source.properties'), Charsets.UTF_8) |
| } |
| |
| task createSeparateZip(type: Zip, dependsOn: generateSourceProps) { |
| into archivesBaseName |
| destinationDir project.parent.ext.androidHostDist |
| baseName = project.group |
| version = rootProject.ext.buildNumber |
| } |
| project.parent.dist.dependsOn createSeparateZip |
| createSeparateZip.dependsOn release |
| |
| project.afterEvaluate { |
| // The archivesBaseName isn't available intially, so set it now |
| def createZipTask = project.tasks.getByName("createSeparateZip") |
| createZipTask.appendix = archivesBaseName |
| createZipTask.from versionDir() |
| } |
| } |