Skip to content
This repository has been archived by the owner on Dec 10, 2020. It is now read-only.

Commit

Permalink
Follow-up options/documentation changes after scala removed from BUIL…
Browse files Browse the repository at this point in the history
…D.tools

* Allow users to specify the runtime spec if they are specifying a custom scala version.
* Add deprecation warning for runtime option

Testing Done:
travis is green https://travis-ci.org/pantsbuild/pants/builds/100450093

http://ec2-54-146-169-50.compute-1.amazonaws.com:8080/job/pants_ci_trigger/52/
http://ec2-54-146-169-50.compute-1.amazonaws.com:8080/job/pants_ci_trigger/60/console

Bugs closed: 2773

Reviewed at https://rbcommons.com/s/twitter/r/3302/
  • Loading branch information
digwanderlust authored and stuhood committed Jan 8, 2016
1 parent 136206c commit f2391e0
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 7 deletions.
7 changes: 7 additions & 0 deletions migrations/options/src/python/migrate_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@
('resolve.ivy', 'nailgun-server'): None,
('resolve.ivy', 'xalan'): None,
('scala-platform', 'scalac'): None,
('scala-platform', 'runtime'): None,
('test.junit', 'cobertura-instrument'): None,
('test.junit', 'cobertura-report'): None,
('test.junit', 'cobertura-run'): None,
Expand Down Expand Up @@ -395,6 +396,11 @@
'limit the number of overrides by inverting the default with a DEFAULT section '
'value of False.')

scala_buildtools_defaults = ('Scala runtime is now determined based on the version specified. '
'Pants will use a default minor version based on the major version '
'specified eg: 2.10. If custom is specified then the full version '
'may be defined in the spec provided in option --runtime-spec ')

scrooge_gen_deps_note = ('The scrooge-gen per-language config fields have been refactored into '
'two options: one for service deps, and one for structs deps.')
compile_jar_note = ('The isolated jvm compile `jar` option is critical to performant operation '
Expand Down Expand Up @@ -557,6 +563,7 @@
('resolve.ivy', 'nailgun-server'): jvm_tool_spec_override,
('resolve.ivy', 'xalan'): jvm_tool_spec_override,
('scala-platform', 'scalac'): jvm_tool_spec_override,
('scala-platform', 'runtime'): scala_buildtools_defaults,
('test.junit', 'cobertura-instrument'): jvm_tool_spec_override,
('test.junit', 'cobertura-report'): jvm_tool_spec_override,
('test.junit', 'cobertura-run'): jvm_tool_spec_override,
Expand Down
32 changes: 25 additions & 7 deletions src/python/pants/backend/jvm/subsystems/scala_platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from pants.backend.jvm.targets.jar_dependency import JarDependency
from pants.backend.jvm.targets.jar_library import JarLibrary
from pants.build_graph.address import Address
from pants.option.custom_types import list_option
from pants.subsystem.subsystem import Subsystem


Expand Down Expand Up @@ -47,13 +48,26 @@ class ScalaPlatform(JvmToolMixin, ZincLanguageMixin, Subsystem):
@classmethod
def register_options(cls, register):
super(ScalaPlatform, cls).register_options(register)
# Version specified will allow the user provide some sane defaults for common
# versions of scala. If version is something other than one of the common
# versions the user will be able to override the defaults by specifying
# custom build targets for //:scalac and //:scala-library
register('--version', advanced=True, default='2.10', choices=['2.10', '2.11', 'custom'],
help='The scala "platform version", which is suffixed onto all published '
'libraries. This should match the declared compiler/library versions.')
'libraries. This should match the declared compiler/library versions. '
'Version specified will allow the user provide some sane defaults for common '
'versions of scala. If version is something other than one of the common '
'versions the user will be able to override the defaults by specifying '
'"custom" as the --version, custom build targets can be specified in the targets '
'for //:scalac and //:scala-library ')

register('--runtime', advanced=True, type=list_option, default=['//:scala-library'],
help='Target specs pointing to the scala runtime libraries.',
deprecated_version='0.0.75',
deprecated_hint='Option is no longer used, --version is used to specify the major '
'version. The runtime is created based on major version. '
'The runtime target will be defined at the address //:scala-library '
'unless it is overriden by the option --runtime-spec and a --version '
'is set to custom.')

register('--runtime-spec', advanced=True, default='//:scala-library',
help='Address to be used for custom scala runtime.')

# Scala 2.10
cls.register_jvm_tool(register,
Expand Down Expand Up @@ -150,8 +164,12 @@ def runtime(self):
"""Return the proper runtime based on scala version.
:return iterator: list with single runtime.
"""
runtime_name = scala_build_info.get(self._get_label()).runtime_name
return [getattr(self, runtime_name)]
# If the version is custom allow the user the option to set the spec.
if self._get_label() == 'custom':
return self.get_options().runtime_spec
else:
runtime_name = scala_build_info.get(self._get_label()).runtime_name
return [getattr(self, runtime_name)]

@classmethod
def _synthetic_runtime_target(cls, buildgraph):
Expand Down

0 comments on commit f2391e0

Please sign in to comment.