blob: c462021f6ddf6b86f5061aa63a8bced1893cffa4 [file] [log] [blame]
apply plugin: 'clone-artifacts'
buildscript {
apply from: "$rootDir/buildSrc/base/version.gradle"
repositories {
maven { url "$rootDir/../prebuilts/tools/common/m2/repository" }
}
dependencies {
classpath libs.kotlin_gradle_plugin
classpath libs.kotlin_reflect
classpath libs.guava
classpath "gradle.plugin.org.jetbrains.gradle.plugin.idea-ext:gradle-idea-ext:0.8.1"
}
}
apply from: "$rootDir/buildSrc/base/idea.gradle"
// artifact cloning destinations
cloneArtifacts {
repository = "$rootDir/../prebuilts/tools/common/m2/repository"
}
repositories {
maven { url "$rootDir/../prebuilts/tools/common/m2/repository" }
}
if (System.getenv("USE_EXTERNAL_REPO") != null) {
allprojects {
repositories {
maven { url = uri(rootProject.cloneArtifacts.repository) }
maven { url 'https://repo.gradle.org/gradle/libs-snapshots-local' }
maven { url 'https://repo.gradle.org/gradle/libs-releases' }
}
}
}
// ext.androidHostOut is shared by all tools/{base,build} gradle projects
ext.androidHostOut = file(System.getenv('BUILD_DIR') ?: "$rootDir/../out")
ext.androidHostDist = new File(ext.androidHostOut, "dist")
// rootProject.buildDir is specific to this gradle build.
buildDir = new File(ext.androidHostOut, "build/root")
ext.localRepo = project.hasProperty('localRepo') ? localRepo : "$ext.androidHostOut/repo"
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")
}
// delay evaluation of this project before all subprojects have been evaluated.
subprojects.each { subproject -> evaluationDependsOn(subproject.path) }
def testTasks = subprojects.collect { it.tasks.withType(Test) }.flatten()
// Print failed tests to the console early.
testTasks.each { task ->
task.testLogging {
events "failed", "skipped"
}
}
task aggregateResults(type: Copy) {
from { testTasks*.binResultsDir*.parentFile*.parentFile }
into { file("$buildDir/results") }
}
testTasks.each { task ->
aggregateResults.mustRunAfter task
}
task prepareRepo(type: Copy) {
from { rootProject.cloneArtifacts.repository }
into { "$rootProject.ext.androidHostOut/repo" }
}
task("copyGradleProperty").doLast {
def gradleProperties = file("${System.getenv("HOME")}/.gradle/gradle.properties")
if (gradleProperties.exists()) {
project.copy {
from { gradleProperties }
into { gradle.gradleUserHomeDir }
}
}
}
def publishLocalTask = tasks.create(name: 'publishLocal')
// publishLocalPluginTask that publishes just the plugin dependencies, not any of the runtime
// artifacts like data binding
def publishLocalPluginTask = tasks.create(name: 'publishAndroidGradleLocal')
publishLocalPluginTask.description = """Publishes artifacts that are direct dependencies of the
plugin without the runtime artifacts (e.g. data binding runtime lib)."""
publishLocalTask.dependsOn publishLocalPluginTask
subprojects { project ->
project.plugins.withId('maven-publish') {
project.plugins.withId('signing') {
rootProject.publishAndroidGradleLocal.dependsOn project.tasks.findByName('publish')
}
}
}
subprojects { project ->
if (project.hasProperty("runtimeArtifactTasks")) {
project.getProperty("runtimeArtifactTasks").each { runtimeArtifactTask ->
rootProject.publishLocal.dependsOn runtimeArtifactTask
runtimeArtifactTask.dependsOn publishLocalPluginTask
def disableRuntimeArtifact = rootProject.hasProperty("disableRuntimeArtifacts") ||
project.hasProperty("disableRuntimeArtifacts")
runtimeArtifactTask.enabled = !disableRuntimeArtifact
}
}
}
// basic task for custom distribution of project should the build server.
task('dist').doLast {}
task('clean').doLast {
delete 'build'
new File("$localRepo/com/android/tools").eachFile {
if (it.name != "external") {
delete it
}
}
}
tasks.register('zipPlugin', Zip) {
it.from(localRepo)
it.destinationDirectory = androidHostDist
it.archiveFileName = "repo.zip"
it.dependsOn(publishLocalPluginTask) // TODO include data binding runtime build
}
apply plugin: 'presubmit-runner'