Annotate more java dependencies for licensing
Annotate more dependencies as runtime linked or toolchain.
Bug: 207445310
Test: m checkbuild
Change-Id: Ia5dc3321a1e476b16058eee94d6dc494fe1e933e
diff --git a/android/license_metadata.go b/android/license_metadata.go
index 4c71a8c..544295c 100644
--- a/android/license_metadata.go
+++ b/android/license_metadata.go
@@ -224,6 +224,9 @@
// LicenseAnnotationSharedDependency should be returned by LicenseAnnotations implementations
// of dependency tags when the usage of the dependency is dynamic, for example a shared library
// linkage for native modules or as a classpath library for java modules.
+ //
+ // Dependency tags that need to always return LicenseAnnotationSharedDependency
+ // can embed LicenseAnnotationSharedDependencyTag to implement LicenseAnnotations.
LicenseAnnotationSharedDependency LicenseAnnotation = "dynamic"
// LicenseAnnotationToolchain should be returned by LicenseAnnotations implementations of
@@ -234,6 +237,14 @@
LicenseAnnotationToolchain LicenseAnnotation = "toolchain"
)
+// LicenseAnnotationSharedDependencyTag can be embedded in a dependency tag to implement
+// LicenseAnnotations that always returns LicenseAnnotationSharedDependency.
+type LicenseAnnotationSharedDependencyTag struct{}
+
+func (LicenseAnnotationSharedDependencyTag) LicenseAnnotations() []LicenseAnnotation {
+ return []LicenseAnnotation{LicenseAnnotationSharedDependency}
+}
+
// LicenseAnnotationToolchainDependencyTag can be embedded in a dependency tag to implement
// LicenseAnnotations that always returns LicenseAnnotationToolchain.
type LicenseAnnotationToolchainDependencyTag struct{}
diff --git a/dexpreopt/config.go b/dexpreopt/config.go
index 1f99a96..153b025 100644
--- a/dexpreopt/config.go
+++ b/dexpreopt/config.go
@@ -408,6 +408,7 @@
type dex2oatDependencyTag struct {
blueprint.BaseDependencyTag
+ android.LicenseAnnotationToolchainDependencyTag
}
func (d dex2oatDependencyTag) ExcludeFromVisibilityEnforcement() {
diff --git a/java/hiddenapi.go b/java/hiddenapi.go
index 7c8be1e..3af5f1c 100644
--- a/java/hiddenapi.go
+++ b/java/hiddenapi.go
@@ -297,6 +297,7 @@
type hiddenApiAnnotationsDependencyTag struct {
blueprint.BaseDependencyTag
+ android.LicenseAnnotationSharedDependencyTag
}
// Tag used to mark dependencies on java_library instances that contains Java source files whose
diff --git a/java/java.go b/java/java.go
index 1714152..35b6a4f 100644
--- a/java/java.go
+++ b/java/java.go
@@ -274,6 +274,9 @@
// True if the dependency is relinked at runtime.
runtimeLinked bool
+
+ // True if the dependency is a toolchain, for example an annotation processor.
+ toolchain bool
}
// installDependencyTag is a dependency tag that is annotated to cause the installed files of the
@@ -287,6 +290,8 @@
func (d dependencyTag) LicenseAnnotations() []android.LicenseAnnotation {
if d.runtimeLinked {
return []android.LicenseAnnotation{android.LicenseAnnotationSharedDependency}
+ } else if d.toolchain {
+ return []android.LicenseAnnotation{android.LicenseAnnotationToolchain}
}
return nil
}
@@ -329,19 +334,19 @@
staticLibTag = dependencyTag{name: "staticlib"}
libTag = dependencyTag{name: "javalib", runtimeLinked: true}
java9LibTag = dependencyTag{name: "java9lib", runtimeLinked: true}
- pluginTag = dependencyTag{name: "plugin"}
- errorpronePluginTag = dependencyTag{name: "errorprone-plugin"}
- exportedPluginTag = dependencyTag{name: "exported-plugin"}
+ pluginTag = dependencyTag{name: "plugin", toolchain: true}
+ errorpronePluginTag = dependencyTag{name: "errorprone-plugin", toolchain: true}
+ exportedPluginTag = dependencyTag{name: "exported-plugin", toolchain: true}
bootClasspathTag = dependencyTag{name: "bootclasspath", runtimeLinked: true}
systemModulesTag = dependencyTag{name: "system modules", runtimeLinked: true}
frameworkResTag = dependencyTag{name: "framework-res"}
kotlinStdlibTag = dependencyTag{name: "kotlin-stdlib", runtimeLinked: true}
kotlinAnnotationsTag = dependencyTag{name: "kotlin-annotations", runtimeLinked: true}
- kotlinPluginTag = dependencyTag{name: "kotlin-plugin"}
+ kotlinPluginTag = dependencyTag{name: "kotlin-plugin", toolchain: true}
proguardRaiseTag = dependencyTag{name: "proguard-raise"}
certificateTag = dependencyTag{name: "certificate"}
instrumentationForTag = dependencyTag{name: "instrumentation_for"}
- extraLintCheckTag = dependencyTag{name: "extra-lint-check"}
+ extraLintCheckTag = dependencyTag{name: "extra-lint-check", toolchain: true}
jniLibTag = dependencyTag{name: "jnilib", runtimeLinked: true}
syspropPublicStubDepTag = dependencyTag{name: "sysprop public stub"}
jniInstallTag = installDependencyTag{name: "jni install"}