rebar3 icon indicating copy to clipboard operation
rebar3 copied to clipboard

How to add custom plugins using rebar3?

Open jiahuili430 opened this issue 2 years ago • 6 comments

Previously we could use custom plugins in rel/plugins, but how to add custom plugins using rebar3? Instead of fetching from git or hexpm, shall we use path to specify the plugins?

{plugins, [{custom_plugins, {path, "rel/plugins"}}]}.

jiahuili430 avatar May 31 '22 16:05 jiahuili430

There are no supported ways of having local plugins in released code, but currently in the main branch, in an umbrella project, you can put a plugin in plugins/ and declare it as if it were in hex and it will work. We're hoping to cut a release soon.

There is and will not be a supported way to do this outside of umbrella applications.

ferd avatar Jun 01 '22 12:06 ferd

https://github.com/jiahuili430/local-plugins I am trying to store the todo plugin source code in the plugins/ folder (main/test/test1 branches) and I am getting the following error.

$ ./rebar3 todo
===> Compiling todo
===> Errors loading plugin todo. Run rebar3 with DEBUG=1 set to see errors.
===> Command todo not found

Do I need to change anything in rebar.config?

  • TODO plugin: https://bitbucket.org/ferd/rebar3-todo-plugin/src/master/
  • rebar3 binary file is built from the main branch: ./bootstrap

jiahuili430 avatar Jun 01 '22 17:06 jiahuili430

That project is not an umbrella project. Umbrella projects’ defining characteristic is that they can contain multiple top-level Erlang/OTP applications, usually within a top-level apps/ or lib/ directory. Each of these applications may contain its own rebar.config file. This format is applicable to only for releases with one or more top-level applications, and can't easily be used as a dependency.

ferd avatar Jun 01 '22 17:06 ferd

I think it's an umbrella project. I used the rebar3 new umbrella to generate it. Just change the folder name from apps to src, and also add {project_app_dirs, ["src/*"]}. to the rebar.config.

jiahuili430 avatar Jun 01 '22 17:06 jiahuili430

https://github.com/jiahuili430/local-plugins/tree/main/src there's a top-level src/ directory.

A proper umbrella project would have apps/<appname>/src to store the Erlang source code.

ferd avatar Jun 01 '22 17:06 ferd

Changed the folder name back to apps and it works now, thank you!

jiahuili430 avatar Jun 01 '22 18:06 jiahuili430