本文整理汇总了Python中pants.backend.jvm.subsystems.java.Java类的典型用法代码示例。如果您正苦于以下问题:Python Java类的具体用法?Python Java怎么用?Python Java使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Java类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: compute_dependency_specs
def compute_dependency_specs(cls, kwargs=None, payload=None):
for spec in super(JavacPlugin, cls).compute_dependency_specs(kwargs, payload):
yield spec
yield (
Java.global_instance().injectables_spec_for_key('javac') or
Java.global_instance().injectables_spec_for_key('tools.jar')
)
示例2: traversable_dependency_specs
def traversable_dependency_specs(self):
for spec in super(JavacPlugin, self).traversable_dependency_specs:
yield spec
javac_spec = Java.global_javac_spec(self._build_graph)
if javac_spec is None:
yield self._tools_jar_spec(self._build_graph)
else:
yield javac_spec
示例3: javac_compiler_plugins_src
def javac_compiler_plugins_src(self, zinc_compile_instance=None):
"""Returns an instance of JvmToolMixin that should provide javac compiler plugins.
TODO: Remove this method once the deprecation of `(scalac|javac)_plugins` on Zinc has
completed in `1.9.0.dev0`.
"""
return Zinc._select_jvm_tool_mixin(zinc_compile_instance,
Java.global_instance(),
['javac_plugins', 'javac_plugin_args', 'javac_plugin_dep'])
示例4: _compiler_plugins_cp_entries
def _compiler_plugins_cp_entries(self):
"""Any additional global compiletime classpath entries for compiler plugins."""
java_options_src = Java.global_instance()
scala_options_src = ScalaPlatform.global_instance()
def cp(instance, toolname):
scope = instance.options_scope
return instance.tool_classpath_from_products(self._products, toolname, scope=scope)
classpaths = (cp(java_options_src, 'javac-plugin-dep') +
cp(scala_options_src, 'scalac-plugin-dep'))
return [(conf, ClasspathEntry(jar)) for conf in self.DEFAULT_CONFS for jar in classpaths]
示例5: _compile_vts
def _compile_vts(self, vts, ctx, upstream_analysis, classpath, progress_message, settings,
compiler_option_sets, zinc_file_manager, counter):
"""Compiles sources for the given vts into the given output dir.
:param vts: VersionedTargetSet with one entry for the target.
:param ctx: - A CompileContext instance for the target.
:param classpath: A list of classpath entries
May be invoked concurrently on independent target sets.
Postcondition: The individual targets in vts are up-to-date, as if each were
compiled individually.
"""
if not ctx.sources:
self.context.log.warn('Skipping {} compile for targets with no sources:\n {}'
.format(self.name(), vts.targets))
else:
counter_val = str(counter()).rjust(counter.format_length(), b' ')
counter_str = '[{}/{}] '.format(counter_val, counter.size)
# Do some reporting.
self.context.log.info(
counter_str,
'Compiling ',
items_to_report_element(ctx.sources, '{} source'.format(self.name())),
' in ',
items_to_report_element([t.address.reference() for t in vts.targets], 'target'),
' (',
progress_message,
').')
with self.context.new_workunit('compile', labels=[WorkUnitLabel.COMPILER]) as compile_workunit:
if self.get_options().capture_classpath:
self._record_compile_classpath(classpath, vts.targets, ctx.classes_dir)
try:
self.compile(
ctx,
self._args,
classpath,
upstream_analysis,
settings,
compiler_option_sets,
zinc_file_manager,
self._get_plugin_map('javac', Java.global_instance(), ctx.target),
self._get_plugin_map('scalac', ScalaPlatform.global_instance(), ctx.target),
)
self._capture_logs(compile_workunit, ctx.log_dir)
except TaskError:
if self.get_options().suggest_missing_deps:
logs = [path
for _, name, _, path in self._find_logs(compile_workunit)
if name == self.name()]
if logs:
self._find_missing_deps(logs, ctx.target)
raise
示例6: _tools_classpath
def _tools_classpath(self):
"""Returns a classpath representing the (equivalent of the) `tools.jar`.
If `javac` has been set explicitly, it is used. Otherwise, searches the current distribution.
"""
javac_classpath = Java.global_javac_classpath(self.context.products)
if javac_classpath:
return javac_classpath
self.set_distribution(jdk=True)
jars = self.dist.find_libs(['tools.jar'])
if len(jars) != 1:
raise TaskError('Expected a single `tools.jar` entry for {}; got: {}'.format(
self.dist, jars))
return jars
示例7: defaulted_property
def defaulted_property(self, target, option_name):
"""Computes a language property setting for the given JvmTarget.
:param selector A function that takes a target or platform and returns the boolean value of the
property for that target or platform, or None if that target or platform does
not directly define the property.
If the target does not override the language property, returns true iff the property
is true for any of the matched languages for the target.
"""
if target.has_sources('.java'):
matching_subsystem = Java.global_instance()
elif target.has_sources('.scala'):
matching_subsystem = ScalaPlatform.global_instance()
else:
return getattr(target, option_name)
return matching_subsystem.get_scalar_mirrored_target_option(option_name, target)
示例8: defaulted_property
def defaulted_property(self, target, selector):
"""Computes a language property setting for the given JvmTarget.
:param selector A function that takes a target or platform and returns the boolean value of the
property for that target or platform, or None if that target or platform does
not directly define the property.
If the target does not override the language property, returns true iff the property
is true for any of the matched languages for the target.
"""
if selector(target) is not None:
return selector(target)
prop = False
if target.has_sources('.java'):
prop |= selector(Java.global_instance())
if target.has_sources('.scala'):
prop |= selector(ScalaPlatform.global_instance())
return prop
示例9: traversable_dependency_specs
def traversable_dependency_specs(self):
for spec in super(JvmTarget, self).traversable_dependency_specs:
yield spec
for resource_spec in self._resource_specs:
yield resource_spec
# Add deps on anything we might need to find plugins.
# Note that this will also add deps from scala targets to javac plugins, but there's
# no real harm in that, and the alternative is to check for .java sources, which would
# eagerly evaluate all the globs, which would be a performance drag for goals that
# otherwise wouldn't do that (like `list`).
for spec in Java.global_plugin_dependency_specs():
# Ensure that if this target is the plugin, we don't create a dep on ourself.
# Note that we can't do build graph dep checking here, so we will create a dep on our own
# deps, thus creating a cycle. Therefore an in-repo plugin that has JvmTarget deps
# can only be applied globally via the Java subsystem if you publish it first and then
# reference it as a JarLibrary (it can still be applied directly from the repo on targets
# that explicitly depend on it though). This is an unfortunate gotcha that will be addressed
# in the new engine.
if spec != self.address.spec:
yield spec
示例10: _compute_language_property
def _compute_language_property(self, target, selector):
"""Computes the a language property setting for the given target sources.
:param target The target whose language property will be calculated.
:param selector A function that takes a target or platform and returns the boolean value of the
property for that target or platform, or None if that target or platform does
not directly define the property.
If the target does not override the language property, returns true iff the property
is true for any of the matched languages for the target.
"""
if selector(target) is not None:
return selector(target)
property = False
if target.has_sources(".java"):
property |= selector(Java.global_instance())
if target.has_sources(".scala"):
property |= selector(ScalaPlatform.global_instance())
return property
示例11: javac_classpath
def javac_classpath(self):
# Note that if this classpath is empty then Zinc will automatically use the javac from
# the JDK it was invoked with.
return Java.global_javac_classpath(self.context.products)