Exemple #1
0
  def __init__(self, context):
    Task.__init__(self, context)

    options = context.options
    products = context.products

    self._output_dir = (options.jar_create_outdir or
                        self.get_workdir(section='jar-create', workdir='jars'))
    self.transitive = options.jar_create_transitive
    self.confs = context.config.getlist('jar-create', 'confs', default=DEFAULT_CONFS)
    self.compression = ZIP_DEFLATED if options.jar_create_compressed else ZIP_STORED

    self.jar_classes = options.jar_create_classes or products.isrequired('jars')
    if self.jar_classes:
      products.require_data('classes_by_target')
      products.require_data('resources_by_target')

    definitely_create_javadoc = options.jar_create_javadoc or products.isrequired('javadoc_jars')
    definitely_dont_create_javadoc = options.jar_create_javadoc is False
    create_javadoc = options.jar_create_javadoc
    if definitely_create_javadoc and definitely_dont_create_javadoc:
      self.context.log.warn('javadoc jars are required but you have requested they not be created, '
                            'creating anyway')
    self.jar_javadoc = (True if definitely_create_javadoc else
                        False if definitely_dont_create_javadoc else
                        create_javadoc)
    if self.jar_javadoc:
      products.require(javadoc.product_type)
      products.require(scaladoc.product_type)

    self.jar_sources = products.isrequired('source_jars') or options.jar_create_sources

    self._jars = {}
Exemple #2
0
 def __init__(self, context):
   Task.__init__(self, context)
   context.products.require('missing_deps')
   self.transitive = context.options.buildlint_transitive
   self.actions = set(context.options.buildlint_actions)
   self.include_intransitive = context.options.buildlint_include_intransitive
   # Manually apply the default. Can't use flag default, because action is 'append', so
   # diffs would always be printed, even if we only wanted to rewrite.
   if not self.actions:
     self.actions.add('diff')
Exemple #3
0
        def __init__(self, context):
          Task.__init__(self, context)

          if not args:
            self.action = lambda targets: action()
          elif len(args) == 1:
            self.action = lambda targets: action(self.context)
          elif len(args) == 2:
            self.action = lambda targets: action(self.context, targets)
          else:
            raise AssertionError('Unexpected fallthrough')
Exemple #4
0
 def __init__(self, context):
     Task.__init__(self, context)
     self.jvm_args = context.config.getlist("jvm-run", "jvm_args", default=[])
     if context.options.run_jvmargs:
         for arg in context.options.run_jvmargs:
             self.jvm_args.extend(shlex.split(arg))
     self.args = []
     if context.options.run_args:
         for arg in context.options.run_args:
             self.args.extend(shlex.split(arg))
     if context.options.run_debug:
         self.jvm_args.extend(context.config.getlist("jvm", "debug_args"))
     self.confs = context.config.getlist("jvm-run", "confs", default=["default"])
     self.only_write_cmd_line = context.options.only_write_cmd_line
     context.products.require_data("exclusives_groups")
Exemple #5
0
 def __init__(self, context):
   Task.__init__(self, context)
   self.jvm_args = context.config.getlist('scala-repl', 'jvm_args', default=[])
   if context.options.run_jvmargs:
     for arg in context.options.run_jvmargs:
       self.jvm_args.extend(shlex.split(arg))
   self.confs = context.config.getlist('scala-repl', 'confs', default=['default'])
   self._bootstrap_key = 'scala-repl'
   bootstrap_tools = context.config.getlist('scala-repl', 'bootstrap-tools')
   self._jvm_tool_bootstrapper.register_jvm_tool(self._bootstrap_key, bootstrap_tools)
   self.main = context.config.get('scala-repl', 'main')
   self.args = context.config.getlist('scala-repl', 'args', default=[])
   if context.options.run_args:
     for arg in context.options.run_args:
       self.args.extend(shlex.split(arg))
