Example #1
0
  def __init__(self, context, output_dir=None, confs=None):
    Task.__init__(self, context)

    self._output_dir = (
      output_dir
      or context.options.jar_create_outdir
      or context.config.get('jar-create', 'workdir')
    )
    self.transitive = context.options.jar_create_transitive
    self.confs = confs or context.config.getlist('jar-create', 'confs')
    self.compression = ZIP_DEFLATED if context.options.jar_create_compressed else ZIP_STORED

    self.jar_classes = context.options.jar_create_classes or context.products.isrequired('jars')
    if self.jar_classes:
      self.context.products.require('classes')

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

    self.jar_javadoc = (
      context.options.jar_create_javadoc
      or context.products.isrequired('javadoc_jars')
    )
    if self.jar_javadoc:
      context.products.require('javadoc')
Example #2
0
  def __init__(self, context):
    Task.__init__(self, context)

    options = context.options
    products = context.products

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

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

    self.jar_idl = products.isrequired('idl_jars') or options.jar_create_idl
    if self.jar_idl:
      products.require('idl')

    self.jar_javadoc = products.isrequired('javadoc_jars') or options.jar_create_javadoc
    if self.jar_javadoc:
      products.require('javadoc')

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

    self._jars = {}
Example #3
0
    def __init__(self, context):
        Task.__init__(self, context)
        config = context.config
        self.confs = config.getlist('benchmark-run', 'confs')
        self.java_args = config.getlist(
            'benchmark-run',
            'args',
            default=['-Xmx1g', '-XX:MaxPermSize=256m'])

        self._benchmark_bootstrap_key = 'benchmark-tool'
        benchmark_bootstrap_tools = config.getlist(
            'benchmark-run',
            'bootstrap-tools',
            default=[':benchmark-caliper-0.5'])
        self._bootstrap_utils.register_jvm_build_tools(
            self._benchmark_bootstrap_key, benchmark_bootstrap_tools)
        self._agent_bootstrap_key = 'benchmark-agent'
        agent_bootstrap_tools = config.getlist(
            'benchmark-run',
            'agent_profile',
            default=[':benchmark-java-allocation-instrumenter-2.1'])
        self._bootstrap_utils.register_jvm_build_tools(
            self._agent_bootstrap_key, agent_bootstrap_tools)

        # TODO(Steve Gury):
        # Find all the target classes from the Benchmark target itself
        # https://jira.twitter.biz/browse/AWESOME-1938
        self.caliper_args = context.options.target_class

        if context.options.memory_profiling:
            self.caliper_args += ['--measureMemory']

        if context.options.debug:
            self.java_args.extend(context.config.getlist('jvm', 'debug_args'))
            self.caliper_args += ['--debug']
Example #4
0
  def __init__(self, context, classpath=None, workdir=None):
    Task.__init__(self, context)

    self._classpath = classpath
    self._nailgun_bootstrap_key = 'nailgun'
    nailgun_bootstrap_tools = context.config.getlist('nailgun', 'bootstrap-tools',
                                                     default=[':nailgun-server'])

    self._bootstrap_utils.register_jvm_build_tools(self._nailgun_bootstrap_key, nailgun_bootstrap_tools)

    self._ng_server_args = context.config.getlist('nailgun', 'args')
    self._daemon = context.options.nailgun_daemon

    workdir = workdir or context.config.get('nailgun', 'workdir')

    # Allows us to identify the nailgun process by its cmd-line.
    self._identifier_arg = '-Dpants.ng.identifier=%s' % os.path.relpath(workdir, get_buildroot())

    self._current_pidport = None

    self._ng_out = os.path.join(workdir, 'stdout')
    self._ng_err = os.path.join(workdir, 'stderr')

    # Prevent concurrency issues when starting up a nailgun.
    self._spawn_lock = threading.Lock()
Example #5
0
  def __init__(self, context):
    Task.__init__(self, context)

    options = context.options
    products = context.products

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

    self.jar_classes = products.isrequired('jars') or options.jar_create_classes
    if self.jar_classes:
      products.require('classes')

    self.jar_idl = products.isrequired('idl_jars') or options.jar_create_idl
    if self.jar_idl:
      products.require('idl')

    self.jar_javadoc = products.isrequired('javadoc_jars') or options.jar_create_javadoc
    if self.jar_javadoc:
      products.require('javadoc')

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

    self._jars = {}
