[go: nahoru, domu]

blob: 6d6a8e6741355c91728571f716ec1681e8641318 [file] [log] [blame]
Sergey Vasilinets0e965b82020-02-04 11:43:47 +00001/*
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
17package androidx.inspection.gradle
18
Sergey Vasilinetse6b0d3c2022-03-18 18:49:49 +000019import com.android.build.api.variant.Variant
Sergey Vasilinets0e965b82020-02-04 11:43:47 +000020import java.io.File
21import java.util.Locale
Sergey Vasilinetse6b0d3c2022-03-18 18:49:49 +000022import org.gradle.api.Project
Sergey Vasilinets0e965b82020-02-04 11:43:47 +000023
Sergey Vasilinetse6b0d3c2022-03-18 18:49:49 +000024internal fun Variant.taskName(baseName: String) =
25 "$baseName${name.replaceFirstChar(Char::titlecase)}"
26
27internal 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 Liutikasd882813f72021-06-21 09:51:24 -070037@Suppress("DEPRECATION") // BaseVariant
38internal fun com.android.build.gradle.api.BaseVariant.taskName(baseName: String) =
39 "$baseName${name.capitalize(Locale.ENGLISH)}"
Sergey Vasilinets0e965b82020-02-04 11:43:47 +000040
Aurimas Liutikasd882813f72021-06-21 09:51:24 -070041@Suppress("DEPRECATION") // BaseVariant
42internal fun Project.taskWorkingDir(
43 variant: com.android.build.gradle.api.BaseVariant,
44 baseName: String
45): File {
Sergey Vasilinets0e965b82020-02-04 11:43:47 +000046 val inspectionDir = File(project.buildDir, "androidx_inspection")
47 return File(File(inspectionDir, baseName), variant.dirName)
Aurimas Liutikas4d534002023-07-06 15:51:33 -070048}