Anton Kulakov | 64ed152 | 2022-08-18 07:53:16 +0000 | [diff] [blame] | 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 | |
Tiem Song | ee0da74 | 2024-01-03 14:08:46 -0800 | [diff] [blame] | 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 | */ |
Anton Kulakov | 64ed152 | 2022-08-18 07:53:16 +0000 | [diff] [blame] | 24 | import androidx.build.LibraryType |
Anton Kulakov | f0e2a2c | 2023-07-27 11:17:27 +0000 | [diff] [blame] | 25 | import javax.inject.Inject |
Anton Kulakov | 64ed152 | 2022-08-18 07:53:16 +0000 | [diff] [blame] | 26 | |
| 27 | plugins { |
| 28 | id("AndroidXPlugin") |
| 29 | id("com.android.library") |
| 30 | id("org.jetbrains.kotlin.android") |
| 31 | } |
| 32 | |
Anton Kulakov | f0e2a2c | 2023-07-27 11:17:27 +0000 | [diff] [blame] | 33 | abstract class BundleTestSdkDexTask extends DefaultTask { |
| 34 | |
| 35 | @InputFiles |
| 36 | @PathSensitive(PathSensitivity.NAME_ONLY) |
| 37 | abstract ConfigurableFileCollection getTestSdkApkFolders() |
| 38 | |
| 39 | @OutputDirectory |
| 40 | abstract DirectoryProperty getOutputDir() |
| 41 | |
| 42 | @Inject |
| 43 | abstract FileSystemOperations getFileSystemOperations() |
| 44 | |
| 45 | @Inject |
| 46 | abstract ArchiveOperations getArchiveOperations() |
| 47 | |
| 48 | @TaskAction |
| 49 | def exec() { |
| 50 | for (File folder : testSdkApkFolders.files) { |
| 51 | for (File file : folder.listFiles()) { |
| 52 | String fileName = file.name |
| 53 | if (!fileName.endsWith(".apk")) { |
| 54 | continue |
| 55 | } |
| 56 | |
| 57 | int projectNameEnd = fileName.indexOf("-") |
| 58 | String projectName = projectNameEnd > 0 ? fileName.substring(0, projectNameEnd) : fileName |
| 59 | |
| 60 | fileSystemOperations.copy { |
| 61 | from(archiveOperations.zipTree(file)) |
| 62 | into(outputDir.dir("test-sdks/$projectName/")) |
| 63 | include('*.dex') |
| 64 | } |
| 65 | } |
| 66 | } |
| 67 | } |
| 68 | } |
| 69 | |
| 70 | def bundleTestSdkDexTaskProvider = tasks.register("bundleTestSdkDexTask", BundleTestSdkDexTask) { |
| 71 | description("Bundle DEX from the androidTestBundleDex configuration into assets folder") |
| 72 | |
| 73 | def configuration = configurations.getByName("androidTestBundleDex") |
| 74 | testSdkApkFolders.from(configuration.incoming.artifactView {}.files) |
| 75 | } |
| 76 | |
| 77 | androidComponents { |
| 78 | onVariants(selector().withBuildType("debug")) { |
| 79 | androidTest.sources.assets.addGeneratedSourceDirectory( |
| 80 | bundleTestSdkDexTaskProvider, |
| 81 | BundleTestSdkDexTask::getOutputDir |
| 82 | ) |
| 83 | } |
| 84 | } |
| 85 | |
| 86 | configurations { |
| 87 | androidTestBundleDex { |
| 88 | canBeConsumed = false |
| 89 | canBeResolved = true |
| 90 | attributes { |
| 91 | attribute( |
| 92 | LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE, |
| 93 | objects.named(LibraryElements, "testSdkApk") |
| 94 | ) |
| 95 | } |
| 96 | } |
| 97 | } |
| 98 | |
Anton Kulakov | 64ed152 | 2022-08-18 07:53:16 +0000 | [diff] [blame] | 99 | dependencies { |
| 100 | api(libs.kotlinStdlib) |
Anton Kulakov | ac243d7 | 2022-09-25 09:25:54 +0000 | [diff] [blame] | 101 | api(libs.kotlinCoroutinesCore) |
Anton Kulakov | f48ae8c | 2023-11-10 19:18:25 +0000 | [diff] [blame] | 102 | implementation("androidx.core:core-ktx:1.12.0") |
Anton Kulakov | ac243d7 | 2022-09-25 09:25:54 +0000 | [diff] [blame] | 103 | |
Anton Kulakov | ac243d7 | 2022-09-25 09:25:54 +0000 | [diff] [blame] | 104 | api project(path: ':privacysandbox:sdkruntime:sdkruntime-core') |
| 105 | |
Anton Kulakov | f48ae8c | 2023-11-10 19:18:25 +0000 | [diff] [blame] | 106 | implementation("androidx.core:core:1.12.0") |
| 107 | implementation("androidx.activity:activity:1.8.0") |
Anton Kulakov | ac243d7 | 2022-09-25 09:25:54 +0000 | [diff] [blame] | 108 | |
Anton Kulakov | 52eeb20 | 2022-11-22 12:17:46 +0000 | [diff] [blame] | 109 | testImplementation(libs.junit) |
| 110 | testImplementation(libs.truth) |
| 111 | testImplementation project(":room:room-compiler-processing-testing") |
| 112 | |
Anton Kulakov | ac243d7 | 2022-09-25 09:25:54 +0000 | [diff] [blame] | 113 | // TODO(b/249982004): cleanup dependencies |
| 114 | androidTestImplementation(libs.testCore) |
| 115 | androidTestImplementation(libs.testExtJunit) |
| 116 | androidTestImplementation(libs.testRunner) |
| 117 | androidTestImplementation(libs.testRules) |
| 118 | androidTestImplementation(libs.truth) |
| 119 | androidTestImplementation(libs.junit) |
Anton Kulakov | ed50ebd | 2023-05-04 13:25:09 +0000 | [diff] [blame] | 120 | androidTestImplementation(project(':internal-testutils-runtime')) |
Anton Kulakov | c06ac2b | 2022-10-22 08:46:32 +0000 | [diff] [blame] | 121 | androidTestImplementation(project(":internal-testutils-truth")) // for assertThrows |
Anton Kulakov | ac243d7 | 2022-09-25 09:25:54 +0000 | [diff] [blame] | 122 | |
| 123 | androidTestImplementation(libs.mockitoCore, excludes.bytebuddy) // DexMaker has it"s own MockMaker |
| 124 | androidTestImplementation(libs.dexmakerMockitoInline, excludes.bytebuddy) // DexMaker has it"s own MockMaker |
Anton Kulakov | f0e2a2c | 2023-07-27 11:17:27 +0000 | [diff] [blame] | 125 | |
| 126 | androidTestBundleDex(project(":privacysandbox:sdkruntime:test-sdks:current")) |
Anton Kulakov | c75cf93 | 2023-08-07 15:27:12 +0000 | [diff] [blame] | 127 | androidTestBundleDex(project(":privacysandbox:sdkruntime:test-sdks:v1")) |
| 128 | androidTestBundleDex(project(":privacysandbox:sdkruntime:test-sdks:v2")) |
| 129 | // V3 was released as V4 (original release postponed) |
| 130 | androidTestBundleDex(project(":privacysandbox:sdkruntime:test-sdks:v4")) |
Anton Kulakov | 096fdc3 | 2024-02-27 17:30:30 +0000 | [diff] [blame] | 131 | androidTestBundleDex(project(":privacysandbox:sdkruntime:test-sdks:v5")) |
Anton Kulakov | 64ed152 | 2022-08-18 07:53:16 +0000 | [diff] [blame] | 132 | } |
| 133 | |
| 134 | android { |
Anton Kulakov | c06ac2b | 2022-10-22 08:46:32 +0000 | [diff] [blame] | 135 | sourceSets { |
| 136 | androidTest { |
| 137 | assets { |
| 138 | srcDirs += "src/androidTest/assets" |
| 139 | } |
| 140 | } |
| 141 | } |
Anton Kulakov | de32ede | 2023-03-14 12:51:13 +0000 | [diff] [blame] | 142 | |
Anton Kulakov | 64ed152 | 2022-08-18 07:53:16 +0000 | [diff] [blame] | 143 | namespace "androidx.privacysandbox.sdkruntime.client" |
Omar Ismail | f780db8 | 2024-04-11 16:00:49 -0400 | [diff] [blame] | 144 | compileSdk = 34 |
| 145 | compileSdkExtension = 10 |
Anton Kulakov | 64ed152 | 2022-08-18 07:53:16 +0000 | [diff] [blame] | 146 | } |
| 147 | |
| 148 | androidx { |
Anton Kulakov | f8cec2a | 2023-09-20 09:54:11 +0000 | [diff] [blame] | 149 | name = "SdkRuntime Client" |
Anton Kulakov | 64ed152 | 2022-08-18 07:53:16 +0000 | [diff] [blame] | 150 | type = LibraryType.PUBLISHED_LIBRARY |
Anton Kulakov | 64ed152 | 2022-08-18 07:53:16 +0000 | [diff] [blame] | 151 | inceptionYear = "2022" |
| 152 | description = "Provides components for SdkRuntime aware Applications" |
Jinseong Jeon | 999075e | 2023-08-22 00:40:11 -0700 | [diff] [blame] | 153 | metalavaK2UastEnabled = true |
Aurimas Liutikas | 5c5419a | 2024-05-29 15:26:58 -0700 | [diff] [blame] | 154 | legacyDisableKotlinStrictApiMode = true |
Anton Kulakov | 64ed152 | 2022-08-18 07:53:16 +0000 | [diff] [blame] | 155 | } |