Example #6
0
  def __init__(self, context):
    Task.__init__(self, context)
    config = context.config
    self.confs = config.getlist('benchmark-run', 'confs')
    self.jvm_options = config.getlist('benchmark-run', 'args',
                                      default=['-Xmx1g', '-XX:MaxPermSize=256m'])

    self._benchmark_bootstrap_key = 'benchmark-tool'
    benchmark_bootstrap_tools = config.getlist('benchmark-run', 'bootstrap-tools',
                                               default=[':benchmark-caliper-0.5'])
    self._jvm_tool_bootstrapper.register_jvm_tool(self._benchmark_bootstrap_key, benchmark_bootstrap_tools)
    self._agent_bootstrap_key = 'benchmark-agent'
    agent_bootstrap_tools = config.getlist('benchmark-run', 'agent_profile',
                                           default=[':benchmark-java-allocation-instrumenter-2.1'])
    self._jvm_tool_bootstrapper.register_jvm_tool(self._agent_bootstrap_key, agent_bootstrap_tools)

    # TODO(Steve Gury):
    # Find all the target classes from the Benchmark target itself
    # https://jira.twitter.biz/browse/AWESOME-1938
    self.caliper_args = context.options.target_class

    if context.options.memory_profiling:
      self.caliper_args += ['--measureMemory']

    if context.options.debug:
      self.jvm_options.extend(context.config.getlist('jvm', 'debug_args'))
      self.caliper_args += ['--debug']
Example #7
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."
        )
Example #8
0
  def __init__(self, context):
    Task.__init__(self, context)
    self.profile = context.config.get('benchmark-run', 'profile',
                                      default="benchmark-caliper-0.5")
    self.confs = context.config.getlist('benchmark-run', 'confs')
    self.java_args = context.config.getlist('benchmark-run', 'args',
                                            default=['-Xmx1g', '-XX:MaxPermSize=256m'])
    self.agent_profile = context.config.get('benchmark-run', 'agent_profile',
                                            default="benchmark-java-allocation-instrumenter-2.1")
    # TODO(Steve Gury):
    # Find all the target classes from the Benchmark target itself
    # https://jira.twitter.biz/browse/AWESOME-1938
    self.caliper_args = context.options.target_class

    if context.options.memory_profiling:
      self.caliper_args += ['--measureMemory']
      # For rewriting JDK classes to work, the JAR file has to be listed specifically in
      # the JAR manifest as something that goes in the bootclasspath.
      # The MANIFEST list a jar 'allocation.jar' this is why we have to rename it
      agent_jar = os.readlink(profile_classpath(self.agent_profile)[0])
      allocation_jar = os.path.join(os.path.dirname(agent_jar), "allocation.jar")
      # TODO(Steve Gury): Find a solution to avoid copying the jar every run and being resilient
      # to version upgrade
      shutil.copyfile(agent_jar, allocation_jar)
      os.environ['ALLOCATION_JAR'] = str(allocation_jar)

    if context.options.debug:
      self.java_args.extend(context.config.getlist('jvm', 'debug_args'))
      self.caliper_args += ['--debug']
Example #9
0
  def __init__(self, context):
    Task.__init__(self, context)

    self.confs = context.config.getlist('junit-run', 'confs')
    self.profile = context.config.get('junit-run', 'profile')

    self.java_args = context.config.getlist('junit-run', 'args', default=[])
    if context.options.junit_run_jvmargs:
      self.java_args.extend(context.options.junit_run_jvmargs)
    if context.options.junit_run_debug:
      self.java_args.extend(context.config.getlist('jvm', 'debug_args'))

    self.test_classes = context.options.junit_run_tests
    self.context.products.require('classes')

    self.outdir = (
      context.options.junit_run_outdir
      or context.config.get('junit-run', 'workdir')
    )

    self.flags = []
    if context.options.junit_run_xmlreport or context.options.junit_run_suppress_output:
      if context.options.junit_run_xmlreport:
        self.flags.append('-xmlreport')
      self.flags.append('-suppress-output')
      self.flags.append('-outdir')
      self.flags.append(self.outdir)
Example #10
0
  def __init__(self, context, output_dir=None, version=None, java_geninfo=None, python_geninfo=None,
               strict=None, verbose=None):

    Task.__init__(self, context)

    self.thrift_binary = select_binary(
      context.config.get('thrift-gen', 'supportdir'),
      version or context.config.get('thrift-gen', 'version'),
      'thrift'
    )
    self.output_dir = (
      output_dir
      or context.options.thrift_gen_create_outdir
      or context.config.get('thrift-gen', 'workdir')
    )
    self.strict = strict or context.config.getbool('thrift-gen', 'strict')
    self.verbose = verbose or context.config.getbool('thrift-gen', 'verbose')

    def create_geninfo(key):
      gen_info = context.config.getdict('thrift-gen', key)
      gen = gen_info['gen']
      deps = OrderedSet()
      for dep in gen_info['deps']:
        deps.update(context.resolve(dep))
      return ThriftGen.GenInfo(gen, deps)

    self.gen_java = java_geninfo or create_geninfo('java')
    self.gen_python = python_geninfo or create_geninfo('python')
    self.gen_langs = set(context.options.thrift_gen_langs)
