Skip to content
This repository
Browse code

Merge pull request #31 from benjyw/master

Allow scalac and javac builds to be unflattened.
  • Loading branch information...
commit 29660971d65e5e94b96a9be66e26ff48d2b2598e 2 parents 7f853fc + 398e2bf
John Sirois jsirois authored
16 src/python/twitter/pants/tasks/java_compile.py
@@ -24,6 +24,7 @@
24 24 from twitter.common.dirutil import safe_open, safe_mkdir
25 25 from twitter.pants import is_apt
26 26 from twitter.pants.targets import JavaLibrary, JavaTests
  27 +from twitter.pants.targets.internal import InternalTarget
27 28 from twitter.pants.tasks import TaskError
28 29 from twitter.pants.tasks.binary_utils import nailgun_profile_classpath
29 30 from twitter.pants.tasks.jvm_compiler_dependencies import Dependencies
@@ -75,6 +76,12 @@ def setup_parser(cls, option_group, args, mkflag):
75 76 help="[%default] Compile java code with all configured warnings "
76 77 "enabled.")
77 78
  79 + option_group.add_option(mkflag("flatten"), mkflag("flatten", negate=True),
  80 + dest="java_compile_flatten", default=True,
  81 + action="callback", callback=mkflag.set_bool,
  82 + help="[%default] Compile java code for all dependencies in a "
  83 + "single pass.")
  84 +
78 85 def __init__(self, context):
79 86 NailgunTask.__init__(self, context, workdir=context.config.get('java-compile', 'nailgun_dir'))
80 87
@@ -94,9 +101,18 @@ def __init__(self, context):
94 101 else:
95 102 self._args.extend(context.config.getlist('java-compile', 'no_warning_args'))
96 103
  104 + self._flatten = context.options.java_compile_flatten
97 105 self._confs = context.config.getlist('java-compile', 'confs')
98 106
99 107 def execute(self, targets):
  108 + if not self._flatten and len(targets) > 1:
  109 + topologically_sorted_targets = filter(JavaCompile._is_java, reversed(InternalTarget.sort_targets(targets)))
  110 + for target in topologically_sorted_targets:
  111 + self.execute([target])
  112 + return
  113 +
  114 + self.context.log.info('Compiling targets %s' % str(targets))
  115 +
100 116 java_targets = filter(JavaCompile._is_java, targets)
101 117 if java_targets:
102 118 with self.context.state('classpath', []) as cp:
16 src/python/twitter/pants/tasks/scala_compile.py
@@ -27,6 +27,7 @@
27 27 from twitter.pants.targets.scala_library import ScalaLibrary
28 28 from twitter.pants.targets.scala_tests import ScalaTests
29 29 from twitter.pants.targets import resolve_target_sources
  30 +from twitter.pants.targets.internal import InternalTarget
30 31 from twitter.pants.tasks import TaskError
31 32 from twitter.pants.tasks.binary_utils import nailgun_profile_classpath
32 33 from twitter.pants.tasks.jvm_compiler_dependencies import Dependencies
@@ -48,6 +49,12 @@ def setup_parser(cls, option_group, args, mkflag):
48 49 help="[%default] Compile scala code with all configured warnings "
49 50 "enabled.")
50 51
  52 + option_group.add_option(mkflag("flatten"), mkflag("flatten", negate=True),
  53 + dest="scala_compile_flatten", default=True,
  54 + action="callback", callback=mkflag.set_bool,
  55 + help="[%default] Compile scala code for all dependencies in a "
  56 + "single pass.")
  57 +
51 58 def __init__(self, context):
52 59 NailgunTask.__init__(self, context, workdir=context.config.get('scala-compile', 'nailgun_dir'))
53 60
@@ -73,10 +80,19 @@ def __init__(self, context):
73 80 else:
74 81 self._args.extend(context.config.getlist('scala-compile', 'no_warning_args'))
75 82
  83 + self._flatten = context.options.scala_compile_flatten
76 84 self._confs = context.config.getlist('scala-compile', 'confs')
77 85 self._depfile = os.path.join(workdir, 'dependencies')
78 86
79 87 def execute(self, targets):
  88 + if not self._flatten and len(targets) > 1:
  89 + topologically_sorted_targets = filter(is_scala, reversed(InternalTarget.sort_targets(targets)))
  90 + for target in topologically_sorted_targets:
  91 + self.execute([target])
  92 + return
  93 +
  94 + self.context.log.info('Compiling targets %s' % str(targets))
  95 +
80 96 scala_targets = filter(is_scala, targets)
81 97 if scala_targets:
82 98 with self.context.state('classpath', []) as cp:

0 comments on commit 2966097

Please sign in to comment.
Something went wrong with that request. Please try again.