예제 #1
0
파일: maven.py 프로젝트: rajeshmr/kiji
def list_dependencies(
    coordinates,
    scope="runtime",
    local_repo=None,
):
    """Lists the resolved dependencies.

    Args:
        coordinates: Collection of Artifact to examine.
        scope: Optional Maven scope to determine the classpath for. Default is runtime.
        local_repo: Optional explicit Maven local repository to use.
    Returns:
        An iterable of Maven artifact coordinates.
    """
    with tempfile.NamedTemporaryFile(prefix="pom.", suffix=".xml") as pom_file, \
        tempfile.NamedTemporaryFile(prefix="maven-dependency-resolved.", suffix=".txt") as tfile:

        with open(pom_file.name, "wt") as file:
            file.write(
                workflow_task.format_pom_file(
                    artf=artifact.Artifact("unknown", "unknown", "unknown"),
                    compile_deps=coordinates,
                ))

        args = [
            "mvn",
            "--batch-mode",
            "--file={}".format(pom_file.name),
        ]
        if local_repo is not None:
            args += ["-Dmaven.repo.local={}".format(local_repo)]

        args += [
            "dependency:list",
            "-DoutputFile={}".format(tfile.name),
            "-Dsort=true",
            "-DincludeScope={}".format(scope),
        ]
        cmd = command.Command(args=args)
        log_maven_output(cmd.output_lines)

        with open(tfile.name, "rt") as file:
            lines = file.readlines()
            lines = map(str.strip, lines)
            lines = filter(None, lines)
            lines = filter(
                lambda line:
                (line != "The following files have been resolved:"), lines)
            lines = map(artifact.parse_artifact, lines)
            return sorted(lines)
예제 #2
0
파일: maven.py 프로젝트: davnoe/kiji
def list_dependencies(
    coordinates,
    scope="runtime",
    local_repo=None,
):
    """Lists the resolved dependencies.

    Args:
        coordinates: Collection of Artifact to examine.
        scope: Optional Maven scope to determine the classpath for. Default is runtime.
        local_repo: Optional explicit Maven local repository to use.
    Returns:
        An iterable of Maven artifact coordinates.
    """
    with tempfile.NamedTemporaryFile(prefix="pom.", suffix=".xml") as pom_file, \
        tempfile.NamedTemporaryFile(prefix="maven-dependency-resolved.", suffix=".txt") as tfile:

        with open(pom_file.name, "wt") as file:
            file.write(workflow_task.format_pom_file(
                artf=artifact.Artifact("unknown", "unknown", "unknown"),
                compile_deps=coordinates,
            ))

        args = [
            "mvn",
            "--batch-mode",
            "--file={}".format(pom_file.name),
        ]
        if local_repo is not None:
            args += ["-Dmaven.repo.local={}".format(local_repo)]

        args += [
            "dependency:list",
            "-DoutputFile={}".format(tfile.name),
            "-Dsort=true",
            "-DincludeScope={}".format(scope),
        ]
        cmd = command.Command(args=args)
        log_maven_output(cmd.output_lines)

        with open(tfile.name, "rt") as file:
            lines = file.readlines()
            lines = map(str.strip, lines)
            lines = filter(None, lines)
            lines = filter(lambda line: (line != "The following files have been resolved:"), lines)
            lines = map(artifact.parse_artifact, lines)
            return sorted(lines)
예제 #3
0
파일: maven.py 프로젝트: rajeshmr/kiji
def get_dependency_tree(
    coordinates,
    scope=None,
    local_repo=None,
):
    """Reports the dependency tree as a text representation.

    Args:
        coordinates: Collection of Artifact to examine.
        scope: Optional Maven scope to determine the classpath for.
        local_repo: Optional explicit Maven local repository to use.
    Returns:
        A text representation of the Maven dependency tree.
    """
    with tempfile.NamedTemporaryFile(prefix="pom.", suffix=".xml") as pom_file, \
        tempfile.NamedTemporaryFile(prefix="maven-dependency-tree.", suffix=".txt") as tfile:

        with open(pom_file.name, "wt") as file:
            file.write(
                workflow_task.format_pom_file(
                    artf=artifact.Artifact("root", "root", "0"),
                    compile_deps=coordinates,
                ))

        args = [
            "mvn",
            "--batch-mode",
            "--file={}".format(pom_file.name),
        ]
        if local_repo is not None:
            args += ["-Dmaven.repo.local={}".format(local_repo)]

        args += [
            "dependency:tree",
            "-DoutputFile={}".format(tfile.name),
            "-Dverbose",
        ]

        if (scope is not None) and (len(scope) > 0):
            args.append("-Dscope={}".format(scope))

        cmd = command.Command(args=args)
        log_maven_output(cmd.output_lines)

        with open(tfile.name, "rt") as file:
            return file.read()
