Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

suppress maven_install excludes in some cases #184

Merged
merged 1 commit into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading