Add KOTLIN,MISC,UNKNOWN,GRADLE TaskCategoryLabel
Test: BuildAnalyzerTest.kt
Bug: 237389446
Change-Id: I03d912f3931f42e254caa04b474a249132df06bd
diff --git a/build-system/gradle-core/src/test/java/com/android/build/gradle/tasks/BuildAnalyzerTest.kt b/build-system/gradle-core/src/test/java/com/android/build/gradle/tasks/BuildAnalyzerTest.kt
index 13d3def..1ba8a8d 100644
--- a/build-system/gradle-core/src/test/java/com/android/build/gradle/tasks/BuildAnalyzerTest.kt
+++ b/build-system/gradle-core/src/test/java/com/android/build/gradle/tasks/BuildAnalyzerTest.kt
@@ -27,6 +27,7 @@
import com.android.build.gradle.internal.tasks.NonIncrementalTask
import com.android.build.gradle.internal.tasks.TestPreBuildTask
import com.android.build.gradle.tasks.sync.AppIdListTask
+import com.android.ide.common.attribution.TaskCategoryLabel
import org.gradle.api.Task
import com.google.common.reflect.ClassPath
import com.google.common.reflect.TypeToken
@@ -48,6 +49,19 @@
assertThat(actualTasksWithoutAnnotations).containsExactlyElementsIn(expectedTasksWithoutAnnotations)
}
+ @Test
+ fun `build analyzer annotated tasks does not have unallowed labels`() {
+ val allTasks = getAllTasks()
+ val unallowedLabels = listOf(TaskCategoryLabel.GRADLE,
+ TaskCategoryLabel.MISC, TaskCategoryLabel.UNKNOWN)
+ val tasksWithUnallowedLabels = allTasks.filter {
+ it.isAnnotationPresent(BuildAnalyzer::class.java)
+ }.filter { clazz ->
+ clazz.getAnnotation(BuildAnalyzer::class.java).taskCategoryLabels.any{ it in unallowedLabels }
+ }
+ assertThat(tasksWithUnallowedLabels).isEmpty()
+ }
+
// Allow-list of tasks that are defined to not have annotations.
// Usually due to it being a base task, and hence is implemented by other tasks.
// Another reason is that it does not fall into any TaskCategoryLabel,
diff --git a/sdk-common/src/main/java/com/android/ide/common/attribution/TaskCategoryLabel.kt b/sdk-common/src/main/java/com/android/ide/common/attribution/TaskCategoryLabel.kt
index e68c3f4..451b812 100644
--- a/sdk-common/src/main/java/com/android/ide/common/attribution/TaskCategoryLabel.kt
+++ b/sdk-common/src/main/java/com/android/ide/common/attribution/TaskCategoryLabel.kt
@@ -38,6 +38,7 @@
JAVA_RESOURCES,
// Tasks that involve Java docs
JAVA_DOC,
+ KOTLIN,
// Tasks that invovle AIDL
AIDL,
// Tasks involving Renderscript framework
@@ -78,5 +79,12 @@
ZIPPING,
LINKING,
MERGING,
- FUSING
+ FUSING,
+ // org.gradle tasks - No tasks in AGP should have this annotation label
+ GRADLE,
+ // Various tasks that do not fall into any other category
+ // No tasks in AGP should have this annotation label
+ MISC,
+ // Other TP plugins - No task in AGP should have this annotation label
+ UNKNOWN
}