Buck: Trigger pack_war invocation when one of transitive deps changed

Buck version was upgraded in If336ea8697. This version contains
behavioral change for genrule()'s rules. Since: [1] the caching
behavior was switched to input-based keys. So that the command in
genrule() is executed only when one of the input keys has changed.
This massive change in behavior broke Gerrit build toolchain in
very subtle way: when gerrit.war was built once, it wasn't rebuilt
any more unless caches were invalidated.  To understand why this
is the case, some background understanding needed how gerrit.war
is packaged in our build toolchain. Gathering of gerrit.war is done
by genrule() that executes python script that retrieves the needed
libraries by issuing buck audit classpath. However, since: [1] this
python script is not invoked any more, when some libraries in
transitive dependency chain have changed, because only very few
libraries specified as the input to this python rule and the rest of
the dependencies is retrieved in dynamic way in the script itself.
So when some source code was changed, and corresponding library, say
gerrit-server was changed as well, the first order dependency to the
python script, like gerrit-pgm wasn't changed, and thus its rule key
remained stable, so that pack_war.py wasn't invoked any more, leaving
gerrit.war stale.

The reproducer for this problem can be found here: [2]. The upstream
issue is here: [3].

The fix is straight forward: instead of passing only the first order
dependencies to the war packager script (that cannot reliably be done
after changed caching behavior of genrule() in: [1]) and issue buck
audit classpath in python script, pass the whole classpath from Buck
build file to war packager. For one this will fix the caching issue,
as the rule key now reflects the whole classpath and thus would change
if some deps in transitive dependency chain would change, for another
we wouldn't have to retrieve the classpath twice: in Buck build itself
and in war packager script.

[1] https://github.com/facebook/buck/commit/143646f4ccd8737f73a2667a244c4c38dc18cb89
[2] https://github.com/davido/buck_genrule_changed_caching_behaviour_143646f
[3] https://github.com/facebook/buck/issues/470

Test plan:

* buck build gitiles
* change some sources in gitiles-servlet project
* buck build gitiles
* verify that gitiles.war was rebuilt in previous step and reflect the
  changes made in gitiles-servlet project

Reported-By: Doug Kelly <dougk.ff7@gmail.com>
Change-Id: I5e22e2d46c82fa5071db34762bda1655d6d353bf
2 files changed