ziperlangrebar3

Is there any way create ".ez" file using rebar3 in erlang?


I know that the support for loading code from archive files is experimental.

An archive file for an application can, for example, be created like this:

zip:create("mnesia-4.4.7.ez",
    ["mnesia-4.4.7"],
    [{cwd, code:lib_dir()},
     {compress, all},
     {uncompress,[".beam",".app"]}]).

But is there any way create ".ez" file using rebar3 conveniently?


Solution

  • I don't see anything built into rebar yet, but you can use this rebar3 plugin to add a custom rebar3 archive command. Here's the basic steps.

    1. Update your ~/.config/rebar3/rebar.config file as shown below (I showed git below but its in hex too).
    {plugins, [
      {rebar3_archive_plugin, {git, "git@github.com:deadtrickster/rebar3_archive_plugin.git", {branch, "master"}}}
    ]}.
    
    1. Cd to the app directory that you want to archive and run rebar3 archive

    Alternatively, you could add the rebar3_archive_plugin entry to the rebar.config of each app that needs to be archived. For my personal build machine I prefer the first approach because it works for all apps. However, the alternate approach may be preferable if you are trying to do this from an automated build system or the main rebar.config file isn't in your control.