Skip to content

Commit

Permalink
Remove hack to add java_sources in context
Browse files Browse the repository at this point in the history
Testing Done:
Yes:
https://travis-ci.org/pantsbuild/pants/builds/37349364

Maunally generated idea for
./pants goal idea testprojects/src/scala/com/pants/testproject/javasources:javasources and
./pants goal idea testprojects/src/scala/com/pants/testproject/javasources:javasources --idea-intransitive

Both have dependent java_sources targets configured in generated Project Structure.

With Eric's hack to add java_sources in ide_gen for scala_library, we no longer need the java_sources to be added to the self.context targets.
https://github.com/pantsbuild/pants/blob/master/src/python/pants/backend/jvm/tasks/ide_gen.py#L552

Reviewed at https://rbcommons.com/s/twitter/r/1130/
  • Loading branch information
tejal29 authored and Tejal Desai committed Oct 8, 2014
1 parent d441fc2 commit 7e48e0a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 13 deletions.
8 changes: 0 additions & 8 deletions src/python/pants/backend/jvm/targets/scala_library.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
from pants.backend.jvm.targets.exportable_jvm_library import ExportableJvmLibrary
from pants.base.address import SyntheticAddress
from pants.base.exceptions import TargetDefinitionException
from pants.base.validation import assert_list


class ScalaLibrary(ExportableJvmLibrary):
Expand Down Expand Up @@ -71,10 +70,3 @@ def java_sources(self):
if target is None:
raise TargetDefinitionException(self, 'No such java target: %s' % spec)
yield target

def closure(self):
# Overrides the default implementation to return java_sources as well
target_set = super(ScalaLibrary, self).closure()
for java_source_target in self.java_sources:
target_set.update(java_source_target.closure())
return target_set
6 changes: 2 additions & 4 deletions src/python/pants/goal/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
from collections import defaultdict
from contextlib import contextmanager

from twitter.common.collections import OrderedSet
from twitter.common.dirutil import Lock
from twitter.common.process import ProcessProviderFactory
from twitter.common.process.process_provider import ProcessProvider
Expand Down Expand Up @@ -278,9 +277,8 @@ def targets(self, predicate=None):
:return: a list of targets evaluated by the predicate in inorder traversal order.
"""
target_set = OrderedSet()
for target in self._target_roots:
target_set.update(target.closure())
target_root_addresses = [target.address for target in self._target_roots]
target_set = self.build_graph.transitive_subgraph_of_addresses(target_root_addresses)
return filter(predicate, target_set)

def dependents(self, on_predicate=None, from_predicate=None):
Expand Down
5 changes: 4 additions & 1 deletion tests/python/pants_test/tasks/test_jvm_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@
class JvmRunTest(BaseTest):
def test_cmdline_only(self):
jvm_binary = self.make_target('src/java/com/pants:binary', JvmBinary, main="com.pants.Binary")
jvm_run = prepare_task(JvmRun, args=['--test-only-write-cmd-line=a'], targets=[jvm_binary])
jvm_run = prepare_task(JvmRun,
args=['--test-only-write-cmd-line=a'],
targets=[jvm_binary],
build_graph=self.build_graph)

round_manager = RoundManager(jvm_run.context)
jvm_run.prepare(round_manager)
Expand Down

0 comments on commit 7e48e0a

Please sign in to comment.