From 040d357a18f4f010047666fdac0a2c5f11f078ff Mon Sep 17 00:00:00 2001 From: Peter Laird Date: Tue, 20 Aug 2024 11:33:25 -0600 Subject: [PATCH] suppress maven_install excludes in some cases (#184) --- common/maveninstallinfo.py | 9 +++++++-- misc/extdeps_pomgen.py | 18 +++++++++++++----- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/common/maveninstallinfo.py b/common/maveninstallinfo.py index e05cdc4..9d78466 100644 --- a/common/maveninstallinfo.py +++ b/common/maveninstallinfo.py @@ -10,15 +10,20 @@ class MavenInstallInfo: - def __init__(self, maven_install_paths): + def __init__(self, maven_install_paths, allow_excludes = True): self.maven_install_paths = maven_install_paths + self.allow_excludes = allow_excludes def get_maven_install_names_and_paths(self, repository_root): """ Returns a list of tuples (mvn install name, mvn install path) """ # paths that start with '-' are excluded if found in glob expansions - excluded_paths = [p[1:].strip() for p in self.maven_install_paths if self._is_excluded_path(p)] + # in some use cases, we don't want to exclude them, so it is conditional + excluded_paths = [] + if self.allow_excludes: + excluded_paths = [p[1:].strip() for p in self.maven_install_paths if self._is_excluded_path(p)] + names_and_paths = [] for rel_path in self.maven_install_paths: if self._is_excluded_path(rel_path): diff --git a/misc/extdeps_pomgen.py b/misc/extdeps_pomgen.py index 7b1a412..bd363e5 100755 --- a/misc/extdeps_pomgen.py +++ b/misc/extdeps_pomgen.py @@ -53,7 +53,7 @@ def _parse_arguments(args): class ThirdPartyDepsPomGen(pom.DynamicPomGen): def __init__(self, workspace, artifact_def, dependencies, pom_template): - super(ThirdPartyDepsPomGen, self).__init__(workspace, artifact_def, + super(ThirdPartyDepsPomGen, self).__init__(workspace, artifact_def, dependency=None, pom_template=pom_template) self.dependencies = dependencies @@ -68,12 +68,20 @@ def _starts_with_ignored_prefix(line): return True return False - def main(args): args = _parse_arguments(args) - repo_root = common.get_repo_root(args.repo_root) + repo_root = common.get_repo_root(args.repo_root) cfg = config.load(repo_root) - mvn_install_info = maveninstallinfo.MavenInstallInfo(cfg.maven_install_paths) + + # For the primary function of pomgen (generating pom.xml files for publishing) + # there are sometimes maven_install namespaces that are ignored in .pomgenrc. + # These are identified as maven_install paths that begin with - . + # For extdeps, we need to have full access to all maven_install namespaces, so + # we tell maveninstallinfo to not honor the excludes. + allow_excludes = False + + mvn_install_info = maveninstallinfo.MavenInstallInfo(cfg.maven_install_paths, allow_excludes) + depmd = dependencymdm.DependencyMetadata(cfg.jar_artifact_classifier) ws = workspace.Workspace(repo_root, cfg, mvn_install_info, pomcontent.NOOP, dependency_metadata=depmd, @@ -82,7 +90,7 @@ def main(args): group_id = "all_ext_deps_group" if args.group_id is None else args.group_id artifact_id = "all_ext_deps_art" if args.artifact_id is None else args.artifact_id version = "0.0.1-SNAPSHOT" if args.version is None else args.version - + artifact_def = buildpom.MavenArtifactDef(group_id=group_id, artifact_id=artifact_id, version=version)