def update(artifact_id): """ Update a snapshot artifact, check for new version """ artifact = Artifact.from_id(artifact_id) artifact = index_manager.get_artifact(artifact) if artifact is None: logger.error('[Error] Can not update %s, please install it first' % artifact) sys.exit(1) if artifact.is_snapshot(): selected_repos = artifact.repos installed_file = os.path.join(get_lib_path(), artifact.to_jip_name()) if os.path.exists(installed_file): lm = os.stat(installed_file)[stat.ST_MTIME] ## find the repository contains the new release ts = selected_repos.last_modified(artifact) if ts is not None and ts > lm : ## download new jar selected_repos.download_jar(artifact, get_lib_path()) ## try to update dependencies pomstring = selected_repos.download_pom(artifact) pom = Pom(pomstring) dependencies = pom.get_dependencies() _install(dependencies) else: logger.error('[Error] Artifact not installed: %s' % artifact) sys.exit(1) else: logger.error('[Error] Can not update non-snapshot artifact') return
def update(artifact_id): """ Update a snapshot artifact, check for new version """ artifact = Artifact.from_id(artifact_id) artifact = index_manager.get_artifact(artifact) if artifact is None: logger.error('[Error] Can not update %s, please install it first' % artifact) sys.exit(1) if artifact.is_snapshot(): selected_repos = artifact.repos installed_file = os.path.join(get_lib_path(), artifact.to_jip_name()) if os.path.exists(installed_file): lm = os.stat(installed_file)[stat.ST_MTIME] ## find the repository contains the new release ts = selected_repos.last_modified(artifact) if ts is not None and ts > lm: ## download new jar selected_repos.download_jar(artifact, get_lib_path()) ## try to update dependencies pomstring = selected_repos.download_pom(artifact) pom = Pom(pomstring) dependencies = pom.get_dependencies() _install(dependencies) else: logger.error('[Error] Artifact not installed: %s' % artifact) sys.exit(1) else: logger.error('[Error] Can not update non-snapshot artifact') return
def deps(artifact_id, options={}): """ Install dependencies for a given artifact coordinator """ artifact = Artifact.from_id(artifact_id) pominfo = _find_pom(artifact) if pominfo is not None: pom = Pom(pominfo[0]) _install(pom.get_dependencies(), options=options) else: logger.error('[Error] artifact %s not found in any repository' % artifact_id) sys.exit(1)
def resolve(pomfile, options={}): """ Resolve and download dependencies in pom file """ pomfile = open(pomfile, 'r') pomstring = pomfile.read() pom = Pom(pomstring) ## custom defined repositories repositories = pom.get_repositories() for repos in repositories: repos_manager.add_repos(*repos) dependencies = pom.get_dependencies() _install(dependencies, options=options)
def _resolve_artifacts(artifacts, exclusions=[]): ## download queue download_list = [] ## dependency_set contains artifact objects to resolve dependency_set = set() for a in artifacts: dependency_set.add(a) while len(dependency_set) > 0: artifact = dependency_set.pop() ## to prevent multiple version installed ## TODO we need a better strategy to resolve this if index_manager.is_same_installed(artifact)\ and artifact not in download_list: continue pominfo = _find_pom(artifact) if pominfo is None: logger.error("[Error] Artifact not found: %s", artifact) sys.exit(1) if not index_manager.is_installed(artifact): pom, repos = pominfo # repos.download_jar(artifact, get_lib_path()) artifact.repos = repos # skip excluded artifact if not any(map(artifact.is_same_artifact, exclusions)): download_list.append(artifact) index_manager.add_artifact(artifact) pom_obj = Pom(pom) for r in pom_obj.get_repositories(): repos_manager.add_repos(*r) more_dependencies = pom_obj.get_dependencies() for d in more_dependencies: d.exclusions.extend(artifact.exclusions) if not index_manager.is_same_installed(d): dependency_set.add(d) return download_list
def _resolve_artifacts(artifacts, exclusions=[], verify=True): ## download queue download_list = [] ## dependency_set contains artifact objects to resolve dependency_set = set() for a in artifacts: dependency_set.add(a) while len(dependency_set) > 0: artifact = dependency_set.pop() ## to prevent multiple version installed ## TODO we need a better strategy to resolve this if index_manager.is_same_installed(artifact)\ and artifact not in download_list: continue pominfo = _find_pom(artifact, verify) if pominfo is None: logger.error("[Error] Artifact not found: %s", artifact) sys.exit(1) if not index_manager.is_installed(artifact): pom, repos = pominfo # repos.download_jar(artifact, get_lib_path()) artifact.repos = repos # skip excluded artifact if not any(map(artifact.is_same_artifact, exclusions)): download_list.append(artifact) index_manager.add_artifact(artifact) pom_obj = Pom(pom) for r in pom_obj.get_repositories(): repos_manager.add_repos(*r) more_dependencies = pom_obj.get_dependencies(verify) for d in more_dependencies: d.exclusions.extend(artifact.exclusions) if not index_manager.is_same_installed(d): dependency_set.add(d) return download_list