Automate your Builds

No one likes to do the same stuff lots of times. Copy a file from here to somewhere, start a bunch of services, do a tricky build with maven… all this shit are acceptable if you do one time and will never need to do it again. When you do it two or three times in a little space of time, you will write a script. Everyone does that. If you don’t, you should.

I realized that most of this scripts are project specific. In my case, at my daily job, I created a scripts folder inside project root folder, and start coding a bunch of scripts inside it.

I end up with a lot of replicated code. Stupid things like exporting MAVEN_OPTS and a lot of params to mvn executable. I could just put that in my dotfiles, but I it doesn’t make sense, since other projects will have other setup.

Another problem, is that lots of times I wanted to run a lot of scripts in one line, for example:

$ ./ && ./ && ./

I hate doing this thought. So, I believed that creating a Rakefile would fit good. But it doesn’t make any sense to put Ruby code with Java code just for this. Then, GNU Make looks a damn good option for me, and start hacking around it.

In first versions, I just put all my code inside the Makefile itself, but it starts to get big, and I decided to modularize.

So, I created the modular-build project with some @merencia contributions and ideas.


The base itself is not a big deal. It have just these files:

  • Documentation, just as expected;
  • Instalation script;
  • Makefile: The Makefile skelecton;
  • A base script that all other scripts will import. You can share stuff here between scripts (environment variables, functions). It already came with some funcions. You should take a look at them;
  • An clean example task;
  • A helper script to create tasks. make newtask will invoke it, ask for the task name, then create the .sh file based on and add it to Makefile.

The instalation is pretty easy, you can just call:

$ wget -qO- | bash

or, using curl:

$ curl -s | bash

After that, make newtask and start building your own scripts. Automate everything, put computers to work to you, not the opposite.

You can find more info in the project repo and also in the project site.

Also, you can give contributions and opinions, here, or in project issues.

Happy hacking!

Related Posts

Improving Jekyll build time

70% cheaper Kubernetes cluster on AWS

Writing cli applications with Golang