Example #11
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
Example #12
0
    def __init__(self, context):
        Task.__init__(self, context)
        self.profile = context.config.get('benchmark-run',
                                          'profile',
                                          default="benchmark-caliper-0.5")
        self.confs = context.config.getlist('benchmark-run', 'confs')
        self.java_args = context.config.getlist(
            'benchmark-run',
            'args',
            default=['-Xmx1g', '-XX:MaxPermSize=256m'])
        self.agent_profile = context.config.get(
            'benchmark-run',
            'agent_profile',
            default="benchmark-java-allocation-instrumenter-2.1")
        # TODO(Steve Gury):
        # Find all the target classes from the Benchmark target itself
        # https://jira.twitter.biz/browse/AWESOME-1938
        self.caliper_args = context.options.target_class

        if context.options.memory_profiling:
            self.caliper_args += ['--measureMemory']
            # For rewriting JDK classes to work, the JAR file has to be listed specifically in
            # the JAR manifest as something that goes in the bootclasspath.
            # The MANIFEST list a jar 'allocation.jar' this is why we have to rename it
            agent_jar = os.readlink(profile_classpath(self.agent_profile)[0])
            allocation_jar = os.path.join(os.path.dirname(agent_jar),
                                          "allocation.jar")
            # TODO(Steve Gury): Find a solution to avoid copying the jar every run and being resilient
            # to version upgrade
            shutil.copyfile(agent_jar, allocation_jar)
            os.environ['ALLOCATION_JAR'] = str(allocation_jar)

        if context.options.debug:
            self.java_args.extend(context.config.getlist('jvm', 'debug_args'))
            self.caliper_args += ['--debug']
Example #13
0
    def __init__(
        self,
        context,
        classpath=None,
        workdir=None,
        nailgun_jar=None,
        args=None,
        stdin=None,
        stderr=sys.stderr,
        stdout=sys.stdout,
    ):
        Task.__init__(self, context)

        self._classpath = classpath
        self._nailgun_jar = nailgun_jar or context.config.get("nailgun", "jar")
        self._ng_server_args = args or context.config.getlist("nailgun", "args")
        self._stdin = stdin
        self._stderr = stderr
        self._stdout = stdout
        self._daemon = context.options.nailgun_daemon

        workdir = workdir or context.config.get("nailgun", "workdir")
        self._pidfile = os.path.join(workdir, "pid")
        self._ng_out = os.path.join(workdir, "stdout")
        self._ng_err = os.path.join(workdir, "stderr")
Example #14
0
  def __init__(self, context):
    Task.__init__(self, context)

    self.confs = context.config.getlist('junit-run', 'confs')
    self.junit_profile = context.config.get('junit-run', 'junit_profile')
    self.emma_profile = context.config.get('junit-run', 'emma_profile')

    self.junit_runner = (
      context.options.junit_runner
      or context.config.get('junit-run', 'runner',
                            default='com.twitter.common.testing.runner.JUnitConsoleRunner')
    )

    self.java_args = context.config.getlist('junit-run', 'args', default=[])
    if context.options.junit_run_jvmargs:
      self.java_args.extend(context.options.junit_run_jvmargs)
    if context.options.junit_run_debug:
      self.java_args.extend(context.config.getlist('jvm', 'debug_args'))

    self.test_classes = context.options.junit_run_tests
    self.context.products.require('classes')

    self.outdir = (
      context.options.junit_run_outdir
      or context.config.get('junit-run', 'workdir')
    )

    self.coverage = context.options.junit_run_coverage
    self.coverage_filters = context.options.junit_run_coverage_patterns or []
    self.coverage_dir = os.path.join(self.outdir, 'coverage')
    self.coverage_instrument_dir = os.path.join(self.coverage_dir, 'classes')
    self.coverage_metadata_file = os.path.join(self.coverage_dir, 'coverage.em')
    self.coverage_file = os.path.join(self.coverage_dir, 'coverage.ec')

    self.coverage_report_console = context.options.junit_run_coverage_console
    self.coverage_console_file = os.path.join(self.coverage_dir, 'coverage.txt')

    self.coverage_report_xml = context.options.junit_run_coverage_xml
    self.coverage_xml_file = os.path.join(self.coverage_dir, 'coverage.xml')

    self.coverage_report_html_open = context.options.junit_run_coverage_html_open
    self.coverage_report_html = (
      self.coverage_report_html_open
      or context.options.junit_run_coverage_html
    )
    self.coverage = self.coverage or self.coverage_report_html_open
    self.coverage_html_file = os.path.join(self.coverage_dir, 'html', 'index.html')

    self.flags = []
    if context.options.junit_run_xmlreport or context.options.junit_run_suppress_output:
      if context.options.junit_run_fail_fast:
        self.flags.append('-fail-fast')
      if context.options.junit_run_xmlreport:
        self.flags.append('-xmlreport')
      self.flags.append('-suppress-output')
      self.flags.append('-outdir')
      self.flags.append(self.outdir)

    self.only_write_cmd_line = context.options.only_write_cmd_line
