示例#1
0
  def configure_project(self, targets, debug_port):
    jvm_targets = [t for t in targets if t.has_label('jvm') or t.has_label('java') or
                   isinstance(t, Resources)]
    if self.intransitive:
      jvm_targets = set(self.context.target_roots).intersection(jvm_targets)

    build_ignore_patterns = self.context.options.for_global_scope().ignore_patterns or []
    build_ignore_patterns.extend(BuildFile._spec_excludes_to_gitignore_syntax(
      os.path.realpath(get_buildroot()), self.context.options.for_global_scope().spec_excludes))

    project = Project(self.project_name,
                      self.python,
                      self.skip_java,
                      self.skip_scala,
                      self.use_source_root,
                      get_buildroot(),
                      debug_port,
                      self.context,
                      jvm_targets,
                      not self.intransitive,
                      self.TargetUtil(self.context),
                      None,
                      PathSpec.from_lines(GitIgnorePattern, build_ignore_patterns))

    if self.python:
      python_source_paths = self.get_options().python_source_paths
      python_test_paths = self.get_options().python_test_paths
      python_lib_paths = self.get_options().python_lib_paths
      project.configure_python(python_source_paths, python_test_paths, python_lib_paths)

    extra_source_paths = self.get_options().extra_jvm_source_paths
    extra_test_paths = self.get_options().extra_jvm_test_paths
    all_targets = project.configure_jvm(extra_source_paths, extra_test_paths)
    return all_targets, project
示例#2
0
    def __init__(self,
                 root_dir,
                 options,
                 build_config,
                 run_tracker,
                 reporting,
                 exiter=sys.exit):
        """
    :param str root_dir: The root directory of the pants workspace (aka the "build root").
    :param Options options: The global, pre-initialized Options instance.
    :param BuildConfiguration build_config: A pre-initialized BuildConfiguration instance.
    :param Runtracker run_tracker: The global, pre-initialized/running RunTracker instance.
    :param Reporting reporting: The global, pre-initialized Reporting instance.
    :param func exiter: A function that accepts an exit code value and exits (for tests, Optional).
    """
        self._root_dir = root_dir
        self._options = options
        self._build_config = build_config
        self._run_tracker = run_tracker
        self._reporting = reporting
        self._exiter = exiter

        self._goals = []
        self._targets = []
        self._requested_goals = self._options.goals
        self._target_specs = self._options.target_specs
        self._help_request = self._options.help_request

        self._global_options = options.for_global_scope()
        self._tag = self._global_options.tag
        self._fail_fast = self._global_options.fail_fast
        # Will be provided through context.address_mapper.build_ignore_patterns.
        self._spec_excludes = None
        self._explain = self._global_options.explain
        self._kill_nailguns = self._global_options.kill_nailguns

        self._project_tree = self._get_project_tree(
            self._global_options.build_file_rev)
        self._build_file_parser = BuildFileParser(self._build_config,
                                                  self._root_dir)
        build_ignore_patterns = self._global_options.ignore_patterns or []
        build_ignore_patterns.extend(
            BuildFile._spec_excludes_to_gitignore_syntax(
                self._root_dir, self._global_options.spec_excludes))
        self._address_mapper = BuildFileAddressMapper(self._build_file_parser,
                                                      self._project_tree,
                                                      build_ignore_patterns)
        self._build_graph = BuildGraph(self._address_mapper)
        self._spec_parser = CmdLineSpecParser(
            self._root_dir,
            self._address_mapper,
            spec_excludes=self._spec_excludes,
            exclude_target_regexps=self._global_options.exclude_target_regexp)
示例#3
0
  def __init__(self, root_dir, options, build_config, run_tracker, reporting, exiter=sys.exit):
    """
    :param str root_dir: The root directory of the pants workspace (aka the "build root").
    :param Options options: The global, pre-initialized Options instance.
    :param BuildConfiguration build_config: A pre-initialized BuildConfiguration instance.
    :param Runtracker run_tracker: The global, pre-initialized/running RunTracker instance.
    :param Reporting reporting: The global, pre-initialized Reporting instance.
    :param func exiter: A function that accepts an exit code value and exits (for tests, Optional).
    """
    self._root_dir = root_dir
    self._options = options
    self._build_config = build_config
    self._run_tracker = run_tracker
    self._reporting = reporting
    self._exiter = exiter

    self._goals = []
    self._targets = []
    self._requested_goals = self._options.goals
    self._target_specs = self._options.target_specs
    self._help_request = self._options.help_request

    self._global_options = options.for_global_scope()
    self._tag = self._global_options.tag
    self._fail_fast = self._global_options.fail_fast
    # Will be provided through context.address_mapper.build_ignore_patterns.
    self._spec_excludes = None
    self._explain = self._global_options.explain
    self._kill_nailguns = self._global_options.kill_nailguns

    self._project_tree = self._get_project_tree(self._global_options.build_file_rev)
    self._build_file_parser = BuildFileParser(self._build_config, self._root_dir)
    build_ignore_patterns = self._global_options.ignore_patterns or []
    build_ignore_patterns.extend(BuildFile._spec_excludes_to_gitignore_syntax(self._root_dir,
                                                                              self._global_options.spec_excludes))
    self._address_mapper = BuildFileAddressMapper(self._build_file_parser, self._project_tree, build_ignore_patterns)
    self._build_graph = BuildGraph(self._address_mapper)
    self._spec_parser = CmdLineSpecParser(
      self._root_dir,
      self._address_mapper,
      spec_excludes=self._spec_excludes,
      exclude_target_regexps=self._global_options.exclude_target_regexp
    )
示例#4
0
文件: ide_gen.py 项目: caveness/pants
    def configure_project(self, targets, debug_port):
        jvm_targets = [t for t in targets if t.has_label("jvm") or t.has_label("java") or isinstance(t, Resources)]
        if self.intransitive:
            jvm_targets = set(self.context.target_roots).intersection(jvm_targets)

        build_ignore_patterns = self.context.options.for_global_scope().ignore_patterns or []
        build_ignore_patterns.extend(
            BuildFile._spec_excludes_to_gitignore_syntax(
                os.path.realpath(get_buildroot()), self.context.options.for_global_scope().spec_excludes
            )
        )

        project = Project(
            self.project_name,
            self.python,
            self.skip_java,
            self.skip_scala,
            self.use_source_root,
            get_buildroot(),
            debug_port,
            self.context,
            jvm_targets,
            not self.intransitive,
            self.TargetUtil(self.context),
            None,
            PathSpec.from_lines(GitIgnorePattern, build_ignore_patterns),
        )

        if self.python:
            python_source_paths = self.get_options().python_source_paths
            python_test_paths = self.get_options().python_test_paths
            python_lib_paths = self.get_options().python_lib_paths
            project.configure_python(python_source_paths, python_test_paths, python_lib_paths)

        extra_source_paths = self.get_options().extra_jvm_source_paths
        extra_test_paths = self.get_options().extra_jvm_test_paths
        all_targets = project.configure_jvm(extra_source_paths, extra_test_paths)
        return all_targets, project