当前位置: 首页>>代码示例>>Python>>正文


Python jvm_binary.JarRules类代码示例

本文整理汇总了Python中pants.backend.jvm.targets.jvm_binary.JarRules的典型用法代码示例。如果您正苦于以下问题:Python JarRules类的具体用法?Python JarRules怎么用?Python JarRules使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了JarRules类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_simple

 def test_simple(self):
   target = self.make_target(':foo', JvmBinary, main='com.example.Foo', basename='foo-base')
   self.assertEquals('com.example.Foo', target.main)
   self.assertEquals('com.example.Foo', target.payload.main)
   self.assertEquals('foo-base', target.basename)
   self.assertEquals('foo-base', target.payload.basename)
   self.assertEquals([], target.deploy_excludes)
   self.assertEquals([], target.payload.deploy_excludes)
   self.assertEquals(JarRules.default(), target.deploy_jar_rules)
   self.assertEquals(JarRules.default(), target.payload.deploy_jar_rules)
   self.assertEquals({}, target.payload.manifest_entries.entries)
开发者ID:benjyw,项目名称:pants,代码行数:11,代码来源:test_jvm_binary.py

示例2: test_simple

 def test_simple(self):
   self.add_to_build_file(
     '',
     'jvm_binary(name = "foo", main = "com.example.Foo", basename = "foo-base")',
   )
   target = self.target(':foo')
   self.assertEquals('com.example.Foo', target.main)
   self.assertEquals('com.example.Foo', target.payload.main)
   self.assertEquals('foo-base', target.basename)
   self.assertEquals('foo-base', target.payload.basename)
   self.assertEquals([], target.deploy_excludes)
   self.assertEquals([], target.payload.deploy_excludes)
   self.assertEquals(JarRules.default(), target.deploy_jar_rules)
   self.assertEquals(JarRules.default(), target.payload.deploy_jar_rules)
   self.assertEquals({}, target.payload.manifest_entries.entries)
开发者ID:baroquebobcat,项目名称:pants,代码行数:15,代码来源:test_jvm_binary.py

示例3: open_jar

  def open_jar(self, path, overwrite=False, compressed=True, jar_rules=None):
    """Yields a Jar that will be written when the context exits.

    :param string path: the path to the jar file
    :param bool overwrite: overwrite the file at ``path`` if it exists; ``False`` by default; ie:
      update the pre-existing jar at ``path``
    :param bool compressed: entries added to the jar should be compressed; ``True`` by default
    :param jar_rules: an optional set of rules for handling jar exclusions and duplicates
    """
    jar = Jar()
    try:
      yield jar
    except jar.Error as e:
      raise TaskError('Failed to write to jar at {}: {}'.format(path, e))

    with jar._render_jar_tool_args() as args:
      if args:  # Don't build an empty jar
        args.append('-update={}'.format(self._flag(not overwrite)))
        args.append('-compress={}'.format(self._flag(compressed)))

        jar_rules = jar_rules or JarRules.default()
        args.append('-default_action={}'.format(self._action_name(jar_rules.default_dup_action)))

        skip_patterns = []
        duplicate_actions = []

        for rule in jar_rules.rules:
          if isinstance(rule, Skip):
            skip_patterns.append(rule.apply_pattern)
          elif isinstance(rule, Duplicate):
            duplicate_actions.append('{}={}'.format(
              rule.apply_pattern.pattern, self._action_name(rule.action)))
          else:
            raise ValueError('Unrecognized rule: {}'.format(rule))

        if skip_patterns:
          args.append('-skip={}'.format(','.join(p.pattern for p in skip_patterns)))

        if duplicate_actions:
          args.append('-policies={}'.format(','.join(duplicate_actions)))

        args.append(path)

        # TODO(Eric Ayers): This needs to be migrated with some thought behind it.  Consider
        # that The jar-tool nailgun instance is shared between tasks and doesn't necessarily
        # need the same JVM args as its parent.
        jvm_options = self.context.config.getlist('jar-tool', 'jvm_args', default=['-Xmx64M'])
        self.runjava(self.tool_classpath('jar-tool'),
                     'com.twitter.common.jar.tool.Main',
                     jvm_options=jvm_options,
                     args=args,
                     workunit_name='jar-tool',
                     workunit_labels=[WorkUnit.TOOL, WorkUnit.JVM, WorkUnit.NAILGUN])
开发者ID:dominichamon,项目名称:pants,代码行数:53,代码来源:jar_task.py