Example #15
0
    def __init__(self, context):
        Task.__init__(self, context)

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

        self.force = context.options.confluence_publish_force
        self.open = context.options.confluence_publish_open
        self.context.products.require("markdown_html")
Example #16
0
    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')
 def setup_parser(cls, option_group, args, mkflag):
   Task.setup_parser(option_group, args, mkflag)
   option_group.add_option(mkflag('error_on_collision'),
                           mkflag('error_on_collision', negate=True),
                           dest='exclusives_error_on_collision', default=True,
                           action='callback', callback=mkflag.set_bool,
                           help=("[%default] Signal an error and abort the build if an " +
                                 "exclusives collision is detected"))
Example #18
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')
   self.profile = context.config.get('scala-repl', 'profile')
   self.main = context.config.get('scala-repl', 'main')
Example #19
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")
     self.profile = context.config.get("scala-repl", "profile")
     self.main = context.config.get("scala-repl", "main")
Example #20
0
    def __init__(self, context, output_dir=None, confs=None):
        Task.__init__(self, context)

        self._output_dir = (output_dir or context.options.javadoc_gen_outdir
                            or context.config.get('javadoc-gen', 'workdir'))
        self.transitive = context.options.javadoc_gen_transitive
        self.confs = confs or context.config.getlist('javadoc-gen', 'confs')
        self.open = context.options.javadoc_gen_open
        self.combined = self.open or context.options.javadoc_gen_combined
Example #21
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)
   # 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')
Example #22
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.builtlint_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')
Example #23
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')
     self.profile = context.config.get('scala-repl', 'profile')
     self.main = context.config.get('scala-repl', 'main')
Example #24
0
    def __init__(self, context):
        Task.__init__(self, context)

        self.confs = context.config.getlist('junit-run', 'confs')
        self.junit_profile = context.config.get('junit-run', 'junit_profile')
        self.emma_profile = context.config.get('junit-run', 'emma_profile')

        self.java_args = context.config.getlist('junit-run',
                                                'args',
                                                default=[])
        if context.options.junit_run_jvmargs:
            self.java_args.extend(context.options.junit_run_jvmargs)
        if context.options.junit_run_debug:
            self.java_args.extend(context.config.getlist('jvm', 'debug_args'))

        self.test_classes = context.options.junit_run_tests
        self.context.products.require('classes')

        self.outdir = (context.options.junit_run_outdir
                       or context.config.get('junit-run', 'workdir'))

        self.coverage = context.options.junit_run_coverage
        self.coverage_filters = context.options.junit_run_coverage_patterns or []
        self.coverage_dir = os.path.join(self.outdir, 'coverage')
        self.coverage_instrument_dir = os.path.join(self.coverage_dir,
                                                    'classes')
        self.coverage_metadata_file = os.path.join(self.coverage_dir,
                                                   'coverage.em')
        self.coverage_file = os.path.join(self.coverage_dir, 'coverage.ec')

        self.coverage_report_console = context.options.junit_run_coverage_console
        self.coverage_console_file = os.path.join(self.coverage_dir,
                                                  'coverage.txt')

        self.coverage_report_xml = context.options.junit_run_coverage_xml
        self.coverage_xml_file = os.path.join(self.coverage_dir,
                                              'coverage.xml')

        self.coverage_report_html_open = context.options.junit_run_coverage_html_open
        self.coverage_report_html = (self.coverage_report_html_open or
                                     context.options.junit_run_coverage_html)
        self.coverage = self.coverage or self.coverage_report_html_open
        self.coverage_html_file = os.path.join(self.coverage_dir, 'html',
                                               'index.html')

        self.flags = []
        if context.options.junit_run_xmlreport or context.options.junit_run_suppress_output:
            if context.options.junit_run_fail_fast:
                self.flags.append('-fail-fast')
            if context.options.junit_run_xmlreport:
                self.flags.append('-xmlreport')
            self.flags.append('-suppress-output')
            self.flags.append('-outdir')
            self.flags.append(self.outdir)
