Apply temporary workaround for GRADLE-3082, and upgrade Gradle to 1.12.
Previous commit only laid the groundwork, this commit actually upgrades Gradle to 1.12.