Exemple #6
0
  def check_artifact_cache(self, vts):
    # Special handling for scala analysis files. Class files are retrieved directly into their
    # final locations in the global classes dir.

    def post_process_cached_vts(cached_vts):
      # Merge the localized analysis with the global one (if any).
      analyses_to_merge = []
      for vt in cached_vts:
        for target in vt.targets:
          analysis_file = JvmCompile._analysis_for_target(self._analysis_tmpdir, target)
          portable_analysis_file = JvmCompile._portable_analysis_for_target(self._analysis_tmpdir,
                                                                            target)
          if os.path.exists(portable_analysis_file):
            self._analysis_tools.localize(portable_analysis_file, analysis_file)
          if os.path.exists(analysis_file):
            analyses_to_merge.append(analysis_file)

      if len(analyses_to_merge) > 0:
        if os.path.exists(self._analysis_file):
          analyses_to_merge.append(self._analysis_file)
        with contextutil.temporary_dir() as tmpdir:
          tmp_analysis = os.path.join(tmpdir, 'analysis')
          with self.context.new_workunit(name='merge_analysis'):
            self._analysis_tools.merge_from_paths(analyses_to_merge, tmp_analysis)
          self.move(tmp_analysis, self._analysis_file)

    self._ensure_analysis_tmpdir()
    return Task.do_check_artifact_cache(self, vts, post_process_cached_vts=post_process_cached_vts)
  def __init__(self, context):
    Task.__init__(self, context)

    self.url = (
      context.options.confluence_publish_url
      or context.config.get('confluence-publish', 'url')
    )

    if not self.url:
      raise TaskError("Unable to proceed publishing to confluence. Please configure a 'url' under "
                      "the 'confluence-publish' heading in pants.ini or using the %s command line "
                      "option." % self.url_option)

    self.force = context.options.confluence_publish_force
    self.open = context.options.confluence_publish_open
    self.context.products.require('wiki_html')
    self._wiki = None
    self.user = context.options.confluence_user
Exemple #8
0
  def setup_parser(cls, option_group, args, mkflag):
    Task.setup_parser(option_group, args, mkflag)

    option_group.add_option(mkflag("transitive"), mkflag("transitive", negate=True),
      dest="buildlint_transitive", default=False,
      action="callback", callback=mkflag.set_bool,
      help="[%default] apply lint rules transitively to all dependency buildfiles.")

    option_group.add_option(mkflag("include-intransitive-deps"),
      mkflag("include-intransitive-deps", negate=True),
      dest="buildlint_include_intransitive", default=False,
      action="callback", callback=mkflag.set_bool,
      help="[%default] correct both simple missing dependencies and intransitive missing deps")


    option_group.add_option(mkflag("action"), dest="buildlint_actions", default=[],
      action="append", type="choice", choices=['diff', 'rewrite'],
      help="diff=print out diffs, rewrite=apply changes to BUILD files directly.")
Exemple #9
0
 def __init__(self, context):
   Task.__init__(self, context)
   self.ivy_utils = IvyUtils(config=context.config,
                             options=context.options,
                             log=context.log)
   self.confs = context.config.getlist('ivy', 'confs', default=['default'])
   self.target_roots = context.target_roots
   self.transitive = context.options.provides_transitive
   self.workdir = context.config.get('provides', 'workdir')
   self.outdir = context.options.provides_outdir or self.workdir
   self.also_write_to_stdout = context.options.provides_also_write_to_stdout or False
   # Create a fake target, in case we were run directly on a JarLibrary containing nothing but JarDependencies.
   # TODO(benjy): Get rid of this special-casing of jar dependencies.
   context.add_new_target(self.workdir,
     JvmBinary,
     name='provides',
     dependencies=self.target_roots,
     configurations=self.confs)
   context.products.require('jars')
Exemple #10
0
  def __init__(self, context):
    Task.__init__(self, context)

    self.open = context.options.markdown_to_html_open

    pants_workdir = context.config.getdefault('pants_workdir')
    self.outdir = (
      context.options.markdown_to_html_outdir
      or context.config.get('markdown-to-html',
                            'workdir',
                            default=os.path.join(pants_workdir, 'markdown'))
    )

    self.extensions = set(
      context.options.markdown_to_html_extensions
      or context.config.getlist('markdown-to-html', 'extensions', default=['.md', '.markdown'])
    )

    self.fragment = context.options.markdown_to_html_fragment

    self.code_style = context.config.get('markdown-to-html', 'code-style', default='friendly')
    if hasattr(context.options, 'markdown_to_html_code_style'):
      if context.options.markdown_to_html_code_style:
        self.code_style = context.options.markdown_to_html_code_style