Example #25
0
  def __init__(self, context, classpath=None, workdir=None, nailgun_jar=None, args=None):
    Task.__init__(self, context)

    self._classpath = classpath
    self._nailgun_jar = nailgun_jar or context.config.get('nailgun', 'jar')
    self._ng_server_args = args or context.config.getlist('nailgun', 'args')

    workdir = workdir or context.config.get('nailgun', 'workdir')
    self._pidfile = os.path.join(workdir, 'pid')
    self._ng_out = os.path.join(workdir, 'stdout')
    self._ng_err = os.path.join(workdir, 'stderr')
Example #26
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("action"), dest="buildlint_actions", default=[],
      action="append", type="choice", choices=['diff', 'rewrite'],
      help="diff=print out diffs, rewrite=apply changes to BUILD files directly.")
Example #27
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')
Example #28
0
 def setup_parser(cls, option_group, args, mkflag):
     Task.setup_parser(option_group, args, mkflag)
     option_group.add_option(
         mkflag('error_on_collision'),
         mkflag('error_on_collision', negate=True),
         dest='exclusives_error_on_collision',
         default=True,
         action='callback',
         callback=mkflag.set_bool,
         help=("[%default] Signal an error and abort the build if an " +
               "exclusives collision is detected"))
Example #29
0
  def __init__(self, context):
    Task.__init__(self, context)

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

    self.force = context.options.confluence_publish_force
    self.open = context.options.confluence_publish_open
    self.context.products.require('markdown_html')
    self._wiki = None
Example #30
0
  def __init__(self, context, classpath=None, workdir=None):
    Task.__init__(self, context)

    self._classpath = classpath
    self._nailgun_profile = context.config.get('nailgun', 'profile', default='nailgun')
    self._ng_server_args = context.config.getlist('nailgun', 'args')
    self._daemon = context.options.nailgun_daemon

    workdir = workdir or context.config.get('nailgun', 'workdir')
    self._pidfile = os.path.join(workdir, 'pid')
    self._ng_out = os.path.join(workdir, 'stdout')
    self._ng_err = os.path.join(workdir, 'stderr')
Example #31
0
  def __init__(self, context, output_dir=None, confs=None):
    Task.__init__(self, context)

    self._output_dir = (
      output_dir
      or context.options.javadoc_gen_outdir
      or context.config.get('javadoc-gen', 'workdir')
    )
    self.transitive = context.options.javadoc_gen_transitive
    self.confs = confs or context.config.getlist('javadoc-gen', 'confs')
    self.open = context.options.javadoc_gen_open
    self.combined = self.open or context.options.javadoc_gen_combined
Example #32
0
  def __init__(self, context, classpath=None, workdir=None):
    Task.__init__(self, context)

    self._classpath = classpath
    self._nailgun_profile = context.config.get('nailgun', 'profile', default='nailgun')
    self._ng_server_args = context.config.getlist('nailgun', 'args')
    self._daemon = context.options.nailgun_daemon

    workdir = workdir or context.config.get('nailgun', 'workdir')
    self._pidfile = os.path.join(workdir, 'pid')
    self._ng_out = os.path.join(workdir, 'stdout')
    self._ng_err = os.path.join(workdir, 'stderr')
Example #33
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')
Example #34
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')
Example #35
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')
   self.only_write_cmd_line = context.options.only_write_cmd_line
Example #36
0
 def __init__(self, context):
   Task.__init__(self, context)
   self._jvm_options = context.config.getlist('scala-repl', 'jvm_args', default=[])
   if context.options.run_jvm_options:
     for arg in context.options.run_jvm_options:
       self._jvm_options.extend(shlex.split(arg))
   self.confs = context.config.getlist('scala-repl', 'confs')
   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))
Example #37
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')
   self.only_write_cmd_line = context.options.only_write_cmd_line
   context.products.require_data('exclusives_groups')
