Skip to content

Commit

Permalink
Prepare the 1.9.0.dev0 release. (#6018)
Browse files Browse the repository at this point in the history
  • Loading branch information
jsirois authored Jun 25, 2018
1 parent 12711f2 commit aad4b7b
Show file tree
Hide file tree
Showing 9 changed files with 99 additions and 162 deletions.
2 changes: 1 addition & 1 deletion src/python/pants/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.8.0rc0
1.9.0.dev0
3 changes: 0 additions & 3 deletions src/python/pants/backend/jvm/subsystems/scala_platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@ class ScalaPlatform(JvmToolMixin, ZincLanguageMixin, InjectablesMixin, Subsystem
"""
options_scope = 'scala'

deprecated_options_scope = 'scala-platform'
deprecated_options_scope_removal_version = '1.9.0.dev0'

@classmethod
def _create_jardep(cls, name, version):
return JarDependency(org='org.scala-lang',
Expand Down
65 changes: 17 additions & 48 deletions src/python/pants/backend/jvm/subsystems/zinc.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ class Factory(Subsystem, JvmToolMixin):

@classmethod
def subsystem_dependencies(cls):
return super(Zinc.Factory, cls).subsystem_dependencies() + (DependencyContext, Java, ScalaPlatform)
return super(Zinc.Factory, cls).subsystem_dependencies() + (DependencyContext,
Java,
ScalaPlatform)

@classmethod
def register_options(cls, register):
Expand Down Expand Up @@ -73,11 +75,13 @@ def register_options(cls, register):
cls.register_jvm_tool(register,
'compiler-interface',
classpath=[
JarDependency(org='org.scala-sbt', name='compiler-interface', rev=zinc_rev),
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.
# 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)

Expand Down Expand Up @@ -158,52 +162,17 @@ def rebase_map_args(self):
','.join('{}:{}'.format(src, dst) for src, dst in rebases.items())
)

@staticmethod
def _select_jvm_tool_mixin(left, right, options):
if left is None:
return right
if any(not left.get_options().is_default(opt)
for opt in options
if getattr(left.get_options(), opt, None) is not None):
return left
return right

@memoized_method
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'])

@memoized_method
def scalac_compiler_plugins_src(self, zinc_compile_instance=None):
"""Returns an instance of JvmToolMixin that should provide scalac 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,
ScalaPlatform.global_instance(),
['scalac_plugins', 'scalac_plugin_args', 'scalac_plugin_dep'])

@memoized_method
def _compiler_plugins_cp_entries(self, zinc_compile_instance=None):
"""Any additional global compiletime classpath entries for compiler plugins.
TODO: Remove parameter once the deprecation of `(scalac|javac)_plugins` on Zinc has
completed in `1.9.0.dev0`.
"""
java_options_src = self.javac_compiler_plugins_src(zinc_compile_instance)
scala_options_src = self.scalac_compiler_plugins_src(zinc_compile_instance)
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')
classpaths = (cp(java_options_src, 'javac-plugin-dep') +
cp(scala_options_src, 'scalac-plugin-dep'))
return [(conf, jar) for conf in self.DEFAULT_CONFS for jar in classpaths]

@memoized_property
Expand All @@ -212,7 +181,7 @@ def extractor(self):
self.ZINC_EXTRACTOR_TOOL_NAME,
scope=self._zinc_factory.options_scope)

def compile_classpath(self, classpath_product_key, target, extra_cp_entries=None, zinc_compile_instance=None):
def compile_classpath(self, classpath_product_key, target, extra_cp_entries=None):
"""Compute the compile classpath for the given target."""
classpath_product = self._products.get_data(classpath_product_key)

Expand All @@ -221,7 +190,7 @@ def compile_classpath(self, classpath_product_key, target, extra_cp_entries=None
else:
dependencies = DependencyContext.global_instance().all_dependencies(target)

all_extra_cp_entries = list(self._compiler_plugins_cp_entries(zinc_compile_instance))
all_extra_cp_entries = list(self._compiler_plugins_cp_entries())
if extra_cp_entries:
all_extra_cp_entries.extend(extra_cp_entries)

Expand Down
32 changes: 6 additions & 26 deletions src/python/pants/backend/jvm/tasks/jvm_compile/jvm_compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,6 @@ def register_options(cls, register):
default=list(cls.get_args_default(register.bootstrap)), fingerprint=True,
help='Pass these extra args to the compiler.')

