예제 #1
0
  def find_plugins(self, plugin_names):
    """Returns a map from plugin name to plugin jar."""
    plugin_names = set(plugin_names)
    plugins = {}
    buildroot = get_buildroot()
    # plugin_jars is the universe of all possible plugins and their transitive deps.
    # Here we select the ones to actually use.
    for jar in self.plugin_jars():
      with open_jar(jar, 'r') as jarfile:
        try:
          with closing(jarfile.open(_PLUGIN_INFO_FILE, 'r')) as plugin_info_file:
            plugin_info = ElementTree.parse(plugin_info_file).getroot()
          if plugin_info.tag != 'plugin':
            raise TaskError(
              'File %s in %s is not a valid scalac plugin descriptor' % (_PLUGIN_INFO_FILE, jar))
          name = plugin_info.find('name').text
          if name in plugin_names:
            if name in plugins:
              raise TaskError('Plugin %s defined in %s and in %s' % (name, plugins[name], jar))
            # It's important to use relative paths, as the compiler flags get embedded in the zinc
            # analysis file, and we port those between systems via the artifact cache.
            plugins[name] = os.path.relpath(jar, buildroot)
        except KeyError:
          pass

    unresolved_plugins = plugin_names - set(plugins.keys())
    if unresolved_plugins:
      raise TaskError('Could not find requested plugins: %s' % list(unresolved_plugins))
    return plugins
예제 #2
0
    def find_plugins(self, plugin_names):
        """Returns a map from plugin name to plugin jar."""
        plugin_names = set(plugin_names)
        plugins = {}
        buildroot = get_buildroot()
        # plugin_jars is the universe of all possible plugins and their transitive deps.
        # Here we select the ones to actually use.
        for jar in self.plugin_jars():
            with open_jar(jar, 'r') as jarfile:
                try:
                    with closing(jarfile.open(_PLUGIN_INFO_FILE,
                                              'r')) as plugin_info_file:
                        plugin_info = ElementTree.parse(
                            plugin_info_file).getroot()
                    if plugin_info.tag != 'plugin':
                        raise TaskError(
                            'File %s in %s is not a valid scalac plugin descriptor'
                            % (_PLUGIN_INFO_FILE, jar))
                    name = plugin_info.find('name').text
                    if name in plugin_names:
                        if name in plugins:
                            raise TaskError(
                                'Plugin %s defined in %s and in %s' %
                                (name, plugins[name], jar))
                        # It's important to use relative paths, as the compiler flags get embedded in the zinc
                        # analysis file, and we port those between systems via the artifact cache.
                        plugins[name] = os.path.relpath(jar, buildroot)
                except KeyError:
                    pass

        unresolved_plugins = plugin_names - set(plugins.keys())
        if unresolved_plugins:
            raise TaskError('Could not find requested plugins: %s' %
                            list(unresolved_plugins))
        return plugins
예제 #3
0
 def list_jar(self, path):
     with open_jar(path, 'r') as jar:
         return jar.namelist()
예제 #4
0
 def list_jar(self, path):
   with open_jar(path, 'r') as jar:
     return jar.namelist()