Allow the buildroot to be a subdirectory of the git worktree

This allows the buildroot to be a subdirectory of the git worktree, which supports a usecase we have internally where two pants builds will live within the same git repo for a while until they can be merged.

- Add a class method to attempt to detect a git worktree
- Report changed_files relative_to some directory (usually the buildroot)

Testing Done:
- confirmed that files outside the relative_to path/directory are ignored
- added test for worktree detection at various levels of nesting
- `./pants goal changed` and `./pants goal bundle` succeed in a buildroot below the worktree root (and in existing projects)

Bugs closed: 405

Reviewed at https://rbcommons.com/s/twitter/r/886/
Support absolute paths for spec_paths when they start with the build root and are supplied on the command line.

As proposed and discussed here: https://groups.google.com/d/topic/pants-devel/scbY4MM1XdM/discussion

Testing Done:
$ PANTS_DEV=1 ./pants goal test tests/python/pants_test/base/:cmd_line_spec_parser

Bugs closed: 471

Reviewed at https://rbcommons.com/s/twitter/r/867/
Deprecate the pants() wrapper from around pants() targets. Update docs, and add a deprecation message:

  *** pants() wrapper is obsolete and will be removed in a future release. See http://pantsbuild.github.io/build_files.html ***

Testing done:

Compile pants, saw new warning.  Scanned the docs locally running build-support/bin/publish_docs.sh and made sure url in warning worked.

Bugs closed: 486

Reviewed at: https://rbcommons.com/s/twitter/r/903/
Moved non-production code out of src/

Followon to https://rbcommons.com/s/twitter/r/868/

- Moved non-java targets into the 'examples' top level directory
- Moved projects used just for testing into the 'testprojects' top
level directory.
- updated docs and ci.sh accordingly

