blob: 41b9d085a40a54e9ecc1abba841185b07c598467 [file] [log] [blame]
/*
* Copyright (C) 2020 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.LibraryGroups
import androidx.build.LibraryType
import androidx.build.Publish
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import static androidx.build.dependencies.DependenciesKt.*
plugins {
id("AndroidXPlugin")
id("kotlin")
}
dependencies {
implementation("androidx.annotation:annotation:1.1.0")
api(project(":room:room-compiler-processing"))
implementation(KOTLIN_STDLIB)
implementation(KOTLIN_KSP_API)
implementation(KOTLIN_STDLIB_JDK8) // KSP defines older version as dependency, force update.
implementation(KOTLIN_KSP)
implementation(GOOGLE_COMPILE_TESTING)
implementation(KOTLIN_COMPILE_TESTING_KSP)
// specify these because KSP do not specify them and we might get an older version from kotlin
// compile testing
// https://github.com/google/ksp/issues/187
implementation(KOTLIN_COMPILER_EMBEDDABLE)
implementation(KOTLIN_COMPILER_DAEMON_EMBEDDABLE)
implementation(KOTLIN_ANNOTATION_PROCESSING_EMBEDDABLE)
}
/**
* Create a properties file with versions that can be read from the test helper to setup test
* projects.
* see: b/178725084
*/
def testPropsOutDir = project.layout.buildDirectory.dir("test-config")
def writeTestPropsTask = tasks.register("prepareTestConfiguration", WriteProperties.class) {
description = "Generates a properties file with the current environment for compilation tests"
setOutputFile(testPropsOutDir.map {
it.file("androidx.room.compiler.processing.util.CompilationTestCapabilities.Config" +
".properties")
})
property("kotlinVersion", KOTLIN_VERSION)
property("kspVersion", KSP_VERSION)
}
java {
sourceSets {
main {
resources.srcDir(testPropsOutDir)
}
}
}
tasks.named("compileKotlin").configure {
dependsOn(writeTestPropsTask)
}
// enable opt in only for tests so that we don't create non experimental APIs by mistake
// in the source.
tasks.named("compileTestKotlin", KotlinCompile.class).configure {
it.kotlinOptions {
freeCompilerArgs += ["-Xopt-in=kotlin.RequiresOptIn",
"-Xopt-in=androidx.room.compiler.processing.ExperimentalProcessingApi"]
}
}
androidx {
name = "AndroidX Room XProcessor Testing"
type = LibraryType.ANNOTATION_PROCESSOR_UTILS
mavenGroup = LibraryGroups.ROOM
inceptionYear = "2020"
description = "Testing helpers for Room XProcessing APIs"
}