def process_databinding(self, original_changed_files, changed_files_ref): if 'databinding' in self._config: if self._config['databinding_modules'] == 0: self.debug('no modules for processing databinding') return databinding_config = self._config['databinding'] DatabindingDirectoryLookUp.load_path_map(self._config['build_cache_dir']) procossor = DataBindingProcessor(self._config) for module_config in databinding_config: module_name = module_config['name'] if module_name in original_changed_files['projects']: resources_files = original_changed_files['projects'][module_config['name']]['res'] if len(resources_files) == 0: self.debug('module {} has no resources files changed'.format(module_name)) continue changed_files_map = {} res_dirs = self._config['project_source_sets'][module_name]['main_res_directory'] # TODO: detect matches missing issue for path in resources_files: for rdir in res_dirs: if path.startswith(rdir): if rdir in changed_files_map: changed_files_map[rdir].append(path) else: changed_files_map[rdir] = [path] break for rdir in changed_files_map.keys(): output_res_dir = DatabindingDirectoryLookUp.find_target_res_path(rdir) output_java_dir = DatabindingDirectoryLookUp.find_target_java_path(rdir) output_layoutinfo_dir = DatabindingDirectoryLookUp.get_merged_layoutinfo_dir(self._cache_dir) if output_res_dir and output_java_dir and output_layoutinfo_dir: changed_files_list = changed_files_map[rdir] procossor.process_module_databinding(module_config, rdir, output_res_dir, output_layoutinfo_dir, output_java_dir, self._config['sdk_directory'], changed_files=changed_files_list) # replace file path for path in changed_files_list: new_path = path.replace(rdir, output_res_dir) self._merged_res_paths.append(output_res_dir) # append new path prefix self.debug('replace {} with output path: {}'.format(path, new_path)) self._replace_mapper[new_path] = path self._changed_files['res'].remove(path) self._changed_files['res'].append(new_path) # mark java compiler if os.path.exists(output_layoutinfo_dir): has_layoutinfo = False for name in os.listdir(output_layoutinfo_dir): if name.endswith('.xml'): has_layoutinfo = True break if has_layoutinfo: info_file = os.path.join(output_java_dir, 'android', 'databinding', 'layouts', 'DataBindingInfo.java') if os.path.exists(info_file): append_files = [info_file] append_files.extend(procossor.extract_related_java_files(module_name, output_layoutinfo_dir)) if 'apt' not in changed_files_ref['projects'][module_name]: changed_files_ref['projects'][module_name]['apt'] = [] for fpath in append_files: self.debug('add {} to {} module'.format(fpath, module_name)) changed_files_ref['projects'][module_name]['apt'].append(fpath) if not android_tools.is_src_changed(self._config['build_cache_dir']): android_tools.mark_src_changed(self._config['build_cache_dir'])