Posted on 17 April, 2013 (8 years ago)
Since I started using Gradle
for building my projects, as soon as I needed to create a brand new project from scratch, I wished that Gradle guided my hand and created the right directory structure and minimal Gradle build script.
A bit less than two years ago, I was inspired by Dierk's gist
providing a basic build that provided two tasks, one for creating the directory layout, and the other one to create the Gradle wrapper. I turned that gist into a blog post of my own
, with just minor version updates, as I wanted to remember how to do that the next time I'd create a new Gradle-based project.
But we were not the only ones missing this capability in Gradle!
More recently, Marcin leveraged the init script capabilities of Gradle
to make the process a bit smoother, so that we don't have to blindly and stupidly copy and paste the same sample build script each time. With his approach, we add the project layout and wrapper creation in the ~/.gradle/init.gradle script, so that it's available in your new projects by default.
Last but not least, just the other day, Erik came up with a similar approach
as the original gist for creating projects, with some more flags to customize which directories we want created.
But the good news is that this often needed feature is actually getting some attention from our Gradle(ware) friends, and we're going to see some form of project creation in Gradle 1.6 soon, as shown in this design document
Ultimately, creating a template project and a Gradle wrapper will likely be as simple as:
gradle setupBuild --type groovy-library
And then, no more hacks needed, you'll have a nice and ready-to-build project in matter of mere seconds, without resorting to our various tactics listed above!
I'm looking forward to Gradle 1.6 even if just for that new capabilities we've all been longing for!