blob: 755ede5d87b12cffbf9076eed57fc0bcb66e7cc7 [file] [log] [blame]
/*
* Copyright 2019 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 androidx.build.BuildServerConfigurationKt
import androidx.build.CompilationTarget
import androidx.build.LibraryGroups
import androidx.build.LibraryVersions
import androidx.build.SupportConfig
import androidx.build.Publish
import static androidx.build.dependencies.DependenciesKt.*
plugins {
id("AndroidXPlugin")
id("kotlin")
id("java-gradle-plugin")
}
apply from: "kotlin-dsl-dependency.gradle.kts"
ext.generatedResources = "$buildDir/generated/resources"
ext.prebuiltsRoot = "${project.projectDir.getParentFile()}/../../../prebuilts"
sourceSets {
test.java.srcDirs += 'src/main/kotlin'
test.resources.srcDirs += generatedResources
}
dependencies {
implementation gradleApi()
implementation(ANDROID_GRADLE_PLUGIN)
implementation(KOTLIN_STDLIB)
testImplementation gradleTestKit()
testImplementation(ANDROIDX_TEST_RUNNER)
testImplementation(JUNIT)
testImplementation(KOTLIN_TEST_COMMON)
}
task generateSdkResource() {
inputs.property("prebuiltsRoot", prebuiltsRoot)
inputs.property("compileSdkVersion", SupportConfig.TARGET_SDK_VERSION)
inputs.property("buildToolsVersion", SupportConfig.BUILD_TOOLS_VERSION)
inputs.property("minSdkVersion", SupportConfig.DEFAULT_MIN_SDK_VERSION)
outputs.dir(generatedResources)
doLast {
// Properties.write will have a timestamp, that invalidates the task,
// so we don't use it and write a file manually
new File(generatedResources, "sdk.prop").withWriter('UTF-8') { writer ->
writer.write("prebuiltsRepo=$prebuiltsRoot\n")
writer.write("compileSdkVersion=$SupportConfig.TARGET_SDK_VERSION\n")
writer.write("buildToolsVersion=$SupportConfig.BUILD_TOOLS_VERSION\n")
writer.write("minSdkVersion=$SupportConfig.DEFAULT_MIN_SDK_VERSION\n")
}
}
}
tasks["compileTestJava"].dependsOn generateSdkResource
task buildOnServer(type: Copy) {
from {
def f = project.file("src/main/resources/scripts/lockClocks.sh")
if (!f.exists()) {
throw new GradleException(f.toString() + " does not exist")
}
return f
}
destinationDir BuildServerConfigurationKt.getDistributionDirectory(rootProject)
}
gradlePlugin {
plugins {
benchmark {
id = "androidx.benchmark"
implementationClass = "androidx.benchmark.gradle.BenchmarkPlugin"
}
}
}
androidx {
name = "Android Benchmark Gradle Plugin"
publish = Publish.SNAPSHOT_AND_RELEASE
toolingProject = true
mavenVersion = LibraryVersions.BENCHMARK
mavenGroup = LibraryGroups.BENCHMARK
inceptionYear = "2019"
description = "Android Benchmark Gradle Plugin"
compilationTarget = CompilationTarget.HOST
}