register('--confs', advanced=True, type=list, default=Zinc.DEFAULT_CONFS,
removal_version='1.9.0.dev0',
removal_hint='Compiling for confs other than `default` is no longer supported.',
help='Compile for these Ivy confs.')

register('--clear-invalid-analysis', advanced=True, type=bool,
help='When set, any invalid/incompatible analysis files will be deleted '
'automatically. When unset, an error is raised instead.')
Expand Down Expand Up @@ -110,29 +105,15 @@ def register_options(cls, register):
'constraints). Choose \'random\' to choose random sizes for each target, which '
'may be useful for distributed builds.')

register('--capture-log', advanced=True, type=bool,
removal_version='1.9.0.dev0',
removal_hint='Now enabled by default: this option has no effect.',
help='Capture compilation output to per-target logs.')

register('--capture-classpath', advanced=True, type=bool, default=True,
fingerprint=True,
help='Capture classpath to per-target newline-delimited text files. These files will '
'be packaged into any jar artifacts that are created from the jvm targets.')

register('--unused-deps', choices=['ignore', 'warn', 'fatal'], default='ignore',
fingerprint=True,
removal_version='1.9.0.dev0',
removal_hint='Option has moved to `--lint-jvm-dep-check-unnecessary-deps` and is '
'ignored in this location.',
help='Controls whether unused deps are checked, and whether they cause warnings or '
'errors. This option uses zinc\'s analysis to determine which deps are unused, '
'and can thus result in false negatives: thus it is disabled by default.')

register('--suggest-missing-deps', type=bool,
help='Suggest missing dependencies on a best-effort basis from target\'s transitive'
'deps for compilation failures that are due to class not found.')

register('--buildozer',
help='Path to buildozer for suggest-missing-deps command lines. '
'If absent, no command line will be suggested to fix missing deps.')
Expand Down Expand Up @@ -327,7 +308,7 @@ def __init__(self, *args, **kwargs):
self._args.extend(self.get_options().debug_symbol_args)

# The ivy confs for which we're building.
self._confs = self.get_options().confs
self._confs = Zinc.DEFAULT_CONFS

# Determines which sources are relevant to this target.
self._sources_predicate = self.select_source
Expand Down Expand Up @@ -510,8 +491,8 @@ def _compile_vts(self, vts, ctx, upstream_analysis, classpath, progress_message,
settings,
fatal_warnings,
zinc_file_manager,
self._get_plugin_map('javac', self._zinc.javac_compiler_plugins_src(self), ctx.target),
self._get_plugin_map('scalac', self._zinc.scalac_compiler_plugins_src(self), ctx.target),
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:
Expand Down Expand Up @@ -587,7 +568,7 @@ def _find_logs(self, compile_workunit):
def _find_missing_deps(self, compile_logs, target):
with self.context.new_workunit('missing-deps-suggest', labels=[WorkUnitLabel.COMPILER]):
compile_failure_log = '\n'.join(read_file(log).decode('utf-8') for log in compile_logs)

missing_dep_suggestions, no_suggestions = self._missing_deps_finder.find(
compile_failure_log, target)

Expand Down Expand Up @@ -772,8 +753,7 @@ def _cp_entries_for_ctx(self, ctx, classpath_product_key):
cp_entries = [ctx.classes_dir]
cp_entries.extend(self._zinc.compile_classpath(classpath_product_key,
ctx.target,
extra_cp_entries=self._extra_compile_time_classpath,
zinc_compile_instance=self))
extra_cp_entries=self._extra_compile_time_classpath))
return cp_entries

