Skip to content

Commit

Permalink
suppress maven_install excludes in some cases (#184)
Browse files Browse the repository at this point in the history
  • Loading branch information
plaird authored Aug 20, 2024
1 parent 4f6c0ee commit 040d357
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
9 changes: 7 additions & 2 deletions common/maveninstallinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
18 changes: 13 additions & 5 deletions misc/extdeps_pomgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand All @@ -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)
Expand Down

0 comments on commit 040d357

Please sign in to comment.