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 remove(artifact_id): """ Remove an artifact from library path """ logger.info('[Checking] %s in library index' % artifact_id) artifact = Artifact.from_id(artifact_id) artifact_path = os.path.join(get_lib_path(), artifact.to_jip_name()) if index_manager.is_installed(artifact) and os.path.exists(artifact_path): os.remove(artifact_path) index_manager.remove_artifact(artifact) index_manager.commit() logger.info('[Finished] %s removed from library path' % artifact_id) else: logger.error('[Error] %s not installed' % artifact_id) sys.exit(1)
def require(artifact_id): _prepare() artifact = Artifact.from_id(artifact_id) artifact_set = _resolve_artifacts([artifact]) ## download to cache first for artifact in artifact_set: if artifact.repos != cache_manager.as_repos(): artifact.repos.download_jar(artifact, cache_manager.get_jar_path(artifact)) pool.join() ## append jars to path for artifact in artifact_set: sys.path.append(cache_manager.get_jar_path(artifact, filepath=True))
def install(artifact_id, options={}): """ Install a package identified by "groupId:artifactId:version" """ artifact = Artifact.from_id(artifact_id) _install([artifact], options=options)