Testing Done:
CI is running (https://travis-ci.org/pantsbuild/pants/builds/32502524)

Bugs closed: 477

Reviewed at https://rbcommons.com/s/twitter/r/881/
Removed pants() references in all project BUILD files

Followon to https://rbcommons.com/s/twitter/r/903/

Mechanical refactor of BUILD files to get rid of deprecated use of pants() wrapper around targets:

    sed -i "" -e 's/pants(([^)]))/\1/g' `find . -name "BUILD"`

Testing Done:
CI is green (https://travis-ci.org/pantsbuild/pants/builds/32717695)

Bugs closed: 487

Reviewed at https://rbcommons.com/s/twitter/r/904/
JarsignerTask and Keystore Target

This adds a new Keystore target and a JarsignerTask. It outputs
the finished apk, which can be verified by pointing it at the sample
code and installing the apk it outputs.

Pants can now output debug and publishable release builds.
The release keystore is removed from version control,
although we will be layering another level of protections
with the release keystore handling in the future.

This bundles an (insecure) debug.keystore, which is scheduled
to be removed soon once we add in the KeytoolTask.

Testing Done:
CI.sh passes.
Travis passes [0]

[0] https://travis-ci.org/pantsbuild/pants/jobs/32476705

Reviewed at https://rbcommons.com/s/twitter/r/883/
Rename Phase -> Goal.

This change deals with phase.py (now goal.py) and things that
depend on it.

CI passes: https://travis-ci.org/pantsbuild/pants/builds/32484729

Future mop-up changes will fix extant uses of the term 'phase'
in various files, and also fix documentation appropriately.

Reviewed at https://rbcommons.com/s/twitter/r/887/
Rename the ':phase' target to ':goal'.

Reviewed in https://rbcommons.com/s/twitter/r/890/.
Fixup JvmRun  only-write-cmd-line flag to accept relative paths.

Introduce expand_path fs utility and use it on JvmRun.
Add tests for this new util and JvmRun's cmdline-only mode.

Testing Done:
$ PANTS_DEV=1 ./pants goal test tests/python/pants_test/tasks/:jvm_run tests/python/pants_test/fs --test-pytest-options="-v -k'test_jvm_run or test_expand_path'"
...
11:10:49 00:00   [test]
11:10:49 00:00     [pytest]
11:10:49 00:00       [run]
                     ============== test session starts ===============
                     platform linux2 -- Python 2.6.9 -- py-1.4.23 -- pytest-2.6.1 -- /usr/bin/python2.6
                     plugins: cov, timeout
                     collected 12 items

                     tests/python/pants_test/fs/test_expand_path.py::ExpandPathTest::test_absolute PASSED
                     tests/python/pants_test/fs/test_expand_path.py::ExpandPathTest::test_dot_relative PASSED
                     tests/python/pants_test/fs/test_expand_path.py::ExpandPathTest::test_env_var_expansion PASSED
                     tests/python/pants_test/fs/test_expand_path.py::ExpandPathTest::test_pure_relative PASSED
                     tests/python/pants_test/fs/test_expand_path.py::ExpandPathTest::test_user_expansion PASSED
                     tests/python/pants_test/tasks/test_jvm_run.py::JvmRunTest::test_cmdline_only PASSED

                      6 tests deselected by '-ktest_jvm_run or test_expand_path'
                     ===== 6 passed, 6 deselected in 0.19 seconds =====

11:10:50 00:01     [junit]
11:10:50 00:01     [specs]
               SUCCESS

Bugs closed: 494, 495

Reviewed at https://rbcommons.com/s/twitter/r/908/
Fixup always True test.

I horked this in diff 2 of https://rbcommons.com/s/twitter/r/908/

commit 6ad878ccbc6654be068e3670feca659de4dbb41d
Author: John Sirois <jsirois@twitter.com>
Date:   Mon Aug 18 12:38:27 2014 -0600

    Fixup always True test.

 tests/python/pants_test/tasks/test_jvm_run.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Testing Done:
$ PANTS_DEV=1 ./pants goal test tests/python/pants_test/tasks/:jvm_run --test-pytest-options=-v
...
13:25:44 00:01   [test]
13:25:44 00:01     [pytest]
13:25:44 00:01       [run]
                     ============== test session starts ===============
                     platform linux2 -- Python 2.6.9 -- py-1.4.23 -- pytest-2.6.1 -- /usr/bin/python2.6
                     plugins: cov, timeout
                     collected 1 items

                     tests/python/pants_test/tasks/test_jvm_run.py::JvmRunTest::test_cmdline_only PASSED

                     ============ 1 passed in 0.17 seconds ============

13:25:45 00:02     [junit]
13:25:45 00:02     [specs]
               SUCCESS

Bugs closed: 494, 496

Reviewed at https://rbcommons.com/s/twitter/r/911/
Clean up almost all extant uses of the obsolete term 'phase'.

The only remaining ones are in builddictionary.py and its test,
goals_reference.mustache, and various .rst files.

Reviewed in https://rbcommons.com/s/twitter/r/910/.
Fix documentation references to "phase".

Removes references to the old Goal (now TaskRegistrar) class, as it's
no longer an important concept. All the reader needs to know about
are Goals (formerly Phases) and Tasks.

Also fixed some incorrect/out-of-date documentation around GroupTasks.

Reviewed at https://rbcommons.com/s/twitter/r/913/
Fix eclipse_gen idea_gen for targets with both Java and Scala

eclipse_gen.py was completely broken:
* Use self.context instead of argument (fixes 1d68bf9d0c)
* Add missing templates
* Fix paths to jars in generated .classpath
* Add test_eclipse_integration.py based on test_idea_integration.py

Both Eclipse and IntelliJ generators were broken for targets that depend on a
library with both Scala and Java source code. They failed to add the Java
dependencies.

ide_gen.py: recurse into Java source dependencies for ScalaLibraries
scaladepsonboth: Example target that depends on a mixed Scala/Java project

Testing Done:
PANTS_DEV=1 ./pants goal test tests/python/pants_test/tasks:integration

I also verified that both IntelliJ and Eclipse can build the generated project for src/scala/com/pants/testproject/scaladepsonboth. The current master doesn't work on either, due to missing a Java source dependency.

Reviewed at https://rbcommons.com/s/twitter/r/857/
Remove all references to phase from builddict and related docs.

Phase is now goal, and goal is now task.

Testing Done:
Ran the unit tests.

Generate the docs locally and clicked around them manually to verify that the text makes sense, hyperlinks work etc.

Reviewed at https://rbcommons.com/s/twitter/r/915/
Remove some BUILD file aliases.

There should be no reason to need these in BUILD files.

Also removed a test that relied on one of the removed aliases. This
test wasn't really testing anything anyway. We don't support registering
tasks in BUILD files any more.

Testing Done:
All unittests. CI baking.

Reviewed at https://rbcommons.com/s/twitter/r/912/
Fixup EclipseGen resources globs to include prefs.

Also upgrade PantsRunIntegrationTest to unittest2.

Testing Done:
$ PANTS_DEV=1 ./pants goal test tests/python/pants_test/tasks:eclipse_integration --test-pytest-options='-vs'
...
16:50:51 00:01   [test]
16:50:51 00:01     [pytest]
16:50:51 00:01       [run]
                     ============== test session starts ===============
                     platform linux2 -- Python 2.6.9 -- py-1.4.23 -- pytest-2.6.1 -- /usr/bin/python2.6
                     plugins: cov, timeout
                     collected 9 items

                     tests/python/pants_test/tasks/test_eclipse_integration.py::EclipseIntegrationTest::test_eclipse_on_all_examples PASSED
                     tests/python/pants_test/tasks/test_eclipse_integration.py::EclipseIntegrationTest::test_eclipse_on_annotations PASSED
                     tests/python/pants_test/tasks/test_eclipse_integration.py::EclipseIntegrationTest::test_eclipse_on_hello PASSED
                     tests/python/pants_test/tasks/test_eclipse_integration.py::EclipseIntegrationTest::test_eclipse_on_java_sources PASSED
                     tests/python/pants_test/tasks/test_eclipse_integration.py::EclipseIntegrationTest::test_eclipse_on_jaxb PASSED
                     tests/python/pants_test/tasks/test_eclipse_integration.py::EclipseIntegrationTest::test_eclipse_on_protobuf PASSED
                     tests/python/pants_test/tasks/test_eclipse_integration.py::EclipseIntegrationTest::test_eclipse_on_scaladepsonboth PASSED
                     tests/python/pants_test/tasks/test_eclipse_integration.py::EclipseIntegrationTest::test_eclipse_on_thriftdeptest PASSED
                     tests/python/pants_test/tasks/test_eclipse_integration.py::EclipseIntegrationTest::test_eclipse_on_unicode PASSED

                     =========== 9 passed in 19.66 seconds ============

16:51:11 00:21     [junit]
16:51:11 00:21     [specs]
               SUCCESS

Travis CI went green here: https://travis-ci.org/pantsbuild/pants/builds/32908116

Bugs closed: 497

Reviewed at https://rbcommons.com/s/twitter/r/916/
this might help Twitter's internal Pants to see the resources useful for markdown goal

Inside Twitter, './pants goal markdown' fails trying to load the page.mustache resource file.
But './pants goal builddict' works, and I know that uses resources.
I see that when TDesai fixed some resource-breakage, she edited this section.
And I see that this section mentions templates/builddictionary but not templates/markdown, so I'm hopeful; even though I'm vague about some (most?) parts of the pants->internal pants ritual.

Testing Done:
https://travis-ci.org/pantsbuild/pants/builds/32912323

Bugs closed: 498

Reviewed at https://rbcommons.com/s/twitter/r/918/
Make :: fail for an invalid dir much like : does for a dir with no BUILD file.

Testing Done:
$ PANTS_DEV=1 ./pants goal test tests/python/pants_test/base/:cmd_line_spec_parser --test-pytest-options=-v
...
17:20:09 00:00   [test]
17:20:09 00:00     [pytest]
17:20:09 00:00       [run]
                     ============== test session starts ===============
                     platform linux2 -- Python 2.6.9 -- py-1.4.23 -- pytest-2.6.1 -- /usr/bin/python2.6
                     plugins: cov, timeout
                     collected 7 items

                     tests/python/pants_test/base/test_cmd_line_spec_parser.py::CmdLineSpecParserTest::test_absolute PASSED
                     tests/python/pants_test/base/test_cmd_line_spec_parser.py::CmdLineSpecParserTest::test_cmd_line_affordances PASSED
                     tests/python/pants_test/base/test_cmd_line_spec_parser.py::CmdLineSpecParserTest::test_cmd_line_spec_list PASSED
                     tests/python/pants_test/base/test_cmd_line_spec_parser.py::CmdLineSpecParserTest::test_does_not_exist PASSED
                     tests/python/pants_test/base/test_cmd_line_spec_parser.py::CmdLineSpecParserTest::test_normal PASSED
                     tests/python/pants_test/base/test_cmd_line_spec_parser.py::CmdLineSpecParserTest::test_sibling PASSED
                     tests/python/pants_test/base/test_cmd_line_spec_parser.py::CmdLineSpecParserTest::test_sibling_or_descendents PASSED

                     ============ 7 passed in 0.10 seconds ============

17:20:43 00:34     [junit]
17:20:43 00:34     [specs]
               SUCCESS

And travis CI went green here: https://travis-ci.org/pantsbuild/pants/builds/32910349

Bugs closed: 484, 492

Reviewed at https://rbcommons.com/s/twitter/r/907/
Fixed 'pants goal targets'

As Jin pointed out in issue 333, pants goal targets is broken. Its pretty easy to patch it up, but it relies on a fixed list of alias-> target classes, which is ugly and seemingly redundant.

Larry says we could just remove it. Or we could try to keep it going. I'm fine with either decision, I just don't like broken commands sitting around, I think it sets bad precedent.

Testing Done:
added test to ci.sh, its green: https://travis-ci.org/pantsbuild/pants/builds/32858261

Bugs closed: 493

Reviewed at https://rbcommons.com/s/twitter/r/914/
Remove some straggling pants() wrappers from the repo

Testing Done:
CI is running https://travis-ci.org/pantsbuild/pants/builds/32976397

Bugs closed: 502

Reviewed at https://rbcommons.com/s/twitter/r/921/