zotonic/zotonic — pull request #503 by amiramix (2013-01-22 00:00:15+00:00)
Title: Use Rebar to get, update and compile dependencies (and only dependencies)

Zotonic is still compiled with the good old method using Emakefile

This Pull Request contains the minimal amount of changes to leverage Rebar dependency management without changing the compilation process of Zotonic itself.

Rationale:

When Zotonic is used as a part of a bigger application, the internal Zotonic dependencies (in Zotonic's deps folder) can clash with dependencies of the main application. Imagine the following folder structure:

main_app/deps/cowboy
main_app/deps/lager
main_app/deps/charreada
main_app/deps/zotonic/deps/cowboy
main_app/deps/zotonic/deps/lager
etc...

In this case cowboy (if used by Zotonic) and lager would be compiled and started twice from different paths.

Also, all Zotonic dependencies use Rebar and Rebar manages its own dependencies pretty well. For example Ranch is listed as dependency inside Cowboy, and both Cobwoy and Ranch are listed as dependencies inside Charrreada. When downloading dependencies with Rebar it will download Ranch and Cowboy only to the main_app/deps folder (NOT to local deps folders inside Cowboy or Charreada). It means everything is much simplified because all dependencies of the main application, no matter how complex it is, are only downloaded into one main_app/deps folder, and not to deps subfolders of the subfolders...

There is no reason to not leverage this simplicity when using Zotonic.

But on the other hand we don't want to compile Zotonic with Rebar because Emakefile is much quicker and also used from z:m() (which wouldn't work when compiling Zotonic with Rebar).

Solution:

Add rebar.config and amend GNUmakefile so that all dependencies are managed by Rebar, but leave compiling Zotonic with the old method. The GNUmakefile has been simplified to contain a simple set of targets:

get-deps: Use Rebar to download all missing Zotonic dependencies; the old method with the use of git submodules works too - git submodules simply don't have to be used when Zotonic is compiled as a part of a bigger application

update-deps: Use Rebar to update dependencies

compile-deps: Use Rebar to compile dependencies, but only those which are present in Zotonic/deps sub-folder. If Rebar resolved Zotonic dependencies so that they are downloaded in the main_app/deps subfolder instead of main_app/deps/zotonic/deps then they won't be compiled by Zotonic's makefile but by the main_app's makefile !!

compile-zotonic: Old rules to compile Zotonic using Emakefile

all: compile-deps + compile-zotonic

docs, clean, clean_logs work as previously.

Please let me know if you have any questions or suggestions regarding this change.