Exemple #1
0
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)
Exemple #2
0
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)
Exemple #3
0
 def download_jar(self, artifact, local_path):
     maven_file_path = self.get_artifact_uri(artifact, 'jar')
     logger.info("[Checking] jar package from %s" % self.name)
     if os.path.exists(maven_file_path):
         local_jip_path = local_path+"/"+artifact.to_jip_name()
         logger.info("[Downloading] %s" % maven_file_path)
         shutil.copy(maven_file_path, local_jip_path)
         logger.info("[Finished] %s completed" % local_jip_path)
     else:
         logger.error("[Error] File not found %s" % maven_file_path)
         raise IOError('File not found:' + maven_file_path)
Exemple #4
0
 def download_jar(self, artifact, local_path):
     maven_file_path = self.get_artifact_uri(artifact, 'jar')
     logger.info("[Checking] jar package from %s" % self.name)
     if os.path.exists(maven_file_path):
         local_jip_path = os.path.join(local_path, artifact.to_jip_name())
         logger.info("[Downloading] %s" % maven_file_path)
         shutil.copy(maven_file_path, local_jip_path)
         logger.info("[Finished] %s completed" % local_jip_path)
     else:
         logger.error("[Error] File not found %s" % maven_file_path)
         raise IOError('File not found:' + maven_file_path)
Exemple #5
0
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)
Exemple #6
0
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)
Exemple #7
0
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
Exemple #8
0
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
Exemple #9
0
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
Exemple #10
0
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