commit | 2150866288e5dcdf6117a96cc427158e32c221a3 | [log] [tgz] |
---|---|---|
author | Michael Bolin <mbolin@fb.com> | Wed Sep 11 12:29:58 2013 -0700 |
committer | Michael Bolin <mbolin@fb.com> | Thu Sep 19 15:25:01 2013 -0700 |
tree | fe811cf1c6d82c6ecd168b5d1f0c571a96f6a125 | |
parent | 8fbbbda4a6d4b9843eb741acd898346be1730bc2 [diff] |
Stop storing the build file on BuildTarget. Summary: Historically, `BuildTarget` required its corresponding build file to be passed in as a constructor argument, where preconditions verified that the build file existed and its path matched the target's path. These strong preconditions were introduced in hopes of preventing errors. In practice, this was a bad choice because it made creating a `BuildTarget` more difficult, as its constructor had to touch the filesystem. As one could imagine, this was quite a pain when it came to writing unit tests. Instead of being a typesafe string, `BuildTarget` was much more complicated. We had to go to great pains to tolerate null build files in fake `BuildTarget`s for tests. This diff removes that complexity. Now, to get the build file associated with a `BuildTarget`, one must invoke `BuildTarget`'s new `getBuildFile(ProjectFilesystem)` method, which throws a `MissingBuildFileException` if there is no file at the path that corresponds to the `BuildTarget`. The `MissingBuildFileException` introduced in this diff is similar to the `NoSuchBuildTargetException` in the `com.facebook.buck.parser` package. The problem is that the `parser` package depends on the `model` package, so a `BuildTarget` could not throw a `NoSuchBuildTarget` exception itself without unwinding quite a few things. This is why the new `MissingBuildFileException` was introduced. Further, a common superclass, `BuildTargetException`, was introduced in order to simplify catch blocks throughout the code. Its two child classes are `NoSuchBuildTargetException` and `MissingBuildFileException`. This diff makes `BuildTargetFactory` largely unnecessary, though it does not delete it outright. Replacing the `BuildTarget(String, String)` constructor with a `BuildTarget(String)` constructor that takes a single parameter and splits on the colon itself will ultimately eliminate the need for `BuildTargetFactory` altogether. This will be done in a follow-up diff. Test Plan: Sandcastle builds.
Buck is an Android build tool. To see what Buck can do for you, check out the documentation at http://facebook.github.io/buck/.
To build Buck, run the following:
git clone git@github.com:facebook/buck.git cd buck ant ./bin/buck --help
Apache License 2.0