Пример #1
0
    def maven_dep(
        coord=None,
        group=None,
        id=None,
        version=None,
        classifier=None,
        type=None,
    ):
        assert (
            (coord is None)
            ^ (frozenset({group, id, version, classifier, type}) == frozenset({None}))), \
            "Invalid Maven dependency."

        if coord is not None:
            return artifact.parse_artifact(coord)

        assert not ((group is None) or (id is None) or (version is None)), \
            "Invalid Maven artifact dependency: incomplete coordinate."

        return artifact.Artifact(
            group_id=group,
            artifact_id=id,
            version=version,
            classifier=classifier,
            packaging=type,
        )
Пример #2
0
    def run(self, args):
        coord = self.flags.artifact
        if (coord is None) and (len(args) > 0):
            coord, args = args[0], args[1:]
        assert (coord is not None), "Must specify an artifact to download."

        assert (len(args) == 0), "Unexpected command-line arguments: {!r}".format(args)

        artf = artifact.parse_artifact(coord)
        log.info("Looking up artifact {!s}", artf)

        print(self.repo.get(artf))
        return os.EX_OK
Пример #3
0
    def run(self, args):
        coord = self.flags.artifact
        if (coord is None) and (len(args) > 0):
            coord, args = args[0], args[1:]
        assert (coord is not None), "Must specify an artifact to download."

        assert (len(args) == 0
                ), "Unexpected command-line arguments: {!r}".format(args)

        artf = artifact.parse_artifact(coord)
        log.info("Looking up artifact {!s}", artf)

        print(self.repo.get(artf))
        return os.EX_OK
Пример #4
0
    def maven_dep(
        coord=None,
        group=None, id=None, version=None, classifier=None, type=None,
    ):
        assert (
            (coord is None)
            ^ (frozenset({group, id, version, classifier, type}) == frozenset({None}))), \
            "Invalid Maven dependency."

        if coord is not None:
            return artifact.parse_artifact(coord)

        assert not ((group is None) or (id is None) or (version is None)), \
            "Invalid Maven artifact dependency: incomplete coordinate."

        return artifact.Artifact(
            group_id=group,
            artifact_id=id,
            version=version,
            classifier=classifier,
            packaging=type,
        )
Пример #5
0
    def run(self, args):
        targets = []
        if (self.flags.targets is not None) and (len(self.flags.targets) > 0):
            targets.extend(self.flags.targets.split(","))
        targets.extend(args)
        targets = frozenset(targets)

        if "all" in targets:
            targets = frozenset()

        from_targets = []
        if (self.flags.from_targets is not None) and (len(self.flags.from_targets) > 0):
            from_targets.extend(self.flags.from_targets.split(","))
        from_targets = frozenset(from_targets)

        if "all" in from_targets:
            from_targets = frozenset()

        flow = self.workspace.make_workflow(config=self.workspace.config)

        # Restrict the build to the requested targets:
        targets = frozenset(targets)
        if len(targets) > 0:
            targets = map(lambda target: flow.GetTask(target), targets)
            flow.prune(targets, direction=workflow.UPSTREAM)

        from_targets = frozenset(from_targets)
        if len(from_targets) > 0:
            from_targets = map(lambda target: flow.GetTask(target), from_targets)
            flow.prune(from_targets, direction=workflow.DOWNSTREAM)

        ewkspc = self.flags.eclipse_workspace
        assert os.path.exists(os.path.join(ewkspc, ".metadata"))

        for name, task in flow.tasks.items():
            logging.info("Generating Eclipse project for %r", name)
            eproject_dir = os.path.join(ewkspc, name[2:].replace(":", "/"))
            os.makedirs(eproject_dir, exist_ok=True)
            eproject_path = os.path.join(eproject_dir, ".project")
            with open(eproject_path, mode="wt", encoding="UTF-8") as file:
                file.write(XML_HEADER)
                file.write(ECLIPSE_PROJECT_XML.format(project_name=name[2:].replace("/", ".")))

            eclasspath_path = os.path.join(eproject_dir, ".classpath")
            output_path = os.path.join(self.workspace.output_dir, "eclipse")

            with open(eclasspath_path, mode="wt", encoding="UTF-8") as file:
                file.write(XML_HEADER)
                file.write("<classpath>\n")
                file.write(eclipse_classpath_entry(kind="con", path="org.eclipse.jdt.launching.JRE_CONTAINER") + "\n")
                file.write(eclipse_classpath_entry(kind="output", path=output_path) + "\n")
                for source in task.spec.sources:
                    if source.endswith("**.java"):
                        file.write(eclipse_classpath_entry(
                            kind="src",
                            path=self.workspace.tools.resolve_wpath(source[:-7]),
                        ))
                        file.write("\n")

                for dep in task.spec.deps:
                    file.write(eclipse_classpath_entry(
                        kind="src",
                        path="/" + dep[2:].replace("/", "."),
                        combine_access_rules=False,  # Project-Project dependency
                    ))
                    file.write("\n")
                for maven_dep in task.spec.maven_deps:
                    artf = artifact.parse_artifact(maven_dep)
                    jar_path = self.workspace.tools.artifact_abspath(artf)

                    file.write(eclipse_classpath_entry(
                        kind="lib",
                        path=jar_path,
                        # source_path=...
                    ))
                    file.write("\n")

                file.write("</classpath>\n")
