def __init__(self, repo_dir):
    # Clear the cache before analyzing the repo
    PomUtils.reset_caches()
    self.repo_dir = repo_dir
    self._top_pom = PomUtils.top_pom_content_handler(rootdir=repo_dir)

    self._pom_details = {}
    # Parse oll of the poms for the modules [ plus the top level pom.xml ]
    module_list = self._top_pom.modules + ['']
    while len(module_list):
      module = module_list.pop()
      if module in self._pom_details.keys():
        continue
      full_source_path = os.path.join(repo_dir, module, 'pom.xml')
      pom_handler = _DFPomContentHandler()
      try:
        with open(full_source_path) as source:
          xml.sax.parse(source, pom_handler)
      except IOError:
        # assume this file has been removed for a good reason and just continue normally
        continue
      self._pom_details[module] = PomDetails(repo_dir, module, pom_handler)
      # Don't forget to also add in the parent poms
      if 'relativePath' in pom_handler.parent:
        parent_module = os.path.join(module, pom_handler.parent['relativePath'])
        if os.path.basename(parent_module) == 'pom.xml':
          parent_module = os.path.dirname(parent_module)
        parent_module =os.path.normpath(parent_module)
        if parent_module not in self._pom_details.keys():
          module_list.append(parent_module)
Ejemplo n.º 2
0
def build_dependency_graph():
  dependency_edges = {}
  for module in PomUtils.top_pom_content_handler().modules:
    logger.debug("found module: " + module)
    finder = CachedDependencyInfos.get(module + "/pom.xml")
    deps = finder.dependencies
    target = "{group_id}.{artifact_id}".format(group_id=finder.groupId,
                                               artifact_id=finder.artifactId)
    logger.debug("Adding dependencies for {target}".format(target=target))
    dependency_edges[target] = []
    for dep in deps:
      dep_target = "{group_id}.{artifact_id}".format(group_id=dep['groupId'],
                                                     artifact_id=dep['artifactId'])
      logger.debug("{target} => {dep_target}".format(target=target, dep_target=dep_target))
      dependency_edges[target].append(dep_target)
  return dependency_edges
Ejemplo n.º 3
0
def build_dependency_graph():
    dependency_edges = {}
    for module in PomUtils.top_pom_content_handler().modules:
        logger.debug("found module: " + module)
        finder = CachedDependencyInfos.get(module + "/pom.xml")
        deps = finder.dependencies
        target = "{group_id}.{artifact_id}".format(
            group_id=finder.groupId, artifact_id=finder.artifactId)
        logger.debug("Adding dependencies for {target}".format(target=target))
        dependency_edges[target] = []
        for dep in deps:
            dep_target = "{group_id}.{artifact_id}".format(
                group_id=dep['groupId'], artifact_id=dep['artifactId'])
            logger.debug("{target} => {dep_target}".format(
                target=target, dep_target=dep_target))
            dependency_edges[target].append(dep_target)
    return dependency_edges