Example #38
0
  def __init__(self, context):
    Task.__init__(self, context)

    self.placeholders = {}
    compiled_idl = set()
    for jar, placeholders in self._PLACEHOLDERS_BY_JAR.items():
      # Any representative placeholder for the jar will do for resolving, the compiler, language,
      # etc. do not come into play here; so we pick just one to minimize resolves.
      representative = placeholders[0]
      compiled_idl.add(representative)
      self.placeholders[representative] = placeholders

    def is_compiled_idl(target):
      return target in compiled_idl
    context.products.require('idl_dependencies', predicate=is_compiled_idl)
Example #39
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')
          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)
Example #40
0
    def check_artifact_cache(self, vts):
        # Special handling for java artifacts.
        cached_vts, uncached_vts = Task.check_artifact_cache(self, vts)

        for vt in cached_vts:
            self.split_depfile(vt)
        return cached_vts, uncached_vts
Example #41
0
    def __init__(self, context):
        Task.__init__(self, context)

        self.placeholders = {}
        compiled_idl = set()
        for jar, placeholders in self._PLACEHOLDERS_BY_JAR.items():
            # Any representative placeholder for the jar will do for resolving, the compiler, language,
            # etc. do not come into play here; so we pick just one to minimize resolves.
            representative = placeholders[0]
            compiled_idl.add(representative)
            self.placeholders[representative] = placeholders

        def is_compiled_idl(target):
            return target in compiled_idl

        context.products.require('idl_dependencies', predicate=is_compiled_idl)
Example #42
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 = ScalaCompile._analysis_for_target(
                        self._analysis_tmpdir, target)
                    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')
                    if self._zinc_utils.run_zinc_merge(analyses_to_merge,
                                                       tmp_analysis):
                        raise TaskError(
                            'Zinc failed to merge cached analysis files.')
                    ZincUtils._copy_analysis(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)
Example #43
0
  def __init__(self, context, classpath=None, workdir=None, nailgun_jar=None, args=None,
               stdin=None, stderr=sys.stderr, stdout=sys.stdout):
    Task.__init__(self, context)

    self._classpath = classpath
    self._nailgun_jar = nailgun_jar or context.config.get('nailgun', 'jar')
    self._ng_server_args = args or context.config.getlist('nailgun', 'args')
    self._stdin = stdin
    self._stderr = stderr
    self._stdout = stdout
    self._daemon = context.options.nailgun_daemon

    workdir = workdir or context.config.get('nailgun', 'workdir')
    self._pidfile = os.path.join(workdir, 'pid')
    self._ng_out = os.path.join(workdir, 'stdout')
    self._ng_err = os.path.join(workdir, 'stderr')
Example #44
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 = ScalaCompile._analysis_for_target(self._analysis_tmpdir, target)
          portable_analysis_file = ScalaCompile._portable_analysis_for_target(self._analysis_tmpdir, target)
          if os.path.exists(portable_analysis_file):
            self._zinc_utils.localize_analysis_file(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')
          Analysis.merge_from_paths(analyses_to_merge, tmp_analysis)
          shutil.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)
Example #45
0
    def check_artifact_cache(self, vts):
        # Special handling for java artifacts.
        cached_vts, uncached_vts = Task.check_artifact_cache(self, vts)

        for vt in cached_vts:
            self.split_depfile(vt)
        return cached_vts, uncached_vts
Example #46
0
    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('markdown_html')
        self._wiki = None
        self.user = context.options.confluence_user
Example #47
0
  def __init__(self, context):
    Task.__init__(self, context)

    self.project_name = context.options.ide_gen_project_name
    self.python = context.options.ide_gen_python
    self.skip_java = not context.options.ide_gen_java
    self.skip_scala = not context.options.ide_gen_scala

    self.work_dir = (
      context.options.ide_gen_project_dir
      or os.path.join(
        context.config.get('ide', 'workdir'), self.__class__.__name__, self.project_name
      )
    )
    self.cwd = context.options.ide_gen_project_cwd or self.work_dir

    checkstyle_suppression_files = context.config.getdefault(
      'checkstyle_suppression_files', type=list, default=[]
    )
    debug_port = context.config.getint('ide', 'debug_port')

    self.classes_conf = context.config.get('ide', 'classes_conf')
    self.sources_conf = context.config.get('ide', 'sources_conf')

    scala_compiler_profile = None
    if not self.skip_scala:
      scala_compiler_profile = context.config.getdefault('scala_compile_profile')

    targets, self._project = self.configure_project(
      context.targets(),
      checkstyle_suppression_files,
      debug_port,
      scala_compiler_profile
    )

    self.configure_compile_context(targets)

    if self.python:
      self.context.products.require('python')
    if not self.skip_java:
      self.context.products.require('java')
    if not self.skip_scala:
      self.context.products.require('scala')

    self.context.products.require('jars')
    self.context.products.require('source_jars')
