Stole some build.gradle ideas from @cazzar