Sergey Vasilinets | 0e965b8 | 2020-02-04 11:43:47 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2020 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 | package androidx.inspection.gradle |
| 18 | |
Sergey Vasilinets | e6b0d3c | 2022-03-18 18:49:49 +0000 | [diff] [blame] | 19 | import com.android.build.api.variant.Variant |
Sergey Vasilinets | 0e965b8 | 2020-02-04 11:43:47 +0000 | [diff] [blame] | 20 | import java.io.File |
| 21 | import java.util.Locale |
Sergey Vasilinets | e6b0d3c | 2022-03-18 18:49:49 +0000 | [diff] [blame] | 22 | import org.gradle.api.Project |
Sergey Vasilinets | 0e965b8 | 2020-02-04 11:43:47 +0000 | [diff] [blame] | 23 | |
Sergey Vasilinets | e6b0d3c | 2022-03-18 18:49:49 +0000 | [diff] [blame] | 24 | internal fun Variant.taskName(baseName: String) = |
| 25 | "$baseName${name.replaceFirstChar(Char::titlecase)}" |
| 26 | |
| 27 | internal fun Project.taskWorkingDir( |
| 28 | variant: Variant, |
| 29 | baseName: String |
| 30 | ): File { |
| 31 | val inspectionDir = File(project.buildDir, "androidx_inspection") |
| 32 | return File(File(inspectionDir, baseName), variant.name) |
| 33 | } |
| 34 | |
| 35 | // Functions below will be removed once registerGenerateProguardDetectionFileTask is migrated |
| 36 | // that needs newly added function "addGeneratedSourceDirectory" |
Aurimas Liutikas | d882813f7 | 2021-06-21 09:51:24 -0700 | [diff] [blame] | 37 | @Suppress("DEPRECATION") // BaseVariant |
| 38 | internal fun com.android.build.gradle.api.BaseVariant.taskName(baseName: String) = |
| 39 | "$baseName${name.capitalize(Locale.ENGLISH)}" |
Sergey Vasilinets | 0e965b8 | 2020-02-04 11:43:47 +0000 | [diff] [blame] | 40 | |
Aurimas Liutikas | d882813f7 | 2021-06-21 09:51:24 -0700 | [diff] [blame] | 41 | @Suppress("DEPRECATION") // BaseVariant |
| 42 | internal fun Project.taskWorkingDir( |
| 43 | variant: com.android.build.gradle.api.BaseVariant, |
| 44 | baseName: String |
| 45 | ): File { |
Sergey Vasilinets | 0e965b8 | 2020-02-04 11:43:47 +0000 | [diff] [blame] | 46 | val inspectionDir = File(project.buildDir, "androidx_inspection") |
| 47 | return File(File(inspectionDir, baseName), variant.dirName) |
Aurimas Liutikas | 4d53400 | 2023-07-06 15:51:33 -0700 | [diff] [blame] | 48 | } |