Example #48
0
  def __init__(self, context):
    Task.__init__(self, context)

    self.profile = context.config.get('specs-run', 'profile')
    self.confs = context.config.getlist('specs-run', 'confs')

    self.java_args = context.config.getlist('specs-run', 'args', default=[])
    if context.options.specs_run_jvmargs:
      self.java_args.extend(context.options.specs_run_jvmargs)
    if context.options.specs_run_debug:
      self.java_args.extend(context.config.getlist('jvm', 'debug_args'))

    self.skip = context.options.specs_run_skip
    self.color = context.options.specs_run_color

    classes = context.options.specs_run_tests
    self.tests = map(self.normalize, classes) if classes else None
Example #49
0
 def __init__(self, context):
   Task.__init__(self, context)
   self.ivy_utils = IvyUtils(context, context.config.get('ivy', 'cache_dir'))
   self.confs = context.config.getlist('ivy', 'confs')
   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')
Example #50
0
    def __init__(self, context):
        Task.__init__(self, context)

        self.open = context.options.markdown_to_html_open

        self.outdir = (context.options.markdown_to_html_outdir
                       or context.config.get('markdown-to-html', 'workdir'))

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

        self.standalone = context.options.markdown_to_html_standalone

        self.code_style = context.config.get('markdown-to-html', 'code-style')
        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
Example #51
0
 def __init__(self, context):
     Task.__init__(self, context)
     self.ivy_utils = IvyUtils(context,
                               context.config.get('ivy', 'cache_dir'))
     self.confs = context.config.getlist('ivy', 'confs')
     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')
Example #52
0
  def __init__(self, context):
    Task.__init__(self, context)

    self.profile = context.config.get('specs-run', 'profile')
    self.confs = context.config.getlist('specs-run', 'confs')

    self.java_args = context.config.getlist('specs-run', 'args', default=[])
    if context.options.specs_run_jvmargs:
      self.java_args.extend(context.options.specs_run_jvmargs)
    if context.options.specs_run_debug:
      self.java_args.extend(context.config.getlist('jvm', 'debug_args'))

    self.skip = context.options.specs_run_skip
    self.color = context.options.specs_run_color

    self.workdir = context.config.get('specs-run', 'workdir')

    self.tests = context.options.specs_run_tests
Example #53
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')
     self._bootstrap_key = 'scala-repl'
     bootstrap_tools = context.config.getlist('scala-repl',
                                              'bootstrap-tools')
     self._bootstrap_utils.register_jvm_build_tools(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))
Example #54
0
    def __init__(self, context, classpath=None, workdir=None):
        Task.__init__(self, context)

        self._classpath = classpath
        self._nailgun_profile = context.config.get('nailgun',
                                                   'profile',
                                                   default='nailgun')
        self._ng_server_args = context.config.getlist('nailgun', 'args')
        self._daemon = context.options.nailgun_daemon

        workdir = workdir or context.config.get('nailgun', 'workdir')

        # Allows us to identify the nailgun process by its cmd-line.
        self._identifier_arg = '-Dpants.ng.identifier=%s' % os.path.relpath(
            workdir, get_buildroot())

        self._ng_out = os.path.join(workdir, 'stdout')
        self._ng_err = os.path.join(workdir, 'stderr')

        # Prevent concurrency issues when starting up a nailgun.
        self._spawn_lock = threading.Lock()
Example #55
0
  def __init__(self, context):
    Task.__init__(self, context)

    self._specs_bootstrap_key = 'specs'
    bootstrap_tools = context.config.getlist('specs-run', 'bootstrap-tools',
                                             default=[':scala-specs-2.9.2'])
    self._bootstrap_utils.register_jvm_build_tools(self._specs_bootstrap_key, bootstrap_tools)
    
    self.confs = context.config.getlist('specs-run', 'confs')

    self.java_args = context.config.getlist('specs-run', 'args', default=[])
    if context.options.specs_run_jvmargs:
      self.java_args.extend(context.options.specs_run_jvmargs)
    if context.options.specs_run_debug:
      self.java_args.extend(context.config.getlist('jvm', 'debug_args'))

    self.skip = context.options.specs_run_skip
    self.color = context.options.specs_run_color

    self.workdir = context.config.get('specs-run', 'workdir')

    self.tests = context.options.specs_run_tests
