Skip to content

Commit

Permalink
Include strict_deps in export output.
Browse files Browse the repository at this point in the history
Previously, the `./pants export` output did not include information
whether a target has enabled strict dependencies or not. This
information is needed in order to faithfully reproduce the compilation
outside of Pants, for example with the IntelliJ compiler or with Bloop
see (scalameta/metals#935).
  • Loading branch information
Olafur Pall Geirsson committed Dec 2, 2019
1 parent 97cddca commit 7a61dcf
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/python/pants/backend/project_info/tasks/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,12 @@ def iter_transitive_jars(jar_lib):

if classpath_products:
info['libraries'] = [self._jar_id(lib) for lib in target_libraries]

strict_deps = False
if hasattr(current_target, 'strict_deps'):
strict_deps = True == getattr(current_target, 'strict_deps')
info['strict_deps'] = strict_deps

targets_map[current_target.address.spec] = info

for target in targets:
Expand Down
19 changes: 19 additions & 0 deletions tests/python/pants_test/backend/project_info/tasks/test_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,18 @@ def setUp(self):
target_type=JvmTarget,
)

self.make_target(
'strict_deps:enabled',
target_type=JvmTarget,
strict_deps=True
)

self.make_target(
'strict_deps:disabled',
target_type=JvmTarget,
strict_deps=False
)

self.add_to_build_file('src/python/x/BUILD', """
python_library(name="x", sources=globs("*.py"))
""".strip())
Expand Down Expand Up @@ -358,6 +370,12 @@ def test_scala_platform_standard(self):
scala_jars = scala_platform['compiler_classpath']
self.assertTrue(any('2.12' in jar_path for jar_path in scala_jars))

def test_strict_deps(self):
enabled_result = self.execute_export_json('strict_deps:enabled')['targets']['strict_deps:enabled']
disabled_result = self.execute_export_json('strict_deps:disabled')['targets']['strict_deps:disabled']
self.assertTrue(enabled_result['strict_deps'])
self.assertFalse(disabled_result['strict_deps'])

def test_sources(self):
self.set_options(sources=True)
result = self.execute_export_json('project_info:third')
Expand Down Expand Up @@ -418,6 +436,7 @@ def test_jvm_target(self):
},
],
'scope' : 'default',
'strict_deps' : False,
'target_type': 'SOURCE',
'transitive' : True,
'pants_target_type': 'scala_library',
Expand Down

0 comments on commit 7a61dcf

Please sign in to comment.