def map_external_jars(self): external_jar_dir = os.path.join(self.gen_project_workdir, 'external-libs') safe_mkdir(external_jar_dir, clean=True) external_source_jar_dir = os.path.join(self.gen_project_workdir, 'external-libsources') safe_mkdir(external_source_jar_dir, clean=True) external_javadoc_jar_dir = os.path.join(self.gen_project_workdir, 'external-libjavadoc') safe_mkdir(external_javadoc_jar_dir, clean=True) jar_products = self.context.products.get_data('ivy_jar_products') jar_paths = get_jar_infos(jar_products, confs=['default', 'sources', 'javadoc']) for entry in jar_paths.values(): binary_jars = entry.get('default') sources_jars = entry.get('sources') javadoc_jars = entry.get('javadoc') cp_jars = self.copy_jars(binary_jars, external_jar_dir) cp_source_jars = self.copy_jars(sources_jars, external_source_jar_dir) cp_javadoc_jars = self.copy_jars(javadoc_jars, external_javadoc_jar_dir) for i in range(len(cp_jars)): cp_jar = cp_jars[i] if i < len(cp_source_jars): cp_source_jar = cp_source_jars[i] else: cp_source_jar = None if i < len(cp_javadoc_jars): cp_javadoc_jar = cp_javadoc_jars[i] else: cp_javadoc_jar = None self._project.external_jars.add(ClasspathEntry(cp_jar, source_jar=cp_source_jar, javadoc_jar=cp_javadoc_jar))
def _resolve_jars_info(self): """Consults ivy_jar_products to export the external libraries. :return: mapping of jar_id -> { 'default' : <jar_file>, 'sources' : <jar_file>, 'javadoc' : <jar_file>, <other_confs> : <jar_file>, } """ mapping = defaultdict(dict) jar_data = self.context.products.get_data('ivy_jar_products') jar_infos = get_jar_infos(ivy_products=jar_data) for ivy_module_ref, conf_to_jarfile_map in jar_infos.iteritems(): mapping[self._jar_id(ivy_module_ref)].update(conf_to_jarfile_map) return mapping
def _resolve_jars_info(self): """Consults ivy_jar_products to export the external libraries. :return: mapping of jar_id -> { 'default' : [ <jar_files> ], 'sources' : [ <jar_files> ], 'javadoc' : [ <jar_files> ], } """ mapping = defaultdict(list) jar_data = self.context.products.get_data('ivy_jar_products') jar_infos = get_jar_infos(ivy_products=jar_data, confs=['default', 'sources', 'javadoc']) for ivy_module_ref, paths in jar_infos.iteritems(): conf_to_jarfile_map = OrderedDict() for conf, pathlist in paths.iteritems(): # TODO(Eric Ayers): pathlist can contain multiple jars in the case where classifiers # to resolve extra artifacts are used. This only captures the first one, meaning the # export is incomplete. See https://github.com/pantsbuild/pants/issues/1489 if pathlist: conf_to_jarfile_map[conf] = pathlist[0] mapping[self._jar_id(ivy_module_ref)] = conf_to_jarfile_map return mapping
def map_external_jars(self): external_jar_dir = os.path.join(self.gen_project_workdir, 'external-libs') safe_mkdir(external_jar_dir, clean=True) external_source_jar_dir = os.path.join(self.gen_project_workdir, 'external-libsources') safe_mkdir(external_source_jar_dir, clean=True) external_javadoc_jar_dir = os.path.join(self.gen_project_workdir, 'external-libjavadoc') safe_mkdir(external_javadoc_jar_dir, clean=True) jar_products = self.context.products.get_data('ivy_jar_products') jar_paths = get_jar_infos(jar_products) for entry in jar_paths.values(): binary_jar = self.copy_jar(entry.get('default'), external_jar_dir) sources_jar = self.copy_jar(entry.get('sources'), external_source_jar_dir) javadoc_jar = self.copy_jar(entry.get('javadoc'), external_javadoc_jar_dir) if binary_jar: self._project.external_jars.add(ClasspathEntry(jar=binary_jar, source_jar=sources_jar, javadoc_jar=javadoc_jar)) # treat all other jars as binaries for classifier, jar in entry.iteritems(): if classifier not in {'default', 'sources', 'javadoc'}: binary_jar = self.copy_jar(jar, external_jar_dir) self._project.external_jars.add(ClasspathEntry(binary_jar))