Drush Make: How to create a drush make file

Usually when I start a new website I always need the latest version of Drupal and basic modules such us Ctools, Views, Entity, Token etc... So every time I used to download Drupal core and all the modules I needed. While the dommands drush dl and drush en are really useful, it was still a waste of time doing this every time. To save time I started to use drush .make file in order to speed up the process.
In this article I will explain how to create a drush make file that downloads Drupal core, contrib modules and apply patches.

Here the is an example of a .make file that installs the latest version of Drupal core, some basic modules and a module in its dev version with a patch to apply.

The file starts with Make API version:

; Drush Make API version
api = 2

 

Then we add the Drupal core. It will download the latest core version:

; Drush Make API version
api = 2
 
; Lastest version of Drupal core.
core = 7.x
projects[] = drupal

 

You can also download a particular version of Drupal core:

; Drush Make API version
api = 2
 
; Version 7.51 Drupal core.
core = 7.x
projects[drupal][version] = 7.51

 

At this point we can start to add our modules.
Download latest version of a module into the subdirectory contrib:

; Latest version of ctools
projects[ctools][subdir] = "contrib"

 

Download a specific version of a module:

; Specific version of ctools
projects[ctools][version] = 7.x-1.7
projects[ctools][subdir] = "contrib"

 

Download a module from git:

; Ctools from git
projects[ctools][type] = "module"
projects[ctools][subdir] = "contrib"
projects[ctools][download][type] = git
projects[ctools][download][url] = http://git.drupal.org/project/ctools.git
projects[ctools][download][branch] = 7.x-1.x
projects[ctools][download][revision] = ea01fb29ee21b86457acd1a4e40b092f4ca157e4

 

After you have included the modules either using one of the method above you can apply the patch.
In this example I will use the first method. Apply a Patch to a module:

; Latest version of ctools
projects[ctools][subdir] = "patched"
; Patch Add class containing the "modal style" to modal. https://www.drupal.org/node/1532174#comment-9960539
projects[ctools][patch][] = https://www.drupal.org/files/issues/ctools-add_css_class_to_modal_container-1532174-18.patch

 

You can add your libraries:

; Libraries
; snabbt http://daniel-lundin.github.io/snabbt.js/index.html
libraries[snabbt][download][type] = "file"
libraries[snabbt][download][url] = https://github.com/daniel-lundin/snabbt.js/releases/download/v0.5.4/snabbt.min.js

 

Here's an examle of a .make file that will download the latest version of Drupal core an some basic modules: vincenzogambino.make

More information about Make can be found here: Drush Make