def _save_module_stat(self, module_name, module_path): # scan bulid.gradle self.__save_stat(module_name, os.path.join(module_path, 'build.gradle')) # scan libs dirs libs_dir_names = ['libs', 'lib'] for lib_dir_name in libs_dir_names: lib_dir_path = os.path.join(module_path, lib_dir_name) if os.path.isdir(lib_dir_path): for dirpath, dirnames, files in os.walk(lib_dir_path): for fn in files: if fn.endswith(".jar"): self.__save_stat(module_name, os.path.join(dirpath, fn)) # scan assets if module_name in self._config['project_source_sets']: # scan manifest self.__save_stat(module_name, self._config['project_source_sets'][module_name]['main_manifest_path']) # scan native so if 'main_jniLibs_directory' in self._config['project_source_sets'][module_name]: native_so_dirs = self._config['project_source_sets'][module_name]['main_jniLibs_directory'] for native_so_dir in native_so_dirs: if os.path.exists(native_so_dir): for dirpath, dirnames, files in os.walk(native_so_dir): for fn in files: if fn.endswith(".so"): self.__save_stat(module_name, os.path.join(dirpath, fn)) assets_dirs = self._config['project_source_sets'][module_name]['main_assets_directory'] for assets_dir in assets_dirs: if os.path.exists(assets_dir): for dirpath, dirnames, files in os.walk(assets_dir): for fn in files: self.__save_stat(module_name, os.path.join(dirpath, fn)) res_dirs = self._config['project_source_sets'][module_name]['main_res_directory'] for res_dir in res_dirs: if os.path.exists(res_dir): for sub_dir in os.listdir(res_dir): sub_dir_path = os.path.join(res_dir, sub_dir) if os.path.isdir(sub_dir_path) and android_tools.is_res_sub_dir(sub_dir): for fn in os.listdir(sub_dir_path): if '.DS_Store' in fn: continue self.__save_stat(module_name, os.path.join(sub_dir_path, fn)) src_dirs = self._config['project_source_sets'][module_name]['main_src_directory'] for src_dir in src_dirs: if os.path.exists(src_dir): for dirpath, dirnames, files in os.walk(src_dir): if re.findall(r'[/\\+]androidTest[/\\+]', dirpath) or '/.' in dirpath: continue for fn in files: if fn.endswith('java'): if fn.endswith('package-info.java') or fn.endswith('BuildConfig.java'): continue self.__save_stat(module_name, os.path.join(dirpath, fn))
def _save_module_stat(self, module_name, module_path): # scan bulid.gradle self.__save_stat(module_name, os.path.join(module_path, 'build.gradle')) # scan libs dirs libs_dir_names = ['libs', 'lib'] for lib_dir_name in libs_dir_names: lib_dir_path = os.path.join(module_path, lib_dir_name) if os.path.isdir(lib_dir_path): for dirpath, dirnames, files in os.walk(lib_dir_path): for fn in files: if fn.endswith(".jar"): self.__save_stat(module_name, os.path.join(dirpath, fn)) # scan assets if module_name in self._config['project_source_sets']: # scan manifest self.__save_stat(module_name, self._config['project_source_sets'][module_name]['main_manifest_path']) # scan native so if 'main_jniLibs_directory' in self._config['project_source_sets'][module_name]: native_so_dirs = self._config['project_source_sets'][module_name]['main_jniLibs_directory'] for native_so_dir in native_so_dirs: if os.path.exists(native_so_dir): for dirpath, dirnames, files in os.walk(native_so_dir): for fn in files: if fn.endswith(".so"): self.__save_stat(module_name, os.path.join(dirpath, fn)) assets_dirs = self._config['project_source_sets'][module_name]['main_assets_directory'] for assets_dir in assets_dirs: if os.path.exists(assets_dir): for dirpath, dirnames, files in os.walk(assets_dir): for fn in files: self.__save_stat(module_name, os.path.join(dirpath, fn)) res_dirs = self._config['project_source_sets'][module_name]['main_res_directory'] for res_dir in res_dirs: if os.path.exists(res_dir): for sub_dir in os.listdir(res_dir): sub_dir_path = os.path.join(res_dir, sub_dir) if os.path.isdir(sub_dir_path) and android_tools.is_res_sub_dir(sub_dir): for fn in os.listdir(sub_dir_path): if '.DS_Store' in fn: continue self.__save_stat(module_name, os.path.join(sub_dir_path, fn)) src_dirs = self._config['project_source_sets'][module_name]['main_src_directory'] for src_dir in src_dirs: if os.path.exists(src_dir): for dirpath, dirnames, files in os.walk(src_dir): if re.findall(r'[/\\+]androidTest[/\\+]', dirpath) or '/.' in dirpath: continue for fn in files: if fn.endswith('java'): if fn.endswith('package-info.java') or fn.endswith('BuildConfig.java'): continue self.__save_stat(module_name, os.path.join(dirpath, fn))
def _scan_module_changes(self, module_name, module_path): module_cache = self._stat_cache[module_name] # scan bulid.gradle config_path = os.path.join(module_path, 'build.gradle') if self.__check_changes(module_name, config_path, module_cache): self._changed_files[module_name]['config'].append(config_path) # scan libs dirs libs_dir_names = ['libs', 'lib'] for lib_dir_name in libs_dir_names: lib_dir_path = os.path.join(module_path, lib_dir_name) if os.path.isdir(lib_dir_path): for dirpath, dirnames, files in os.walk(lib_dir_path): for fn in files: if fn.endswith(".jar"): fpath = os.path.join(dirpath, fn) if self.__check_changes(module_name, fpath, module_cache): self._changed_files[module_name]['libs'].append(fpath) if module_name in self._config['project_source_sets']: # scan manifest manifest = self._config['project_source_sets'][module_name]['main_manifest_path'] if self.__check_changes(module_name, manifest, module_cache): self._changed_files[module_name]['manifest'].append(manifest) # scan native so if 'main_jniLibs_directory' in self._config['project_source_sets'][module_name]: native_so_dirs = self._config['project_source_sets'][module_name]['main_jniLibs_directory'] for native_so_dir in native_so_dirs: if os.path.exists(native_so_dir): for dirpath, dirnames, files in os.walk(native_so_dir): for fn in files: if fn.endswith(".so"): fpath = os.path.join(dirpath, fn) if self.__check_changes(module_name, fpath, module_cache): self._changed_files[module_name]['so'].append(fpath) # scan assets assets_dirs = self._config['project_source_sets'][module_name]['main_assets_directory'] for assets_dir in assets_dirs: if os.path.exists(assets_dir): for dirpath, dirnames, files in os.walk(assets_dir): for fn in files: fpath = os.path.join(dirpath, fn) if self.__check_changes(module_name, fpath, module_cache): self._changed_files[module_name]['assets'].append(fpath) # scan res res_dirs = self._config['project_source_sets'][module_name]['main_res_directory'] for res_dir in res_dirs: if os.path.exists(res_dir): for sub_dir in os.listdir(res_dir): sub_dir_path = os.path.join(res_dir, sub_dir) if os.path.isdir(sub_dir_path) and android_tools.is_res_sub_dir(sub_dir): for fn in os.listdir(sub_dir_path): if '.DS_Store' in fn: continue fpath = os.path.join(sub_dir_path, fn) if self.__check_changes(module_name, fpath, module_cache, should_check_size=True): self._changed_files[module_name]['res'].append(fpath) # scan src src_dirs = self._config['project_source_sets'][module_name]['main_src_directory'] for src_dir in src_dirs: if os.path.exists(src_dir): for dirpath, dirnames, files in os.walk(src_dir): if re.findall(r'[/\\+]androidTest[/\\+]', dirpath) or '/.' in dirpath: continue for fn in files: if fn.endswith('java'): if fn.endswith('package-info.java') or fn.endswith('BuildConfig.java'): continue fpath = os.path.join(dirpath, fn) if self.__check_changes(module_name, fpath, module_cache): self._changed_files[module_name]['src'].append(fpath)
def _scan_module_changes(self, module_name, module_path): module_cache = self._stat_cache[module_name] # scan bulid.gradle config_path = os.path.join(module_path, 'build.gradle') if self.__check_changes(module_name, config_path, module_cache): self._changed_files[module_name]['config'].append(config_path) # scan libs dirs libs_dir_names = ['libs', 'lib'] for lib_dir_name in libs_dir_names: lib_dir_path = os.path.join(module_path, lib_dir_name) if os.path.isdir(lib_dir_path): for dirpath, dirnames, files in os.walk(lib_dir_path): for fn in files: if fn.endswith(".jar"): fpath = os.path.join(dirpath, fn) if self.__check_changes(module_name, fpath, module_cache): self._changed_files[module_name]['libs'].append(fpath) if module_name in self._config['project_source_sets']: # scan manifest manifest = self._config['project_source_sets'][module_name]['main_manifest_path'] if self.__check_changes(module_name, manifest, module_cache): self._changed_files[module_name]['manifest'].append(manifest) # scan native so if 'main_jniLibs_directory' in self._config['project_source_sets'][module_name]: native_so_dirs = self._config['project_source_sets'][module_name]['main_jniLibs_directory'] for native_so_dir in native_so_dirs: if os.path.exists(native_so_dir): for dirpath, dirnames, files in os.walk(native_so_dir): for fn in files: if fn.endswith(".so"): fpath = os.path.join(dirpath, fn) if self.__check_changes(module_name, fpath, module_cache): self._changed_files[module_name]['so'].append(fpath) # scan assets assets_dirs = self._config['project_source_sets'][module_name]['main_assets_directory'] for assets_dir in assets_dirs: if os.path.exists(assets_dir): for dirpath, dirnames, files in os.walk(assets_dir): for fn in files: fpath = os.path.join(dirpath, fn) if self.__check_changes(module_name, fpath, module_cache): self._changed_files[module_name]['assets'].append(fpath) # scan res res_dirs = self._config['project_source_sets'][module_name]['main_res_directory'] for res_dir in res_dirs: if os.path.exists(res_dir): for sub_dir in os.listdir(res_dir): sub_dir_path = os.path.join(res_dir, sub_dir) if os.path.isdir(sub_dir_path) and android_tools.is_res_sub_dir(sub_dir): for fn in os.listdir(sub_dir_path): if '.DS_Store' in fn: continue fpath = os.path.join(sub_dir_path, fn) if self.__check_changes(module_name, fpath, module_cache, should_check_size=True): self._changed_files[module_name]['res'].append(fpath) # scan src src_dirs = self._config['project_source_sets'][module_name]['main_src_directory'] for src_dir in src_dirs: if os.path.exists(src_dir): for dirpath, dirnames, files in os.walk(src_dir): if re.findall(r'[/\\+]androidTest[/\\+]', dirpath) or '/.' in dirpath: continue for fn in files: if fn.endswith('java'): if fn.endswith('package-info.java') or fn.endswith('BuildConfig.java'): continue fpath = os.path.join(dirpath, fn) if self.__check_changes(module_name, fpath, module_cache): self._changed_files[module_name]['src'].append(fpath)