blob: 529af80e2267295a78e368e91fe9312d13a56832 [file] [log] [blame]
load("//tools/base/bazel:coverage.bzl", "coverage_java_test")
load("//tools/base/bazel:maven.bzl", "maven_repository")
load("//tools/base/bazel:utils.bzl", "merged_zip")
# Gmaven artifacts that are not used by the gradle builds
maven_repository(
name = "other_gmaven_artifacts",
#keep sorted
artifacts = [
"//prebuilts/tools/common/lint-psi/intellij-core",
"//prebuilts/tools/common/lint-psi/kotlin-compiler",
"//prebuilts/tools/common/lint-psi/uast",
"//tools/analytics-library/inspector",
"//tools/analytics-library/publisher",
"//tools/analytics-library/testing:tools.analytics-testing",
"//tools/base/apkparser:tools.binary-resources",
"//tools/base/apkparser/analyzer:tools.analyzer.maven",
"//tools/base/chunkio:tools.chunkio",
"//tools/base/draw9patch:tools.draw9patch",
"//tools/base/emulator/proto",
"//tools/base/fakeadbserver:tools.fakeadbserver",
"//tools/base/lint:tools.lint-api",
"//tools/base/lint:tools.lint-checks",
"//tools/base/lint:tools.lint-gradle",
"//tools/base/lint/cli",
"//tools/base/lint/libs/lint-tests",
"//tools/base/ninepatch:tools.ninepatch",
"//tools/base/pixelprobe:tools.pixelprobe",
"//tools/base/testutils:tools.testutils",
"//tools/base/utp/android-test-plugin-host-device-info-proto",
"//tools/data-binding:tools.compiler",
],
include_transitive_deps = False,
)
genrule(
name = "maven_artifact_list",
srcs = [":gmaven"],
outs = ["maven_artifacts.txt"],
cmd = " ".join([
"zip -sf $(SRCS)",
# filter out everything but the pom files,
# leaving $GROUP/$ARTIFACT/$VERSION/$FILENAME.
"| grep .*pom$$",
# remove the last two path segments, $VERSION/$FILENAME.
"| sed -E 's/(.*)\\/[^/]+\\/[^/]+$$/\\1/'",
# replace the last '/' with a ':' to format as $GROUP:$ARTIFACT
"| sed -E 's/(.*)\\/([A-Za-z_-]+)/\\1:\\2/'",
"| sort",
"> $@",
]),
)
sh_binary(
name = "update-allowlist",
srcs = ["update_allowlist.sh"],
args = ["$(execpath //tools/base/gmaven:maven_artifact_list)"],
data = ["//tools/base/gmaven:maven_artifact_list"],
)
sh_test(
name = "allowed-artifacts-test",
srcs = ["test_allowlist.sh"],
args = [
"$(location :artifacts_allowlist.txt)",
"$(location :maven_artifact_list)",
],
data = [
":artifacts_allowlist.txt",
":maven_artifact_list",
],
tags = [
"no_test_mac",
"no_test_windows",
],
)
# A subset of the artifacts that can be built without our vendor
# repositories.
filegroup(
name = "zips_without_vendor",
srcs = [
":other_gmaven_artifacts.zip",
"//tools/base:agp_artifacts.zip",
"//tools/base/build-system:android_gradle_plugin.zip",
"//tools/base/utp:utp.zip",
],
)
# The Gmaven repository as built with the hybrid gradle/bazel build.
merged_zip(
name = "gmaven",
srcs = [
":zips_without_vendor",
"//tools/data-binding:data_binding_runtime.zip",
],
)
# A subset of the maven repository that can be built without
# any of the vendor repos. Note that at this moment the SDK we use
# to build some artifacts is in a vendor repo so they are excluded.
merged_zip(
name = "gmaven_without_vendor",
srcs = [
":zips_without_vendor",
],
)
java_library(
name = "java_tests",
srcs = ["src/test/java/com/android/tools/test/GmavenZipTest.java"],
resources = [
"src/test/resources/com/android/tools/test/gmaven-aars.txt",
"src/test/resources/com/android/tools/test/gmaven-jars.txt",
"src/test/resources/com/android/tools/test/gmaven-poms.txt",
],
deps = [
"//tools/base/annotations",
"//tools/base/common:tools.common",
"//tools/base/testutils:tools.testutils",
"@maven//:com.google.guava.guava",
"@maven//:com.google.truth.truth",
"@maven//:junit.junit",
],
)
coverage_java_test(
name = "tests",
data = [
":gmaven.zip",
],
jvm_flags = [
"-Dtest.suite.jar=tests.jar",
"-Dfile.encoding=UTF-8",
"-Dsun.jnu.encoding=UTF-8",
"-Dmaven.repo.local=/tmp/localMavenRepo", # For gradle publishing, writing to ~/.m2
],
tags = [
"block-network",
"no_test_windows", # b/73306170
],
test_class = "com.android.testutils.JarTestSuite",
runtime_deps = [
":java_tests",
],
)