Introduce a `--no-cache` option that will ignore the `[cache]` in .buckconfig.

Summary:
We have gotten some reports of errors with bad caching in the wild.
Users are currently working around these by running `buck clean`.
We would prefer it if they ran with `--no-cache` to verify that a
corrupted build cache is the true cause of their problems.

To introduce `--no-cache`, we have to defer the construction of the
`ArtifactCache` until after the `AbstractCommandOptions` are instantiated,
as we have to know whether the user passed `--no-cache` before trying
to create the `ArtifactCache`. To that end, this diff introduces the
concept of an `ArtifactCacheFactory`, which makes it possible to
defer the construction of the `ArtifactCache`.

Previously, the `ArtifactCache` was constructed for all Buck commands.
Now, for commands like `buck clean`, the `ArtifactCache` should never
need to be created.

This diff renames `AbstractCommandRunner.runCommandWithOptions()` to
`AbstractCommandRunner.runCommandWithOptionsInternal()`, and then
reimplements `runCommandWithOptions()` to invoke
`runCommandWithOptionsInternal()`. This is done to guarantee that
`this.options` is set in `AbstractCommandRunner` before
`runCommandWithOptionsInternal()` is invoked. The `options` field must be
set so that `getArtifactCache()` does not fail a precondition check.

Many of the unit tests in the `com.facebook.buck.cli` package injected
their own `ArtifactCache` for testing purposes.
An `InstanceArtifactCacheFactory` is introduced in this diff to
facilitate that injection.

Test Plan: Updated DefaultJavaLibraryRuleIntegrationTest to verify `--no-cache`.
25 files changed
tree: d030b248fca87506766feaeb82642ba13ed11ce5
  1. .idea/
  2. bin/
  3. config/
  4. docs/
  5. lib/
  6. pmd/
  7. scripts/
  8. src/
  9. test/
  10. testdata/
  11. third-party/
  12. .buckconfig
  13. .classpath
  14. .gitignore
  15. .project
  16. buck.iml
  17. build.xml
  18. DEFS
  19. LICENSE
  20. README.md
README.md

Buck

Buck is an Android build tool. To see what Buck can do for you, check out the documentation at http://facebook.github.io/buck/.

Installation

To build Buck, run the following:

git clone git@github.com:facebook/buck.git
cd buck
ant
./bin/buck --help

License

Apache License 2.0