{"action":"created","issue":{"url":"https://api.github.com/repos/pantsbuild/pants/issues/112","labels_url":"https://api.github.com/repos/pantsbuild/pants/issues/112/labels{/name}","comments_url":"https://api.github.com/repos/pantsbuild/pants/issues/112/comments","events_url":"https://api.github.com/repos/pantsbuild/pants/issues/112/events","html_url":"https://github.com/pantsbuild/pants/issues/112","id":33189357,"number":112,"title":"'goal compile' on java_thrift_library doesn't actually compile","user":{"login":"lahosken","id":371906,"avatar_url":"https://avatars.githubusercontent.com/u/371906?v=3","gravatar_id":"","url":"https://api.github.com/users/lahosken","html_url":"https://github.com/lahosken","followers_url":"https://api.github.com/users/lahosken/followers","following_url":"https://api.github.com/users/lahosken/following{/other_user}","gists_url":"https://api.github.com/users/lahosken/gists{/gist_id}","starred_url":"https://api.github.com/users/lahosken/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lahosken/subscriptions","organizations_url":"https://api.github.com/users/lahosken/orgs","repos_url":"https://api.github.com/users/lahosken/repos","events_url":"https://api.github.com/users/lahosken/events{/privacy}","received_events_url":"https://api.github.com/users/lahosken/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/pantsbuild/pants/labels/publishing","name":"publishing","color":"eb6420"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2014-05-09T16:57:45Z","updated_at":"2015-02-25T20:22:05Z","closed_at":null,"body":"to see...\r\n\r\nedit src/thrift/com/pants/examples/distance/distance.thrift:\r\n\r\n```\r\n struct Distance {\r\n-  1: optional string Unit;\r\n+  1: optional string Unit; totally broken\r\n   2: required i64 Number;\r\n```\r\n\r\n$  ./pants goal compile src/thrift/com/pants/examples/distance:distance-java\r\n\r\nHappily says \r\n\r\n```\r\n09:34:55 00:00   [compile]\r\n09:34:55 00:00     [jvm]\r\n               SUCCESS \r\n```\r\n\r\n$  ./pants goal test src/thrift/com/pants/examples/distance:distance-java\r\ngets SUCCESS\r\n$  ./pants goal compile tests/java/com/pants/examples/usethrift # <- test which deps on distance:java\r\ngets an ERROR (whew!)\r\n\r\nMmmaybe this is a problem w/Apache-thrift integration. I say this because putting a \r\ncompiler='scrooge',\r\ninto the BUILD target makes a compile happen. (if your thrift is bad, you get an error. if your thrift is good, you get class files in .pants.d.)\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/pantsbuild/pants/issues/comments/76047847","html_url":"https://github.com/pantsbuild/pants/issues/112#issuecomment-76047847","issue_url":"https://api.github.com/repos/pantsbuild/pants/issues/112","id":76047847,"user":{"login":"jsirois","id":157586,"avatar_url":"https://avatars.githubusercontent.com/u/157586?v=3","gravatar_id":"","url":"https://api.github.com/users/jsirois","html_url":"https://github.com/jsirois","followers_url":"https://api.github.com/users/jsirois/followers","following_url":"https://api.github.com/users/jsirois/following{/other_user}","gists_url":"https://api.github.com/users/jsirois/gists{/gist_id}","starred_url":"https://api.github.com/users/jsirois/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jsirois/subscriptions","organizations_url":"https://api.github.com/users/jsirois/orgs","repos_url":"https://api.github.com/users/jsirois/repos","events_url":"https://api.github.com/users/jsirois/events{/privacy}","received_events_url":"https://api.github.com/users/jsirois/received_events","type":"User","site_admin":false},"created_at":"2015-02-25T20:22:05Z","updated_at":"2015-02-25T20:22:05Z","body":"It has _everything_ to do with the scrooge compiler.  ScroogeGen does not inherit from CodeGen and so does not have the behavior I described (except it sort of does for unrelated reasons - see below :/).  Larry filed this issue as a non-Tweep, so I assume he is talking about OSS behavior.  In OSS pants, ApacheThriftGen is the default compiler for thfit with lang 'java'.  Its configured to be the opposite inside Twitter walls (or at least it was in birdcage).\r\n\r\nNow ScroogeGen does suffer a similar fate - but not intentionally like CodeGen descendants:\r\n```console\r\njsirois@gill ~/dev/3rdparty/pants (master *) $ git diff\r\ndiff --git a/contrib/scrooge/src/python/pants/contrib/scrooge/tasks/scrooge_gen.py b/contrib/scrooge/src/python/pants/contrib/scrooge/tasks/scrooge_gen.py\r\nindex 3973317..ff66dc7 100644\r\n--- a/contrib/scrooge/src/python/pants/contrib/scrooge/tasks/scrooge_gen.py\r\n+++ b/contrib/scrooge/src/python/pants/contrib/scrooge/tasks/scrooge_gen.py\r\n@@ -130,7 +130,9 @@ class ScroogeGen(NailgunTask, JvmToolTaskMixin):\r\n       for vt in invalidation_check.invalid_vts:\r\n         invalid_targets.extend(vt.targets)\r\n \r\n+      print('>>> invalid targets: {}'.format(invalid_targets))\r\n       import_paths, changed_srcs = calculate_compile_sources(invalid_targets, self.is_gentarget)\r\n+      print('>>> import paths: {} changed_srcs: {}'.format(import_paths, changed_srcs))\r\n       outdir = self._outdir(partial_cmd)\r\n       if changed_srcs:\r\n         args = []\r\n@@ -240,6 +242,10 @@ class ScroogeGen(NailgunTask, JvmToolTaskMixin):\r\n     tgt.add_labels('codegen')\r\n     for dependee in dependees:\r\n       dependee.inject_dependency(tgt.address)\r\n+    print('\\n>>> injected target {}'.format(tgt.address.spec))\r\n+    print('  with br sources {}'.format(tgt.sources_relative_to_buildroot()))\r\n+    print('  with sr sources {}'.format(list(tgt.sources_relative_to_source_root())))\r\n+    print('  as a dependency of {}'.format(dependees))\r\n     return tgt\r\n \r\n   def parse_gen_file_map(self, gen_file_map_path, outdir):\r\ndiff --git a/examples/src/thrift/com/pants/examples/distance/BUILD b/examples/src/thrift/com/pants/examples/distance/BUILD\r\nindex 24d08b7..04696ca 100644\r\n--- a/examples/src/thrift/com/pants/examples/distance/BUILD\r\n+++ b/examples/src/thrift/com/pants/examples/distance/BUILD\r\n@@ -4,8 +4,16 @@\r\n # trivial example of \"generally-useful\" thrift to include in other thrift\r\n # (to see how this is included, cd ../precipitation)\r\n \r\n+target(name='no_cities_to_love', dependencies=[':distance-java'])\r\n+\r\n java_thrift_library(name='distance-java',\r\n   sources=['distance.thrift'],\r\n+  provides=artifact(org='com.pants.examples',\r\n+    name='distance-thrift-java',\r\n+    repo=public),\r\n+  compiler='scrooge',\r\n+  language='java',\r\n+  rpc_style='finagle',\r\n )\r\n \r\n python_thrift_library(name='distance-python',\r\ndiff --git a/src/python/pants/backend/core/tasks/group_task.py b/src/python/pants/backend/core/tasks/group_task.py\r\nindex af3f7d7..dfeed52 100644\r\n--- a/src/python/pants/backend/core/tasks/group_task.py\r\n+++ b/src/python/pants/backend/core/tasks/group_task.py\r\n@@ -300,6 +300,7 @@ class GroupTask(Task):\r\n       # built.\r\n       ordered_chunks = []\r\n       chunks_by_member = defaultdict(list)\r\n+      print('>>> universe of targets:\\n\\t{}'.format('\\n\\t'.join(t.address.spec for t in self.context.targets())))\r\n       for group_member, chunk in GroupIterator(self.context.targets(), self._group_members):\r\n         ordered_chunks.append((group_member, chunk))\r\n         chunks_by_member[group_member].append(chunk)\r\njsirois@gill ~/dev/3rdparty/pants (master *) $ pants.dev clean-all compile examples/src/thrift/com/pants/examples/distance:distance-java -ldebug\r\n...\r\n13:16:14 00:00   [gen]\r\n13:16:14 00:00     [thrift]\r\n13:16:14 00:00     [protoc]DEBUG] Selected protoc binary bootstrapped to: /home/jsirois/.cache/pants/bin/protobuf/linux/x86_64/2.4.1/protoc\r\n\r\n13:16:14 00:00     [antlr]\r\n13:16:14 00:00     [ragel]\r\n13:16:14 00:00     [jaxb]\r\n13:16:14 00:00     [wire]\r\n13:16:14 00:00     [aapt]\r\n13:16:14 00:00     [scrooge]\r\n                   Invalidated 1 target.>>> invalid targets: [JavaThriftLibrary(BuildFileAddress(/home/jsirois/dev/3rdparty/pants/examples/src/thrift/com/pants/examples/distance/BUILD, distance-java))]\r\n>>> import paths: set([u'examples/src/thrift']) changed_srcs: set([u'examples/src/thrift/com/pants/examples/distance/distance.thrift'])\r\n...\r\n>>> injected target .pants.d/gen/scrooge/java-finagle:examples.src.thrift.com.pants.examples.distance.distance-java\r\n  with br sources [u'.pants.d/gen/scrooge/java-finagle/com/pants/examples/distance/thriftjava/Distance.java']\r\n  with sr sources [u'com/pants/examples/distance/thriftjava/Distance.java']\r\n  as a dependency of []\r\n\r\n13:16:16 00:02   [resolve]\r\n13:16:16 00:02     [ivy]\r\n13:16:16 00:02   [compile]\r\n13:16:16 00:02     [compile]\r\n13:16:16 00:02     [jvm]\r\n13:16:16 00:02       [jvm-compilers]>>> universe of targets:\r\n\texamples/src/thrift/com/pants/examples/distance:distance-java\r\n\r\n                     ::: created chunks(0)\r\n13:16:16 00:02     [python-eval]\r\n13:16:16 00:02       [eval-targets]\r\n13:16:16 00:02     [checkstyle]\r\n13:16:16 00:02     [scalastyle]\r\n                   Non synthetic scala targets to be checked:\r\n                   Non excluded scala sources to be checked:\r\n               SUCCESS\r\n```\r\n\r\nSo scrooge gen fails to add the synthetic java library to and dependees because there are none (your dummy target adds one and that's why this works).  More importantly, the synthetic target it adds to the context does not show up in self.context.targets().  That is a behavior change that came from the big target refactor in may and thus broke ScroogeGen.  If you read the code for add_new_target and targets in Context pre-refactor [1], you'll see the synthetic target would have shown up in self.context.targets() at that point in time.\r\n\r\nI encourage less thought and more code reading here.  Thinking is vastly over-rated.\r\n\r\n[1] https://github.com/pantsbuild/pants/blob/0ff02cdb36a3be15351c6838665afaa5e996d32b/src/python/pants/goal/context.py"}}