SPARK-1084 (part 1). Fix most build warnings.

This is a redo of https://github.com/apache/incubator-spark/pull/586

This contains all the same changes, minus dependency changes. It also rebases and squashes some commits that could be combined.

After this is in I'll propose part 2, which concerns dependencies.