예제 #4
0
파일: maven.py 프로젝트: davnoe/kiji
def get_dependency_tree(
    coordinates,
    scope=None,
    local_repo=None,
):
    """Reports the dependency tree as a text representation.

    Args:
        coordinates: Collection of Artifact to examine.
        scope: Optional Maven scope to determine the classpath for.
        local_repo: Optional explicit Maven local repository to use.
    Returns:
        A text representation of the Maven dependency tree.
    """
    with tempfile.NamedTemporaryFile(prefix="pom.", suffix=".xml") as pom_file, \
        tempfile.NamedTemporaryFile(prefix="maven-dependency-tree.", suffix=".txt") as tfile:

        with open(pom_file.name, "wt") as file:
            file.write(workflow_task.format_pom_file(
                artf=artifact.Artifact("root", "root", "0"),
                compile_deps=coordinates,
            ))

        args = [
            "mvn",
            "--batch-mode",
            "--file={}".format(pom_file.name),
        ]
        if local_repo is not None:
            args += ["-Dmaven.repo.local={}".format(local_repo)]

        args += [
            "dependency:tree",
            "-DoutputFile={}".format(tfile.name),
            "-Dverbose",
        ]

        if (scope is not None) and (len(scope) > 0):
            args.append("-Dscope={}".format(scope))

        cmd = command.Command(args=args)
        log_maven_output(cmd.output_lines)

        with open(tfile.name, "rt") as file:
            return file.read()
예제 #5
0
파일: maven.py 프로젝트: rajeshmr/kiji
def list_classpath_entries(
    coordinates,
    scope="runtime",
    local_repo=None,
):
    """Lists the classpath entries.

    Args:
        coordinates: Collection of Artifact to examine.
        scope: Optional Maven scope to determine the classpath for. Default is runtime.
        local_repo: Optional explicit Maven local repository to use.
    Returns:
        An iterable of classpath entries.
    """
    with tempfile.NamedTemporaryFile(prefix="pom.", suffix=".xml") as pom_file, \
        tempfile.NamedTemporaryFile(prefix="maven-classpath.", suffix=".txt") as tfile:

        with open(pom_file.name, "wt") as file:
            file.write(
                workflow_task.format_pom_file(
                    artf=artifact.Artifact("unknown", "unknown", "unknown"),
                    compile_deps=coordinates,
                ))

        args = [
            "mvn",
            "--batch-mode",
            "--file={}".format(pom_file.name),
        ]
        if local_repo is not None:
            args += ["-Dmaven.repo.local={}".format(local_repo)]

        args += [
            "dependency:build-classpath",
            "-DincludeScope={}".format(scope),
            "-Dmdep.cpFile={}".format(tfile.name),
        ]
        cmd = command.Command(args=args)
        log_maven_output(cmd.output_lines)

        with open(tfile.name, "rt") as file:
            return file.read().split(":")
예제 #6
0
파일: maven.py 프로젝트: davnoe/kiji
def list_classpath_entries(
    coordinates,
    scope="runtime",
    local_repo=None,
):
    """Lists the classpath entries.

    Args:
        coordinates: Collection of Artifact to examine.
        scope: Optional Maven scope to determine the classpath for. Default is runtime.
        local_repo: Optional explicit Maven local repository to use.
    Returns:
        An iterable of classpath entries.
    """
    with tempfile.NamedTemporaryFile(prefix="pom.", suffix=".xml") as pom_file, \
        tempfile.NamedTemporaryFile(prefix="maven-classpath.", suffix=".txt") as tfile:

        with open(pom_file.name, "wt") as file:
            file.write(workflow_task.format_pom_file(
                artf=artifact.Artifact("unknown", "unknown", "unknown"),
                compile_deps=coordinates,
            ))

        args = [
            "mvn",
            "--batch-mode",
            "--file={}".format(pom_file.name),
        ]
        if local_repo is not None:
            args += ["-Dmaven.repo.local={}".format(local_repo)]

        args += [
            "dependency:build-classpath",
            "-DincludeScope={}".format(scope),
            "-Dmdep.cpFile={}".format(tfile.name),
        ]
        cmd = command.Command(args=args)
        log_maven_output(cmd.output_lines)

        with open(tfile.name, "rt") as file:
            return file.read().split(":")