Skip to content

Commit

Permalink
Revert "add scala_platform to export output for metals! (pantsbuild#8370
Browse files Browse the repository at this point in the history
)" (pantsbuild#8379)

pantsbuild#8370 was broken, and I failed to ensure it passed CI before merging it. See e.g. the failure [here](https://travis-ci.org/pantsbuild/pants/jobs/592373373).
  • Loading branch information
cosmicexplorer authored Oct 2, 2019
1 parent b6981e5 commit f673fd2
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 91 deletions.
13 changes: 0 additions & 13 deletions src/docs/export.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,15 +107,6 @@ The following is an abbreviated export file from a command in the pants repo:
},
"default_interpreter": "CPython-2.7.10"
},
"scala_platform": {
"scala_version": "2.12",
"compiler_classpath": [
"/Users/dmcclanahan/tools/pants-v4/.pants.d/bootstrap/bootstrap-jvm-tools/a0ebe8e0b001/ivy/jars/org.scala-lang/scala-compiler/jars/scala-compiler-2.12.8.jar",
"/Users/dmcclanahan/tools/pants-v4/.pants.d/bootstrap/bootstrap-jvm-tools/a0ebe8e0b001/ivy/jars/org.scala-lang/scala-library/jars/scala-library-2.12.8.jar",
"/Users/dmcclanahan/tools/pants-v4/.pants.d/bootstrap/bootstrap-jvm-tools/a0ebe8e0b001/ivy/jars/org.scala-lang/scala-reflect/jars/scala-reflect-2.12.8.jar",
"/Users/dmcclanahan/tools/pants-v4/.pants.d/bootstrap/bootstrap-jvm-tools/a0ebe8e0b001/ivy/jars/org.scala-lang.modules/scala-xml_2.12/jars/scala-xml_2.12-1.0.6.jar"
]
},
"targets": {
"examples/tests/java/org/pantsbuild/example/usethrift:usethrift": {
"is_code_gen": false,
Expand Down Expand Up @@ -177,10 +168,6 @@ The following is an abbreviated export file from a command in the pants repo:

# Export Format Changes

## 1.0.11

The 'scala_platform' field is added to the top-level keys, containing the 'scala_version' string (without patch version, e.g. "2.12") and the 'compiler_classpath' jars (a list of absolute paths to jar files).

## 1.0.10

Coursier is added to be an option for the resolve path which ignores the confs for library sources and javadoc yet.
Expand Down
13 changes: 1 addition & 12 deletions src/python/pants/backend/project_info/tasks/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

from pants.backend.jvm.subsystems.jvm_platform import JvmPlatform
from pants.backend.jvm.subsystems.resolve_subsystem import JvmResolveSubsystem
from pants.backend.jvm.subsystems.scala_platform import ScalaPlatform
from pants.backend.jvm.targets.jar_library import JarLibrary
from pants.backend.jvm.targets.junit_tests import JUnitTests
from pants.backend.jvm.targets.jvm_app import JvmApp
Expand Down Expand Up @@ -56,7 +55,7 @@ class ExportTask(ResolveRequirementsTaskBase, IvyTaskMixin, CoursierMixin):
#
# Note format changes in src/docs/export.md and update the Changelog section.
#
DEFAULT_EXPORT_VERSION = '1.0.11'
DEFAULT_EXPORT_VERSION = '1.0.10'

@classmethod
def subsystem_dependencies(cls):
Expand Down Expand Up @@ -283,15 +282,6 @@ def iter_transitive_jars(jar_lib):
for target in targets:
process_target(target)

scala_platform = ScalaPlatform.global_instance()
scala_platform_map = {
'scala_version': scala_platform.version,
'compiler_classpath': [
cp_entry.path
for cp_entry in scala_platform.compiler_classpath_entries(self.context.products)
],
}

jvm_platforms_map = {
'default_platform' : JvmPlatform.global_instance().default_platform.name,
'platforms': {
Expand All @@ -306,7 +296,6 @@ def iter_transitive_jars(jar_lib):
'version': self.DEFAULT_EXPORT_VERSION,
'targets': targets_map,
'jvm_platforms': jvm_platforms_map,
'scala_platform': scala_platform_map,
# `jvm_distributions` are static distribution settings from config,
# `preferred_jvm_distributions` are distributions that pants actually uses for the
# given platform setting.
Expand Down
71 changes: 5 additions & 66 deletions tests/python/pants_test/backend/project_info/tasks/test_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
from pants.backend.jvm.targets.jvm_binary import JvmBinary
from pants.backend.jvm.targets.jvm_target import JvmTarget
from pants.backend.jvm.targets.scala_library import ScalaLibrary
from pants.backend.jvm.tasks.bootstrap_jvm_tools import BootstrapJvmTools
from pants.backend.jvm.tasks.classpath_products import ClasspathProducts
from pants.backend.project_info.tasks.export import Export
from pants.backend.python.register import build_file_aliases as register_python
Expand All @@ -46,9 +45,6 @@ def task_type(cls):
def alias_groups(cls):
return register_core().merge(register_jvm()).merge(register_python())

# Version of the scala compiler and libraries used for this test.
_scala_toolchain_version = '2.10.5'

def setUp(self):
super().setUp()

Expand All @@ -60,40 +56,10 @@ def setUp(self):
}
init_subsystems([JUnit, ScalaPlatform, ScoveragePlatform], scala_options)

self.make_target(
':jar-tool',
JarLibrary,
jars=[JarDependency('org.pantsbuild', 'jar-tool', '0.0.10')]
)

self.make_target(
':jarjar',
JarLibrary,
jars=[JarDependency(org='org.pantsbuild', name='jarjar', rev='1.7.2')]
)

self.make_target(
':scala-library',
JarLibrary,
jars=[JarDependency('org.scala-lang', 'scala-library', self._scala_toolchain_version)]
)

self.make_target(
':scalac',
JarLibrary,
jars=[JarDependency('org.scala-lang', 'scala-compiler', self._scala_toolchain_version)]
)

self.make_target(
':scala-reflect',
JarLibrary,
jars=[JarDependency('org.scala-lang', 'scala-reflect', self._scala_toolchain_version)]
)

self.make_target(
':scala-repl',
JarLibrary,
jars=[JarDependency('org.scala-lang', 'scala-repl', self._scala_toolchain_version)]
jars=[JarDependency('org.scala-lang', 'scala-library', '2.10.5')]
)

self.make_target(
Expand Down Expand Up @@ -215,20 +181,17 @@ def setUp(self):

self.add_to_build_file('src/python/has_reqs/BUILD', textwrap.dedent("""
python_library(name="has_reqs", sources=globs("*.py"), dependencies=[':six'])
python_requirement_library(
name='six',
requirements=[
python_requirement('six==1.9.0')
]
)
)
"""))

def execute_export(self, *specs, **options_overrides):
options = {
ScalaPlatform.options_scope: {
'version': 'custom'
},
JvmResolveSubsystem.options_scope: {
'resolver': 'ivy'
},
Expand All @@ -241,14 +204,10 @@ def execute_export(self, *specs, **options_overrides):
}
options.update(options_overrides)

BootstrapJvmTools.options_scope = 'bootstrap-jvm-tools'
context = self.context(options=options, target_roots=[self.target(spec) for spec in specs],
for_subsystems=[JvmPlatform],
for_task_types=[BootstrapJvmTools])
for_subsystems=[JvmPlatform])
context.products.safe_create_data('compile_classpath',
init_func=ClasspathProducts.init_func(self.pants_workdir))
bootstrap_task = BootstrapJvmTools(context, self.pants_workdir)
bootstrap_task.execute()
task = self.create_task(context)
return list(task.console_output(list(task.context.targets()),
context.products.get_data('compile_classpath')))
Expand Down Expand Up @@ -290,27 +249,7 @@ def test_without_dependencies(self):
def test_version(self):
result = self.execute_export_json('project_info:first')
# If you have to update this test, make sure export.md is updated with changelog notes
self.assertEqual('1.0.11', result['version'])

def test_scala_platform_custom(self):
result = self.execute_export_json('project_info:first')
scala_platform = result['scala_platform']
scala_version = scala_platform['scala_version']
self.assertEqual(scala_version, 'custom')
scala_jars = scala_platform['compiler_classpath']
self.assertTrue(any(self._scala_toolchain_version in jar_path for jar_path in scala_jars))

def test_scala_platform_standard(self):
result = self.execute_export_json('project_info:first', **{
ScalaPlatform.options_scope: {
'version': '2.12'
}
})
scala_platform = result['scala_platform']
scala_version = scala_platform['scala_version']
self.assertEqual(scala_version, '2.12')
scala_jars = scala_platform['compiler_classpath']
self.assertTrue(any('2.12' in jar_path for jar_path in scala_jars))
self.assertEqual('1.0.10', result['version'])

def test_sources(self):
self.set_options(sources=True)
Expand Down

0 comments on commit f673fd2

Please sign in to comment.