Пример #6
0
    def run(self, args):
        targets = []
        if (self.flags.targets is not None) and (len(self.flags.targets) > 0):
            targets.extend(self.flags.targets.split(","))
        targets.extend(args)
        targets = frozenset(targets)

        if "all" in targets:
            targets = frozenset()

        from_targets = []
        if (self.flags.from_targets
                is not None) and (len(self.flags.from_targets) > 0):
            from_targets.extend(self.flags.from_targets.split(","))
        from_targets = frozenset(from_targets)

        if "all" in from_targets:
            from_targets = frozenset()

        flow = self.workspace.make_workflow(config=self.workspace.config)

        # Restrict the build to the requested targets:
        targets = frozenset(targets)
        if len(targets) > 0:
            targets = map(lambda target: flow.GetTask(target), targets)
            flow.prune(targets, direction=workflow.UPSTREAM)

        from_targets = frozenset(from_targets)
        if len(from_targets) > 0:
            from_targets = map(lambda target: flow.GetTask(target),
                               from_targets)
            flow.prune(from_targets, direction=workflow.DOWNSTREAM)

        ewkspc = self.flags.eclipse_workspace
        assert os.path.exists(os.path.join(ewkspc, ".metadata"))

        for name, task in flow.tasks.items():
            logging.info("Generating Eclipse project for %r", name)
            eproject_dir = os.path.join(ewkspc, name[2:].replace(":", "/"))
            os.makedirs(eproject_dir, exist_ok=True)
            eproject_path = os.path.join(eproject_dir, ".project")
            with open(eproject_path, mode="wt", encoding="UTF-8") as file:
                file.write(XML_HEADER)
                file.write(
                    ECLIPSE_PROJECT_XML.format(
                        project_name=name[2:].replace("/", ".")))

            eclasspath_path = os.path.join(eproject_dir, ".classpath")
            output_path = os.path.join(self.workspace.output_dir, "eclipse")

            with open(eclasspath_path, mode="wt", encoding="UTF-8") as file:
                file.write(XML_HEADER)
                file.write("<classpath>\n")
                file.write(
                    eclipse_classpath_entry(
                        kind="con",
                        path="org.eclipse.jdt.launching.JRE_CONTAINER") + "\n")
                file.write(
                    eclipse_classpath_entry(kind="output", path=output_path) +
                    "\n")
                for source in task.spec.sources:
                    if source.endswith("**.java"):
                        file.write(
                            eclipse_classpath_entry(
                                kind="src",
                                path=self.workspace.tools.resolve_wpath(
                                    source[:-7]),
                            ))
                        file.write("\n")

                for dep in task.spec.deps:
                    file.write(
                        eclipse_classpath_entry(
                            kind="src",
                            path="/" + dep[2:].replace("/", "."),
                            combine_access_rules=
                            False,  # Project-Project dependency
                        ))
                    file.write("\n")
                for maven_dep in task.spec.maven_deps:
                    artf = artifact.parse_artifact(maven_dep)
                    jar_path = self.workspace.tools.artifact_abspath(artf)

                    file.write(
                        eclipse_classpath_entry(
                            kind="lib",
                            path=jar_path,
                            # source_path=...
                        ))
                    file.write("\n")

                file.write("</classpath>\n")