Exemple #11
0
 def __init__(self, context):
   Task.__init__(self, context)
Exemple #12
0
  def __init__(self, context, scm=None):
    Task.__init__(self, context)
    ScmPublish.__init__(self, scm or get_scm(),
                        self.context.config.getlist(
                          JarPublish._CONFIG_SECTION, 'restrict_push_branches'))
    self.outdir = os.path.join(context.config.getdefault('pants_workdir'), 'publish')
    self.cachedir = os.path.join(self.outdir, 'cache')

    self._jvmargs = context.config.getlist(JarPublish._CONFIG_SECTION, 'ivy_jvmargs', default=[])

    if context.options.jar_publish_local:
      local_repo = dict(
        resolver='publish_local',
        path=os.path.abspath(os.path.expanduser(context.options.jar_publish_local)),
        confs=['*'],
        auth=None
      )
      self.repos = defaultdict(lambda: local_repo)
      self.commit = False
      self.snapshot = context.options.jar_publish_local_snapshot
    else:
      self.repos = context.config.getdict(JarPublish._CONFIG_SECTION, 'repos')
      if not self.repos:
        raise TaskError("This repo is not yet set for publishing to the world! Please re-run with --publish-local")
      for repo, data in self.repos.items():
        auth = data.get('auth')
        if auth:
          credentials = context.resolve(auth).next()
          user = credentials.username(data['resolver'])
          password = credentials.password(data['resolver'])
          self.context.log.debug('Found auth for repo=%s user=%s' % (repo, user))
          self.repos[repo]['username'] = user
          self.repos[repo]['password'] = password
      self.commit = context.options.jar_publish_commit
      self.snapshot = False

    self.ivycp = context.config.getlist('ivy', 'classpath')
    self.ivysettings = context.config.get('jar-publish', 'ivy_settings')

    self.dryrun = context.options.jar_publish_dryrun
    self.transitive = context.options.jar_publish_transitive
    self.force = context.options.jar_publish_force

    def parse_jarcoordinate(coordinate):
      components = coordinate.split('#', 1)
      if len(components) == 2:
        org, name = components
        return org, name
      else:
        try:
          address = Address.parse(get_buildroot(), coordinate)
          try:
            target = Target.get(address)
            if not target:
              siblings = Target.get_all_addresses(address.buildfile)
              prompt = 'did you mean' if len(siblings) == 1 else 'maybe you meant one of these'
              raise TaskError('%s => %s?:\n    %s' % (address, prompt,
                                                      '\n    '.join(str(a) for a in siblings)))
            if not target.is_exported:
              raise TaskError('%s is not an exported target' % coordinate)
            return target.provides.org, target.provides.name
          except (ImportError, SyntaxError, TypeError):
            raise TaskError('Failed to parse %s' % address.buildfile.relpath)
        except IOError:
          raise TaskError('No BUILD file could be found at %s' % coordinate)

    self.overrides = {}
    if context.options.jar_publish_override:
      def parse_override(override):
        try:
          coordinate, rev = override.split('=', 1)
          try:
            rev = Semver.parse(rev)
          except ValueError as e:
            raise TaskError('Invalid version %s: %s' % (rev, e))
          return parse_jarcoordinate(coordinate), rev
        except ValueError:
          raise TaskError('Invalid override: %s' % override)

      self.overrides.update(parse_override(o) for o in context.options.jar_publish_override)

    self.restart_at = None
    if context.options.jar_publish_restart_at:
      self.restart_at = parse_jarcoordinate(context.options.jar_publish_restart_at)

    context.products.require('jars')
    context.products.require('source_jars')
  def __init__(self, context):
    Task.__init__(self, context)

    self.workdir = context.config.get('prepare-resources', 'workdir')
    self.confs = context.config.getlist('prepare-resources', 'confs', default=['default'])
    self.context.products.require_data('exclusives_groups')