Example #56
0
  def check_artifact_cache(self, vts):
    # Special handling for scala artifacts.
    cached_vts, uncached_vts = Task.check_artifact_cache(self, vts)

    if cached_vts:
      # Localize the portable analysis files.
      with self.context.new_workunit('localize', labels=[WorkUnit.MULTITOOL]):
        self._localize_portable_analysis_files(cached_vts)

      # Split any merged artifacts.
      for vt in cached_vts:
        if len(vt.targets) > 1:
          artifacts = [self._artifact_factory.artifact_for_target(t) for t in vt.targets]
          merged_artifact = self._artifact_factory.merged_artifact(artifacts)
          merged_artifact.split()
          for v in vt.versioned_targets:
            v.update()
    return cached_vts, uncached_vts
Example #57
0
    def check_artifact_cache(self, vts):
        # Special handling for scala artifacts.
        cached_vts, uncached_vts = Task.check_artifact_cache(self, vts)

        # Localize the portable analysis files.
        self._localize_portable_analysis_files(cached_vts)

        # Split any merged artifacts.
        for vt in cached_vts:
            if len(vt.targets) > 1:
                artifacts = [
                    self._artifact_factory.artifact_for_target(t)
                    for t in vt.targets
                ]
                merged_artifact = self._artifact_factory.merged_artifact(
                    artifacts)
                merged_artifact.split()
                for v in vt.versioned_targets:
                    v.update()
        return cached_vts, uncached_vts
Example #58
0
    def __init__(self, context):
        Task.__init__(self, context)

        context.products.require_data('exclusives_groups')

        self.confs = context.config.getlist('junit-run', 'confs')

        self._junit_bootstrap_key = 'junit'
        junit_bootstrap_tools = context.config.getlist('junit-run',
                                                       'junit-bootstrap-tools',
                                                       default=[':junit'])
        self._bootstrap_utils.register_jvm_build_tools(
            self._junit_bootstrap_key, junit_bootstrap_tools)

        self._emma_bootstrap_key = 'emma'
        emma_bootstrap_tools = context.config.getlist('junit-run',
                                                      'emma-bootstrap-tools',
                                                      default=[':emma'])
        self._bootstrap_utils.register_jvm_build_tools(
            self._emma_bootstrap_key, emma_bootstrap_tools)

        self.java_args = context.config.getlist('junit-run',
                                                'args',
                                                default=[])
        if context.options.junit_run_jvmargs:
            self.java_args.extend(context.options.junit_run_jvmargs)
        if context.options.junit_run_debug:
            self.java_args.extend(context.config.getlist('jvm', 'debug_args'))

        self.test_classes = context.options.junit_run_tests
        self.context.products.require('classes')

        self.outdir = (context.options.junit_run_outdir
                       or context.config.get('junit-run', 'workdir'))

        self.batch_size = context.options.junit_run_batch_size
        self.fail_fast = context.options.junit_run_fail_fast

        self.coverage = context.options.junit_run_coverage
        self.coverage_filters = context.options.junit_run_coverage_patterns or []
        self.coverage_dir = os.path.join(self.outdir, 'coverage')
        self.coverage_instrument_dir = os.path.join(self.coverage_dir,
                                                    'classes')
        self.coverage_metadata_file = os.path.join(self.coverage_dir,
                                                   'coverage.em')
        self.coverage_file = os.path.join(self.coverage_dir, 'coverage.ec')

        self.coverage_report_console = context.options.junit_run_coverage_console
        self.coverage_console_file = os.path.join(self.coverage_dir,
                                                  'coverage.txt')

        self.coverage_report_xml = context.options.junit_run_coverage_xml
        self.coverage_xml_file = os.path.join(self.coverage_dir,
                                              'coverage.xml')

        self.coverage_report_html_open = context.options.junit_run_coverage_html_open
        self.coverage_report_html = (self.coverage_report_html_open or
                                     context.options.junit_run_coverage_html)
        self.coverage = self.coverage or self.coverage_report_html_open
        self.coverage_html_file = os.path.join(self.coverage_dir, 'html',
                                               'index.html')

        self.opts = []
        if context.options.junit_run_xmlreport or context.options.junit_run_suppress_output:
            if self.fail_fast:
                self.opts.append('-fail-fast')
            if context.options.junit_run_xmlreport:
                self.opts.append('-xmlreport')
            self.opts.append('-suppress-output')
            self.opts.append('-outdir')
            self.opts.append(self.outdir)

        if context.options.junit_run_per_test_timer:
            self.opts.append('-per-test-timer')
        if context.options.junit_run_default_parallel:
            self.opts.append('-default-parallel')
        self.opts.append('-parallel-threads')
        self.opts.append(str(context.options.junit_run_parallel_threads))