Ejemplo n.º 1
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']
Ejemplo n.º 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 = {}
Ejemplo n.º 3
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)
Ejemplo n.º 4
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']
Ejemplo n.º 5
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
Ejemplo n.º 6
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()
Ejemplo n.º 7
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)
Ejemplo n.º 8
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']
Ejemplo n.º 9
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")
Ejemplo n.º 10
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')
Ejemplo n.º 11
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']
Ejemplo n.º 12
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 = {}
Ejemplo n.º 13
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
Ejemplo n.º 14
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')
Ejemplo n.º 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")
Ejemplo n.º 16
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")
Ejemplo n.º 17
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')
Ejemplo n.º 18
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
Ejemplo n.º 19
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')
Ejemplo n.º 20
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')
Ejemplo n.º 21
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)
Ejemplo n.º 22
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')
Ejemplo n.º 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')
Ejemplo n.º 24
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')
Ejemplo n.º 25
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')
Ejemplo n.º 26
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')
Ejemplo n.º 27
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
Ejemplo n.º 28
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
Ejemplo n.º 29
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')
Ejemplo n.º 30
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')
Ejemplo n.º 31
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
Ejemplo n.º 32
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))
Ejemplo n.º 33
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)
Ejemplo n.º 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')
   self.only_write_cmd_line = context.options.only_write_cmd_line
   context.products.require_data('exclusives_groups')
Ejemplo n.º 35
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)
Ejemplo n.º 36
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')
Ejemplo n.º 37
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')
Ejemplo n.º 38
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
Ejemplo n.º 39
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')
Ejemplo n.º 40
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
Ejemplo n.º 41
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
Ejemplo n.º 42
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')
Ejemplo n.º 43
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()
Ejemplo n.º 44
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
Ejemplo n.º 45
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
Ejemplo n.º 46
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
Ejemplo n.º 47
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('wiki_html')
    self._wiki = None
    self.user = context.options.confluence_user
Ejemplo n.º 48
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))
Ejemplo n.º 49
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()
Ejemplo n.º 50
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
Ejemplo n.º 51
0
 def __init__(self, context):
   Task.__init__(self, context)
   self.log = context.log
   self.target_roots = context.target_roots
Ejemplo n.º 52
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))
Ejemplo n.º 53
0
 def __init__(self, context, outstream=sys.stdout):
     Task.__init__(self, context)
     separator_option = "console_%s_separator" % self.__class__.__name__
     self._console_separator = getattr(
         context.options, separator_option).decode('string-escape')
     self._outstream = outstream
Ejemplo n.º 54
0
 def __init__(self, context):
   Task.__init__(self, context)
Ejemplo n.º 55
0
 def __init__(self, context, signal_error=None):
     Task.__init__(self, context)
     self.signal_error = (context.options.exclusives_error_on_collision
                          if signal_error is None else signal_error)
Ejemplo n.º 56
0
 def __init__(self, context):
     Task.__init__(self, context)
     self.outdir = context.config.getdefault('outdir')
     self.context.products.require('jars', predicate=is_java)
     self.context.products.require('jar_dependencies',
                                   predicate=self.is_oink_query)
Ejemplo n.º 57
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')
Ejemplo n.º 58
0
    def __init__(self, context):
        Task.__init__(self, context)

        self.outdir = context.config.get('jar-publish', 'workdir')
        self.cachedir = os.path.join(self.outdir, 'cache')

        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=context.config.getlist('jar-publish',
                                             'publish_local_confs',
                                             default=['*']),
                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('jar-publish', 'repos')
            self.commit = context.options.jar_publish_commit
            self.snapshot = False

        self.ivycp = context.config.getlist('ivy', 'classpath')
        self.ivysettings = context.config.get('ivy', '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 is_exported(target):
                            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_overrides:

            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_overrides)

        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')
        context.products.require('javadoc_jars')