Skip to content

Commit

Permalink
Fix broken export-classpath (pantsbuild#4603)
Browse files Browse the repository at this point in the history
### Problem

I'd assumed that ClassPathUtils.classpath would take just the root targets, and that it didn't apply excludes correctly when the closure was passed. That was incorrect.

Doing that would cause export-classpath to return an invalid classpath

### Solution

Revert that change, and update the regression test to be more comprehensive.

### Result

export-classpath works correctly again, and the regression test covers the excludes case more effectively.
  • Loading branch information
baroquebobcat authored May 17, 2017
1 parent eaf036b commit c0a8b21
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def _output_folder(self):
def execute(self):
basedir = os.path.join(self.get_options().pants_distdir, self._output_folder)
runtime_classpath = self.context.products.get_data('runtime_classpath')
targets = self.context.target_roots
targets = self.context.targets()
if self.get_options().manifest_jar_only:
classpath = ClasspathUtil.classpath(targets, runtime_classpath)
# Safely create e.g. dist/export-classpath/manifest.jar
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ jar_library(name = 'zinc',
java_library(name='foo',
sources=globs('Main.java'),
dependencies=[
':baz',
':zinc',
],
excludes=[
Expand All @@ -35,3 +36,7 @@ java_library(name='bar',
':jmake',
]
)

java_library(name='baz',
sources=globs('Main.java'),
)
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ def test_export_classpath_file_with_excludes(self):

with open_zip(manifest_jar_path) as synthetic_jar:
self.assertListEqual([Manifest.PATH], synthetic_jar.namelist())
oneline_classpath = synthetic_jar.read(Manifest.PATH).replace('\n', '')
self.assertNotIn('sbt', oneline_classpath)
oneline_classpath = synthetic_jar.read(Manifest.PATH).replace('\n', '').replace(' ', '')
self.assertNotIn('sbt-interface', oneline_classpath)
self.assertIn('foo', oneline_classpath)
self.assertIn('baz', oneline_classpath)

0 comments on commit c0a8b21

Please sign in to comment.