blob: 6ea7548bee69db65d01bb3ffc6dcb874c16afdab [file] [log] [blame]
/*
* Copyright (C) 2022 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.
*/
/**
* This file was created using the `create_project.py` script located in the
* `<AndroidX root>/development/project-creator` directory.
*
* Please use that script when creating a new project, rather than copying an existing project and
* modifying its settings.
*/
import androidx.build.KotlinTarget
import androidx.build.LibraryType
import androidx.build.SdkHelperKt
import androidx.build.AndroidXConfig
plugins {
id("AndroidXPlugin")
id("kotlin")
id("com.gradleup.shadow")
}
androidx.configureAarAsJarForConfiguration("testImplementation")
def buildToolsVersion = AndroidXConfig.getDefaultAndroidConfig(project).getBuildToolsVersion()
def compileSdk = AndroidXConfig.getDefaultAndroidConfig(project).getCompileSdk()
configurations {
// Configuration of shadowed / jarjared dependencies
shadowed
// Shadowed dependencies are compile only
compileOnly.extendsFrom(shadowed)
// Include shadowed dependencies for test compilation
testCompile.extendsFrom(shadowed)
// Replace the standard jar with the one built by 'shadowJar' in both api and runtime variants
apiElements.outgoing.artifacts.clear()
apiElements.outgoing.artifact(shadowJar) {
builtBy shadowJar
}
runtimeElements.outgoing.artifacts.clear()
runtimeElements.outgoing.artifact(shadowJar) {
builtBy shadowJar
}
}
shadowJar {
archiveClassifier = ""
configurations = [project.configurations.shadowed]
relocate("kotlin.metadata", "androidx.privacysandbox.tools.kotlin.metadata")
mergeServiceFiles() // kotlin-metadata-jvm has a service descriptor that needs transformation
// Exclude Kotlin metadata files from kotlin-metadata-jvm
exclude 'META-INF/kotlin-metadata-jvm.kotlin_module'
exclude 'META-INF/kotlin-metadata.kotlin_module'
exclude 'META-INF/metadata.jvm.kotlin_module'
exclude 'META-INF/metadata.kotlin_module'
}
jar {
archiveClassifier = "before-jarjar"
}
dependencies {
api(libs.kotlinStdlib)
implementation(libs.asm)
implementation(libs.asmCommons)
shadowed(libs.kotlinMetadataJvm) {
exclude group: "org.jetbrains.kotlin", module: "kotlin-stdlib"
}
implementation(libs.kotlinPoet)
implementation(project(":privacysandbox:tools:tools"))
implementation(project(":privacysandbox:tools:tools-core"))
testImplementation(project(":internal-testutils-truth"))
testImplementation(project(":privacysandbox:tools:tools-apipackager"))
testImplementation(project(":privacysandbox:tools:tools-testing"))
testImplementation(project(":room:room-compiler-processing-testing"))
testImplementationAarAsJar(project(":privacysandbox:activity:activity-core"))
testImplementationAarAsJar(project(":privacysandbox:activity:activity-client"))
testImplementationAarAsJar(project(":privacysandbox:ui:ui-core"))
testImplementationAarAsJar(project(":privacysandbox:ui:ui-client"))
testImplementationAarAsJar(project(":privacysandbox:sdkruntime:sdkruntime-client"))
testImplementationAarAsJar(project(":privacysandbox:sdkruntime:sdkruntime-core"))
testImplementation(libs.kotlinCoroutinesCore)
testImplementation(libs.kotlinMetadataJvm)
testImplementation(libs.junit)
testImplementation(libs.truth)
// Include android jar for compilation of generated sources.
testImplementation(SdkHelperKt.getSdkDependency(project))
}
// Get AIDL compiler path and framework.aidl path and pass to tests for code generation.
def aidlCompilerPath = "${SdkHelperKt.getSdkPath(project)}/build-tools/$buildToolsVersion/aidl"
def frameworkAidlPath = "${SdkHelperKt.getSdkPath(project)}/platforms/android-$compileSdk/framework.aidl"
def testGeneratedSourcesPath = "${project.buildDir}/testGeneratedSources"
tasks.withType(Test).configureEach { test ->
test.inputs.files(aidlCompilerPath)
.withPropertyName("aidl_compiler_path")
.withPathSensitivity(PathSensitivity.NAME_ONLY)
test.inputs.files(frameworkAidlPath)
.withPropertyName("framework_aidl_path")
.withPathSensitivity(PathSensitivity.NAME_ONLY)
test.inputs.dir("src/test/test-data").withPathSensitivity(PathSensitivity.RELATIVE)
test.doFirst {
systemProperty "aidl_compiler_path", aidlCompilerPath
systemProperty "framework_aidl_path", frameworkAidlPath
systemProperty "test_output_dir", testGeneratedSourcesPath
}
}
androidx {
name = "androidx.privacysandbox.tools:tools-apigenerator"
type = LibraryType.OTHER_CODE_PROCESSOR
inceptionYear = "2022"
description = "Generate sources for communication with SDKs in the Privacy Sandbox."
kotlinTarget = KotlinTarget.KOTLIN_1_9
}