def _record_target_stats(self, target, classpath_len, sources_len, compiletime, is_incremental,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -499,37 +499,6 @@ def process_info_file(cp_elem, info_file):
class ZincCompile(BaseZincCompile):
"""Compile Scala and Java code to classfiles using Zinc."""

@classmethod
def register_options(cls, register):
super(ZincCompile, cls).register_options(register)
register('--javac-plugins', advanced=True, type=list, fingerprint=True,
removal_version='1.9.0.dev0',
removal_hint='Use `--java-javac-plugins` instead.',
help='Use these javac plugins.')
register('--javac-plugin-args', advanced=True, type=dict, default={}, fingerprint=True,
removal_version='1.9.0.dev0',
removal_hint='Use `--java-javac-plugin-args` instead.',
help='Map from javac plugin name to list of arguments for that plugin.')
cls.register_jvm_tool(register, 'javac-plugin-dep', classpath=[],
removal_version='1.9.0.dev0',
removal_hint='Use `--java-javac-plugin-dep` instead.',
help='Search for javac plugins here, as well as in any '
'explicit dependencies.')

register('--scalac-plugins', advanced=True, type=list, fingerprint=True,
removal_version='1.9.0.dev0',
removal_hint='Use `--scala-scalac-plugins` instead.',
help='Use these scalac plugins.')
register('--scalac-plugin-args', advanced=True, type=dict, default={}, fingerprint=True,
removal_version='1.9.0.dev0',
removal_hint='Use `--scala-scalac-plugin-args` instead.',
help='Map from scalac plugin name to list of arguments for that plugin.')
cls.register_jvm_tool(register, 'scalac-plugin-dep', classpath=[],
removal_version='1.9.0.dev0',
removal_hint='Use `--scala-scalac-plugin-dep` instead.',
help='Search for scalac plugins here, as well as in any '
'explicit dependencies.')

@classmethod
def product_types(cls):
return ['runtime_classpath', 'zinc_analysis', 'zinc_args']
Expand Down
51 changes: 5 additions & 46 deletions src/python/pants/backend/jvm/tasks/jvm_dependency_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,9 @@
class JvmDependencyCheck(Task):
"""Checks true dependencies of a JVM target and ensures that they are consistent with BUILD files."""

deprecated_scope = 'compile.jvm-dep-check'
deprecated_scope_removal_version = '1.9.0.dev0'

@classmethod
def register_options(cls, register):
super(JvmDependencyCheck, cls).register_options(register)
register('--missing-deps', choices=['off', 'warn', 'fatal'], default='off',
fingerprint=True,
removal_version='1.9.0.dev0',
removal_hint='Undeclared transitive dependencies are no longer possible.',
help='Check for missing dependencies in compiled code. Reports actual '
'dependencies A -> B where there is no transitive BUILD file dependency path '
'from A to B. If fatal, missing deps are treated as a build error.')

register('--missing-direct-deps', choices=['off', 'warn', 'fatal'],
default='off',
fingerprint=True,
Expand Down Expand Up @@ -69,7 +58,7 @@ def subsystem_dependencies(cls):
@staticmethod
def _skip(options):
"""Return true if the task should be entirely skipped, and thus have no product requirements."""
values = [options.missing_deps, options.missing_direct_deps, options.unnecessary_deps]
values = [options.missing_direct_deps, options.unnecessary_deps]
return all(v == 'off' for v in values)

@classmethod
Expand All @@ -88,7 +77,6 @@ def munge_flag(flag):
flag_value = self.get_options().get(flag, None)
return None if flag_value == 'off' else flag_value

self._check_missing_deps = munge_flag('missing_deps')
self._check_missing_direct_deps = munge_flag('missing_direct_deps')
self._check_unnecessary_deps = munge_flag('unnecessary_deps')
self._target_whitelist = [Address.parse(s) for s in self.get_options().missing_deps_whitelist]
Expand Down Expand Up @@ -125,8 +113,8 @@ def check(self, src_tgt, actual_deps):
See docstring for _compute_missing_deps for details.
"""
if self._check_missing_deps or self._check_missing_direct_deps or self._check_unnecessary_deps:
missing_file_deps, missing_tgt_deps, missing_direct_tgt_deps = \
if self._check_missing_direct_deps or self._check_unnecessary_deps:
missing_file_deps, missing_direct_tgt_deps = \
self._compute_missing_deps(src_tgt, actual_deps)

buildroot = get_buildroot()
Expand All @@ -141,23 +129,6 @@ def filter_whitelisted(missing_deps):
return [(tgt_pair, evidence) for (tgt_pair, evidence) in missing_deps
if tgt_pair[0].address not in self._target_whitelist]

missing_tgt_deps = filter_whitelisted(missing_tgt_deps)

if self._check_missing_deps and (missing_file_deps or missing_tgt_deps):
log_fn = (self.context.log.error if self._check_missing_deps == 'fatal'
else self.context.log.warn)
for (tgt_pair, evidence) in missing_tgt_deps:
evidence_str = '\n'.join([' {} uses {}'.format(shorten(e[0]), shorten(e[1]))
for e in evidence])
log_fn('Missing BUILD dependency {} -> {} because:\n{}'
.format(tgt_pair[0].address.spec, tgt_pair[1].address.spec,
evidence_str))
for (src_tgt, dep) in missing_file_deps:
log_fn('Missing BUILD dependency {} -> {}'
.format(src_tgt.address.spec, shorten(dep)))
if self._check_missing_deps == 'fatal':
raise TaskError('Missing deps.')

missing_direct_tgt_deps = filter_whitelisted(missing_direct_tgt_deps)

if self._check_missing_direct_deps and missing_direct_tgt_deps:
Expand Down Expand Up @@ -193,15 +164,12 @@ def _compute_missing_deps(self, src_tgt, actual_deps):
- actual_deps: a map src -> list of actual deps (source, class or jar file) as noted by the
compiler.
Returns a triple (missing_file_deps, missing_tgt_deps, missing_direct_tgt_deps) where:
Returns a tuple (missing_file_deps, missing_direct_tgt_deps) where:
- missing_file_deps: a list of dep_files where src_tgt requires dep_file, and we're unable
to map to a target (because its target isn't in the total set of targets in play,
and we don't want to parse every BUILD file in the workspace just to find it).
- missing_tgt_deps: a list of dep_tgt where src_tgt is missing a necessary transitive
dependency on dep_tgt.
- missing_direct_tgt_deps: a list of dep_tgts where src_tgt is missing a direct dependency
on dep_tgt but has a transitive dep on it.
Expand All @@ -227,14 +195,8 @@ def target_or_java_dep_in_targets(target, targets):
else:
return False

# TODO: If recomputing these every time becomes a performance issue, memoize for
# already-seen targets and incrementally compute for new targets not seen in a previous
# partition, in this or a previous chunk.
transitive_deps_by_target = analyzer.compute_transitive_deps_by_target(self.context.targets())

# Find deps that are actual but not specified.
missing_file_deps = OrderedSet() # (src, src).
missing_tgt_deps_map = defaultdict(list) # (tgt, tgt) -> a list of (src, src) as evidence.
missing_direct_tgt_deps_map = defaultdict(list) # The same, but for direct deps.

targets_by_file = analyzer.targets_by_file(self.context.targets())
Expand All @@ -250,15 +212,12 @@ def target_or_java_dep_in_targets(target, targets):
elif not target_or_java_dep_in_targets(src_tgt, actual_dep_tgts):
# Obviously intra-target deps are fine.
canonical_actual_dep_tgt = next(iter(actual_dep_tgts))
if actual_dep_tgts.isdisjoint(transitive_deps_by_target.get(src_tgt, [])):
missing_tgt_deps_map[(src_tgt, canonical_actual_dep_tgt)].append((src, actual_dep))
elif canonical_actual_dep_tgt not in src_tgt.dependencies:
if canonical_actual_dep_tgt not in src_tgt.dependencies:
# The canonical dep is the only one a direct dependency makes sense on.
missing_direct_tgt_deps_map[(src_tgt, canonical_actual_dep_tgt)].append(
(src, actual_dep))

return (list(missing_file_deps),
missing_tgt_deps_map.items(),
missing_direct_tgt_deps_map.items())

def _do_check_unnecessary_deps(self, target, actual_deps, log_fn):
Expand Down
Loading

0 comments on commit aad4b7b

Please sign in to comment.