summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Viverette <alanv@google.com>2022-12-15 16:08:17 -0500
committerAlan Viverette <alanv@google.com>2022-12-15 21:24:47 +0000
commit908cac2d97f0270a89e5b2965bd43a952927b1b4 (patch)
tree4351654ea044e82b21bf16993f1e83f349493958
parente8461275281cc257e5120e1549bb9de12e36d764 (diff)
downloadsdk-908cac2d97f0270a89e5b2965bd43a952927b1b4.tar.gz
Fail on invalid include/exclude arguments
Fixes: 261992166 Test: ./update_prebuilts.py --exclude blablabla -x <build-id> Merged-In: I0756192f0696c15c03e4d84a541a08ce28ee97fa Change-Id: I0756192f0696c15c03e4d84a541a08ce28ee97fa
-rwxr-xr-xupdate_prebuilts/update_prebuilts.py33
1 files changed, 33 insertions, 0 deletions
diff --git a/update_prebuilts/update_prebuilts.py b/update_prebuilts/update_prebuilts.py
index e444068c1..88cf11ec5 100755
--- a/update_prebuilts/update_prebuilts.py
+++ b/update_prebuilts/update_prebuilts.py
@@ -441,6 +441,27 @@ def detect_artifacts(maven_repo_dirs):
return maven_lib_info
+def find_invalid_spec(artifact_list):
+ """Verifies whether all the artifacts in the list correspond to an entry in maven_to_make.
+
+ Args:
+ artifact_list: list of group IDs or artifact coordinates
+ Returns:
+ The first invalid artifact specification in the list, or None if all specs are valid.
+ """
+ if artifact_list is None:
+ return None
+ for prefix in artifact_list:
+ has_prefix = False
+ for artifact_id in maven_to_make:
+ if artifact_id.startswith(prefix):
+ has_prefix = True
+ break
+ if not has_prefix:
+ return prefix
+ return None
+
+
def transform_maven_repos(maven_repo_dirs, transformed_dir, extract_res=True,
include_static_deps=True, include=None, exclude=None, prepend=None):
"""Transforms a standard Maven repository to be compatible with the Android build system.
@@ -1012,6 +1033,18 @@ def main():
'You may also need to run \'m pom2bp\' if it hasn\'t been built already.')
sys.exit(1)
+ # Validate include/exclude arguments.
+ if args.exclude:
+ invalid_spec = find_invalid_spec(args.exclude)
+ if invalid_spec:
+ parser.error('Unknown artifact specification in exclude: ' + invalid_spec)
+ sys.exit(1)
+ if args.include:
+ invalid_spec = find_invalid_spec(args.include)
+ if invalid_spec:
+ parser.error('Unknown artifact specification in include: ' + invalid_spec)
+ sys.exit(1)
+
# Validate the git status.
if has_uncommitted_changes():
if args.commit_first: