1/*
2 * Copyright (C) 2022 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17/**
18 * This file was created using the `create_project.py` script located in the
19 * `<AndroidX root>/development/project-creator` directory.
20 *
21 * Please use that script when creating a new project, rather than copying an existing project and
22 * modifying its settings.
23 */
24import androidx.build.SoftwareType
25import androidx.build.SdkHelperKt
26import androidx.build.AndroidXConfig
27
28plugins {
29    id("AndroidXPlugin")
30    id("AndroidXRepackagePlugin")
31    id("kotlin")
32    id("com.google.protobuf")
33}
34
35def buildToolsVersion = AndroidXConfig.getDefaultAndroidConfig(project).getBuildToolsVersion()
36def compileSdk = AndroidXConfig.getDefaultAndroidConfig(project).getCompileSdk()
37
38repackage {
39    // Must match what is in privacysandbox/tools/tools-core-external-protobuf/build.gradle
40    addRelocation {
41        sourcePackage = "com.google.protobuf"
42        targetPackage =  "androidx.privacysandbox.tools.core.proto"
43    }
44}
45
46dependencies {
47    api(libs.kotlinStdlib)
48    api("com.squareup:kotlinpoet:2.0.0")
49    api(project(":privacysandbox:tools:tools-core-external-protobuf"))
50    // Must be compileOnly to not bring in protobufLite in runtime
51    // Repackaged protobufLite brought in by
52    // project(":privacysandbox:tools:tools-core-external-protobuf") and used at runtime
53    compileOnly(libs.protobufLite)
54    implementation(libs.guava)
55    implementation(project(":privacysandbox:tools:tools"))
56
57    testImplementation(libs.junit)
58    testImplementation(libs.truth)
59    testImplementation(project(":internal-testutils-truth"))
60    testImplementation(project(":privacysandbox:tools:tools-testing"))
61    testImplementation(project(":room:room-compiler-processing-testing"))
62    // Include android jar for compilation of generated sources.
63    testImplementation(SdkHelperKt.getSdkDependency(project))
64}
65
66// Get AIDL compiler path and framework.aidl path and pass to tests for code generation.
67def aidlCompilerPath = "${SdkHelperKt.getSdkPath(project)}/build-tools/$buildToolsVersion/aidl"
68def frameworkAidlPath = "${SdkHelperKt.getSdkPath(project)}/platforms/android-$compileSdk/framework.aidl"
69tasks.withType(Test).configureEach { test ->
70    test.inputs.files(aidlCompilerPath)
71            .withPropertyName("aidl_compiler_path")
72            .withPathSensitivity(PathSensitivity.NAME_ONLY)
73    test.inputs.files(frameworkAidlPath)
74            .withPropertyName("framework_aidl_path")
75            .withPathSensitivity(PathSensitivity.NAME_ONLY)
76    test.inputs.dir("src/test/test-data").withPathSensitivity(PathSensitivity.RELATIVE)
77    test.doFirst {
78        systemProperty "aidl_compiler_path", aidlCompilerPath
79        systemProperty "framework_aidl_path", frameworkAidlPath
80    }
81}
82
83androidx {
84    name = "androidx.privacysandbox.tools:tools-core"
85    type = SoftwareType.ANNOTATION_PROCESSOR_UTILS
86    inceptionYear = "2022"
87    description = "Core utilities for Privacy Sandbox Tools."
88}
89