示例4: open_jar

  def open_jar(self, path, overwrite=False, compressed=True, jar_rules=None):
    """Yields a Jar that will be written when the context exits.

    :param string path: the path to the jar file
    :param bool overwrite: overwrite the file at ``path`` if it exists; ``False`` by default; ie:
      update the pre-existing jar at ``path``
    :param bool compressed: entries added to the jar should be compressed; ``True`` by default
    :param jar_rules: an optional set of rules for handling jar exclusions and duplicates
    """
    jar = Jar()
    try:
      yield jar
    except jar.Error as e:
      raise TaskError('Failed to write to jar at %s: %s' % (path, e))

    with jar._render_jar_tool_args() as args:
      if args:  # Don't build an empty jar
        args.append('-update=%s' % self._flag(not overwrite))
        args.append('-compress=%s' % self._flag(compressed))

        jar_rules = jar_rules or JarRules.default()
        args.append('-default_action=%s' % self._action_name(jar_rules.default_dup_action))

        skip_patterns = []
        duplicate_actions = []

        for rule in jar_rules.rules:
          if isinstance(rule, Skip):
            skip_patterns.append(rule.apply_pattern)
          elif isinstance(rule, Duplicate):
            duplicate_actions.append('%s=%s' % (rule.apply_pattern.pattern,
                                                self._action_name(rule.action)))
          else:
            raise ValueError('Unrecognized rule: %s' % rule)

        if skip_patterns:
          args.append('-skip=%s' % ','.join(p.pattern for p in skip_patterns))

        if duplicate_actions:
          args.append('-policies=%s' % ','.join(duplicate_actions))

        args.append(path)

        jvm_args = self.context.config.getlist('jar-tool', 'jvm_args', default=['-Xmx64M'])
        self.runjava(self.tool_classpath(self._JAR_TOOL_CLASSPATH_KEY),
                     'com.twitter.common.jar.tool.Main',
                     jvm_options=jvm_args,
                     args=args,
                     workunit_name='jar-tool',
                     workunit_labels=[WorkUnit.TOOL, WorkUnit.JVM, WorkUnit.NAILGUN])
开发者ID:cheecheeo,项目名称:pants,代码行数:50,代码来源:jar_task.py

示例5: open_jar

    def open_jar(self, path, overwrite=False, compressed=True, jar_rules=None):
        """Yields a Jar that will be written when the context exits.

    :API: public

    :param string path: the path to the jar file
    :param bool overwrite: overwrite the file at ``path`` if it exists; ``False`` by default; ie:
      update the pre-existing jar at ``path``
    :param bool compressed: entries added to the jar should be compressed; ``True`` by default
    :param jar_rules: an optional set of rules for handling jar exclusions and duplicates
    """
        jar = Jar(path)
        try:
            yield jar
        except jar.Error as e:
            raise TaskError("Failed to write to jar at {}: {}".format(path, e))

        with jar._render_jar_tool_args(self.get_options()) as args:
            if args:  # Don't build an empty jar
                args.append("-update={}".format(self._flag(not overwrite)))
                args.append("-compress={}".format(self._flag(compressed)))

                jar_rules = jar_rules or JarRules.default()
                args.append("-default_action={}".format(self._action_name(jar_rules.default_dup_action)))

                skip_patterns = []
                duplicate_actions = []

                for rule in jar_rules.rules:
                    if isinstance(rule, Skip):
                        skip_patterns.append(rule.apply_pattern)
                    elif isinstance(rule, Duplicate):
                        duplicate_actions.append(
                            "{}={}".format(rule.apply_pattern.pattern, self._action_name(rule.action))
                        )
                    else:
                        raise ValueError("Unrecognized rule: {}".format(rule))

                if skip_patterns:
                    args.append("-skip={}".format(",".join(p.pattern for p in skip_patterns)))

                if duplicate_actions:
                    args.append("-policies={}".format(",".join(duplicate_actions)))

                args.append(path)

                if JarTool.global_instance().run(context=self.context, runjava=self.runjava, args=args):
                    raise TaskError("jar-tool failed")
开发者ID:ahamilton55,项目名称:pants,代码行数:48,代码来源:jar_task.py

示例6: test_set_bad_default

 def test_set_bad_default(self):
   with self.assertRaisesRegexp(ValueError, r'The default rules must be a JarRules'):
     JarRules.set_default(None)
开发者ID:benjyw,项目名称:pants,代码行数:3,代码来源:test_jvm_binary.py

示例7: test_default

 def test_default(self):
   jar_rules = JarRules.default()
   self.assertTrue(4, len(jar_rules.rules))
   for rule in jar_rules.rules:
     self.assertTrue(rule.apply_pattern.pattern.startswith(r'^META-INF'))
开发者ID:benjyw,项目名称:pants,代码行数:5,代码来源:test_jvm_binary.py


注:本文中的pants.backend.jvm.targets.jvm_binary.JarRules类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。