本文整理汇总了Python中pants.backend.jvm.subsystems.shader.Shader类的典型用法代码示例。如果您正苦于以下问题:Python Shader类的具体用法?Python Shader怎么用?Python Shader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Shader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: register_options
def register_options(cls, register):
super(JUnit, cls).register_options(register)
cls.register_jvm_tool(register,
'junit_library',
classpath=[
cls.LIBRARY_JAR,
])
cls.register_jvm_tool(register,
'junit',
classpath=[
cls._RUNNER_JAR,
],
main=cls.RUNNER_MAIN,
# TODO(John Sirois): Investigate how much less we can get away with.
# Clearly both tests and the runner need access to the same @Test,
# @Before, as well as other annotations, but there is also the Assert
# class and some subset of the @Rules, @Theories and @RunWith APIs.
custom_rules=[
Shader.exclude_package('junit.framework', recursive=True),
Shader.exclude_package('org.junit', recursive=True),
Shader.exclude_package('org.hamcrest', recursive=True),
Shader.exclude_package('org.pantsbuild.junit.annotations',
recursive=True),
])
示例2: register_options
def register_options(cls, register):
super(JUnitRun, cls).register_options(register)
register('--batch-size', advanced=True, type=int, default=sys.maxint,
help='Run at most this many tests in a single test process.')
register('--test', type=list,
help='Force running of just these tests. Tests can be specified using any of: '
'[classname], [classname]#[methodname], [filename] or [filename]#[methodname]')
register('--per-test-timer', type=bool, help='Show progress and timer for each test.')
register('--default-concurrency', advanced=True,
choices=junit_tests.VALID_CONCURRENCY_OPTS, default=junit_tests.CONCURRENCY_SERIAL,
help='Set the default concurrency mode for running tests not annotated with'
' @TestParallel or @TestSerial.')
register('--default-parallel', advanced=True, type=bool,
removal_hint='Use --concurrency instead.', removal_version='1.1.0',
help='Run classes without @TestParallel or @TestSerial annotations in parallel.')
register('--parallel-threads', advanced=True, type=int, default=0,
help='Number of threads to run tests in parallel. 0 for autoset.')
register('--test-shard', advanced=True,
help='Subset of tests to run, in the form M/N, 0 <= M < N. '
'For example, 1/3 means run tests number 2, 5, 8, 11, ...')
register('--output-mode', choices=['ALL', 'FAILURE_ONLY', 'NONE'], default='NONE',
help='Specify what part of output should be passed to stdout. '
'In case of FAILURE_ONLY and parallel tests execution '
'output can be partial or even wrong. '
'All tests output also redirected to files in .pants.d/test/junit.')
register('--cwd', advanced=True,
help='Set the working directory. If no argument is passed, use the build root. '
'If cwd is set on a target, it will supersede this argument.')
register('--strict-jvm-version', type=bool, advanced=True,
help='If true, will strictly require running junits with the same version of java as '
'the platform -target level. Otherwise, the platform -target level will be '
'treated as the minimum jvm to run.')
register('--failure-summary', type=bool, default=True,
help='If true, includes a summary of which test-cases failed at the end of a failed '
'junit run.')
register('--allow-empty-sources', type=bool, advanced=True,
help='Allows a junit_tests() target to be defined with no sources. Otherwise,'
'such a target will raise an error during the test run.')
register('--use-experimental-runner', type=bool, advanced=True,
help='Use experimental junit-runner logic for more options for parallelism.')
cls.register_jvm_tool(register,
'junit',
classpath=[
JarDependency(org='org.pantsbuild', name='junit-runner', rev='1.0.7'),
],
main=JUnitRun._MAIN,
# TODO(John Sirois): Investigate how much less we can get away with.
# Clearly both tests and the runner need access to the same @Test,
# @Before, as well as other annotations, but there is also the Assert
# class and some subset of the @Rules, @Theories and @RunWith APIs.
custom_rules=[
Shader.exclude_package('junit.framework', recursive=True),
Shader.exclude_package('org.junit', recursive=True),
Shader.exclude_package('org.hamcrest', recursive=True),
Shader.exclude_package('org.pantsbuild.junit.annotations', recursive=True),
])
# TODO: Yuck, but will improve once coverage steps are in their own tasks.
for c in [Coverage, Cobertura]:
c.register_options(register, cls.register_jvm_tool)
示例3: test_assemble_default_rules_default_package
def test_assemble_default_rules_default_package(self):
input_jar = self.populate_input_jar('main.class', 'com/google/common/base/Function.class')
rules = self.shader.assemble_binary_rules('main', input_jar)
self.assertEqual(Shader.exclude_package(), rules[0])
self.assertIn(Shader.exclude_package('javax.annotation'), rules[1:-1])
self.assertEqual(Shader.shade_package('com.google.common.base'), rules[-1])
示例4: test_assemble_classes_in_meta_inf
def test_assemble_classes_in_meta_inf(self):
input_jar = self.populate_input_jar('org/pantsbuild/tools/fake/Main.class',
'META-INF/versions/9/javax/xml/bind/ModuleInfo.class')
rules = self.shader.assemble_binary_rules('org.pantsbuild.tools.fake.Main', input_jar)
self.assertEqual(Shader.exclude_package('org.pantsbuild.tools.fake'), rules[0])
self.assertIn(Shader.exclude_package('javax', recursive=True), rules[1:])
self.assertNotIn(Shading.create_relocate('META-INF.versions.9.javax.xml.bind.*'), rules[1:])
示例5: test_assemble_default_rules
def test_assemble_default_rules(self):
input_jar = self.populate_input_jar('org/pantsbuild/tools/fake/Main.class',
'com/google/common/base/Function.class')
rules = self.shader.assemble_binary_rules('org.pantsbuild.tools.fake.Main', input_jar)
self.assertEqual(Shader.exclude_package('org.pantsbuild.tools.fake'), rules[0])
self.assertIn(Shader.exclude_package('javax.annotation'), rules[1:-1])
self.assertEqual(Shader.shade_package('com.google.common.base'), rules[-1])
示例6: register_options
def register_options(cls, register):
super(Zinc.Factory, cls).register_options(register)
zinc_rev = '1.0.3'
shader_rules = [
# The compiler-interface and compiler-bridge tool jars carry xsbt and
# xsbti interfaces that are used across the shaded tool jar boundary so
# we preserve these root packages wholesale along with the core scala
# APIs.
Shader.exclude_package('scala', recursive=True),
Shader.exclude_package('xsbt', recursive=True),
Shader.exclude_package('xsbti', recursive=True),
# Unfortunately, is loaded reflectively by the compiler.
Shader.exclude_package('org.apache.logging.log4j', recursive=True),
]
cls.register_jvm_tool(register,
Zinc.ZINC_COMPILER_TOOL_NAME,
classpath=[
JarDependency('org.pantsbuild', 'zinc-compiler_2.11', '0.0.5'),
],
main=Zinc.ZINC_COMPILE_MAIN,
custom_rules=shader_rules)
cls.register_jvm_tool(register,
'compiler-bridge',
classpath=[
ScalaJarDependency(org='org.scala-sbt',
name='compiler-bridge',
rev=zinc_rev,
classifier='sources',
intransitive=True),
])
cls.register_jvm_tool(register,
'compiler-interface',
classpath=[
JarDependency(org='org.scala-sbt',
name='compiler-interface',
rev=zinc_rev),
],
# NB: We force a noop-jarjar'ing of the interface, since it is now
# broken up into multiple jars, but zinc does not yet support a sequence
# of jars for the interface.
main='no.such.main.Main',
custom_rules=shader_rules)
cls.register_jvm_tool(register,
Zinc.ZINC_EXTRACTOR_TOOL_NAME,
classpath=[
JarDependency('org.pantsbuild', 'zinc-extractor_2.11', '0.0.4')
])
示例7: register_options
def register_options(cls, register):
super(ZincCompile, cls).register_options(register)
register('--plugins', advanced=True, action='append', fingerprint=True,
help='Use these scalac plugins.')
register('--plugin-args', advanced=True, type=dict_option, default={}, fingerprint=True,
help='Map from plugin name to list of arguments for that plugin.')
register('--name-hashing', advanced=True, action='store_true', default=False, fingerprint=True,
help='Use zinc name hashing.')
cls.register_jvm_tool(register,
'zinc',
classpath=[
JarDependency('org.pantsbuild', 'zinc', '1.0.8')
],
main=cls._ZINC_MAIN,
custom_rules=[
# The compiler-interface and sbt-interface tool jars carry xsbt and
# xsbti interfaces that are used across the shaded tool jar boundary so
# we preserve these root packages wholesale along with the core scala
# APIs.
Shader.exclude_package('scala', recursive=True),
Shader.exclude_package('xsbt', recursive=True),
Shader.exclude_package('xsbti', recursive=True),
])
def sbt_jar(name, **kwargs):
return JarDependency(org='com.typesafe.sbt', name=name, rev='0.13.9', **kwargs)
cls.register_jvm_tool(register,
'compiler-interface',
classpath=[
sbt_jar(name='compiler-interface',
classifier='sources',
# We just want the single compiler-interface jar and not its
# dep on scala-lang
intransitive=True)
])
cls.register_jvm_tool(register,
'sbt-interface',
classpath=[
sbt_jar(name='sbt-interface',
# We just want the single sbt-interface jar and not its dep
# on scala-lang
intransitive=True)
])
# By default we expect no plugin-jars classpath_spec is filled in by the user, so we accept an
# empty classpath.
cls.register_jvm_tool(register, 'plugin-jars', classpath=[])
示例8: register_options
def register_options(cls, register):
super(JUnitRun, cls).register_options(register)
register('--batch-size', advanced=True, type=int, default=sys.maxint,
help='Run at most this many tests in a single test process.')
register('--test', action='append',
help='Force running of just these tests. Tests can be specified using any of: '
'[classname], [classname]#[methodname], [filename] or [filename]#[methodname]')
register('--per-test-timer', action='store_true', help='Show progress and timer for each test.')
register('--default-parallel', advanced=True, action='store_true',
help='Run classes without @TestParallel or @TestSerial annotations in parallel.')
register('--parallel-threads', advanced=True, type=int, default=0,
help='Number of threads to run tests in parallel. 0 for autoset.')
register('--test-shard', advanced=True,
help='Subset of tests to run, in the form M/N, 0 <= M < N. '
'For example, 1/3 means run tests number 2, 5, 8, 11, ...')
register('--suppress-output', action='store_true', default=True,
help='Redirect test output to files in .pants.d/test/junit.')
register('--cwd', advanced=True,
help='Set the working directory. If no argument is passed, use the build root. '
'If cwd is set on a target, it will supersede this argument.')
register('--strict-jvm-version', action='store_true', default=False, advanced=True,
help='If true, will strictly require running junits with the same version of java as '
'the platform -target level. Otherwise, the platform -target level will be '
'treated as the minimum jvm to run.')
register('--failure-summary', action='store_true', default=True,
help='If true, includes a summary of which test-cases failed at the end of a failed '
'junit run.')
register('--allow-empty-sources', action='store_true', default=False, advanced=True,
help='Allows a junit_tests() target to be defined with no sources. Otherwise,'
'such a target will raise an error during the test run.')
cls.register_jvm_tool(register,
'junit',
classpath=[
JarDependency(org='org.pantsbuild', name='junit-runner', rev='0.0.12'),
],
main=JUnitRun._MAIN,
# TODO(John Sirois): Investigate how much less we can get away with.
# Clearly both tests and the runner need access to the same @Test,
# @Before, as well as other annotations, but there is also the Assert
# class and some subset of the @Rules, @Theories and @RunWith APIs.
custom_rules=[
Shader.exclude_package('junit.framework', recursive=True),
Shader.exclude_package('org.junit', recursive=True),
Shader.exclude_package('org.hamcrest', recursive=True),
Shader.exclude_package('org.pantsbuild.junit.annotations', recursive=True),
])
# TODO: Yuck, but will improve once coverage steps are in their own tasks.
for c in [Coverage, Cobertura]:
c.register_options(register, cls.register_jvm_tool)
示例9: register_options_for
def register_options_for(jvm_tool_mixin_cls, register, **kwargs):
"""Register options for the zinc tool in the context of the given JvmToolMixin.
TODO: Move into the classmethod after zinc registration has been removed
from `zinc_compile` in `1.6.0.dev0`.
"""
cls = jvm_tool_mixin_cls
def sbt_jar(name, **kwargs):
return JarDependency(org='org.scala-sbt', name=name, rev='1.0.0-X5', **kwargs)
shader_rules = [
# The compiler-interface and compiler-bridge tool jars carry xsbt and
# xsbti interfaces that are used across the shaded tool jar boundary so
# we preserve these root packages wholesale along with the core scala
# APIs.
Shader.exclude_package('scala', recursive=True),
Shader.exclude_package('xsbt', recursive=True),
Shader.exclude_package('xsbti', recursive=True),
]
cls.register_jvm_tool(register,
'zinc',
classpath=[
JarDependency('org.pantsbuild', 'zinc_2.10', '0.0.5'),
],
main=Zinc.ZINC_COMPILE_MAIN,
custom_rules=shader_rules,
**kwargs)
cls.register_jvm_tool(register,
'compiler-bridge',
classpath=[
sbt_jar(name='compiler-bridge_2.10',
classifier='sources',
intransitive=True)
],
**kwargs)
cls.register_jvm_tool(register,
'compiler-interface',
classpath=[
sbt_jar(name='compiler-interface')
],
# NB: We force a noop-jarjar'ing of the interface, since it is now broken
# up into multiple jars, but zinc does not yet support a sequence of jars
# for the interface.
main='no.such.main.Main',
custom_rules=shader_rules,
**kwargs)
示例10: register_options
def register_options(cls, register):
super(FindBugs, cls).register_options(register)
register('--skip', action='store_true', default=False, fingerprint=True, help='Skip findbugs.')
register('--jvm-options', advanced=True, action='append', metavar='<option>...',
help='Run findbugs with these extra jvm options.')
register('--effort', default='default', choices=['min', 'less', 'default', 'more', 'max'],
help='Effort of the bug finders.')
register('--threshold', default='medium', choices=['low', 'medium', 'high', 'experimental'],
help='Effort of the bug finders.')
register('--fail-on-error', action='store_true', help='Fail the build on an error.')
register('--max-rank', type=int, help='Maximum bug ranking to record [1..20].')
register('--relaxed', action='store_true', default=False, help='Relaxed reporting mode')
register('--nested', action='store_true', default=True, help='Analyze nested jar/zip archives')
register('--exclude-filter-file', help='Exclude bugs matching given filter')
register('--include-filter-file', help='Include only bugs matching given filter')
register('--exclude-patterns', action='append', default=[],
help='Adds patterns for targets to be excluded from analysis.')
cls.register_jvm_tool(register,
'findbugs',
classpath=[
JarDependency(org='com.google.code.findbugs',
name='findbugs',
rev='3.0.1'),
],
main=cls._FINDBUGS_MAIN,
custom_rules=[
Shader.exclude_package('edu.umd.cs.findbugs',
recursive=True),
])
示例11: register_options
def register_options(cls, register):
super(ErrorProne, cls).register_options(register)
register('--skip', type=bool, help='Skip Error Prone.')
register('--transitive', default=False, type=bool,
help='Run Error Prone against transitive dependencies of targets '
'specified on the command line.')
register('--command-line-options', type=list, default=[], fingerprint=True,
help='Command line options passed to Error Prone')
register('--exclude-patterns', type=list, default=[], fingerprint=True,
help='Patterns for targets to be excluded from analysis.')
cls.register_jvm_tool(register,
'errorprone',
classpath=[
JarDependency(org='com.google.errorprone',
name='error_prone_core',
rev='2.3.1'),
],
main=cls._ERRORPRONE_MAIN,
custom_rules=[
Shader.exclude_package('com.google.errorprone', recursive=True)
]
)
# The javac version should be kept in sync with the version used by errorprone above.
cls.register_jvm_tool(register,
'errorprone-javac',
classpath=[
JarDependency(org='com.google.errorprone',
name='javac',
rev='9+181-r4173-1'),
])
示例12: register_options
def register_options(cls, register):
super(Checkstyle, cls).register_options(register)
register('--skip', type=bool, fingerprint=True,
help='Skip checkstyle.')
register('--configuration', advanced=True, type=file_option, fingerprint=True,
help='Path to the checkstyle configuration file.')
register('--properties', advanced=True, type=dict_with_files_option, default={},
fingerprint=True,
help='Dictionary of property mappings to use for checkstyle.properties.')
register('--confs', advanced=True, type=list, default=['default'],
help='One or more ivy configurations to resolve for this target.')
register('--include-user-classpath', type=bool, fingerprint=True,
help='Add the user classpath to the checkstyle classpath')
cls.register_jvm_tool(register,
'checkstyle',
# Note that checkstyle 7.0 does not run on Java 7 runtimes or below.
classpath=[
JarDependency(org='com.puppycrawl.tools',
name='checkstyle',
rev='6.19'),
],
main=cls._CHECKSTYLE_MAIN,
custom_rules=[
# Checkstyle uses reflection to load checks and has an affordance that
# allows leaving off a check classes' package name. This affordance
# breaks for built-in checkstyle checks under shading so we ensure all
# checkstyle packages are excluded from shading such that just its
# third party transitive deps (guava and the like), are shaded.
# See the module configuration rules here which describe this:
# http://checkstyle.sourceforge.net/config.html#Modules
Shader.exclude_package('com.puppycrawl.tools.checkstyle',
recursive=True),
])
示例13: register_options
def register_options(cls, register):
super(ErrorProne, cls).register_options(register)
register('--skip', type=bool, help='Skip Error Prone.')
register('--transitive', default=False, type=bool,
help='Run Error Prone against transitive dependencies of targets '
'specified on the command line.')
register('--command-line-options', type=list, default=[], fingerprint=True,
help='Command line options passed to Error Prone')
register('--exclude-patterns', type=list, default=[], fingerprint=True,
help='Patterns for targets to be excluded from analysis.')
cls.register_jvm_tool(register,
'errorprone',
classpath=[
JarDependency(org='com.google.errorprone',
name='error_prone_core',
rev='2.0.17'),
],
main=cls._ERRORPRONE_MAIN,
custom_rules=[
Shader.exclude_package('com.google.errorprone', recursive=True),
Shading.create_exclude('*'), # https://github.com/pantsbuild/pants/issues/4288
]
)
示例14: test_runner_command
def test_runner_command(self):
input_jar = self.populate_input_jar('main.class', 'com/google/common/base/Function.class')
custom_rules = [Shader.exclude_package('log4j', recursive=True)]
with self.shader.binary_shader(self.output_jar, 'main', input_jar,
custom_rules=custom_rules) as shader:
command = shader.command
self.assertTrue(command.pop(0).endswith('java'))
jar_or_cp = command.pop(0)
self.assertIn(jar_or_cp, {'-cp', 'classpath', '-jar'})
self.assertEqual(self.jarjar, os.path.abspath(command.pop(0)))
if jar_or_cp != '-jar':
# We don't really care what the name of the jarjar main class is - shader.command[2]
command.pop(0)
self.assertEqual('process', command.pop(0))
rules_file = command.pop(0)
self.assertTrue(os.path.exists(rules_file))
with open(rules_file) as fp:
lines = fp.read().splitlines()
self.assertEqual('rule log4j.** [email protected]', lines[0]) # The custom rule.
self.assertEqual('rule * @1', lines[1]) # Exclude main's package.
self.assertIn('rule javax.annotation.* [email protected]', lines) # Exclude system.
self.assertEqual('rule com.google.common.base.* {}[email protected]'
.format(Shading.SHADE_PREFIX), lines[-1]) # Shade the rest.
self.assertEqual(input_jar, command.pop(0))
self.assertEqual(self.output_jar, command.pop(0))
示例15: register_options
def register_options(cls, register):
super(ExtractJava, cls).register_options(register)
cls.register_jvm_tool(register,
'kythe-java-extractor',
custom_rules=[
# These need to remain unshaded so that Kythe can interact with the
# javac embedded in its jar.
Shader.exclude_package('com.sun', recursive=True),
],
main=cls._KYTHE_JAVA_EXTRACTOR_MAIN)