rebar3 引用本地elixir 模块

前边简单说过基于rebar_mix 使用elixir模块,但是使用的模块是三方的,如果时候我们可以需要使用自己的
就可以使用本地git 项目,或者搭建自己的私服git,以下是一个简单使用

项目准备

  • 本地elixir mix 项目
    一个基于mix cli 创建的项目,同时进行git init
 
mix new login 

git init
git add  --all
git commit -m 'init'
  • rebar3 项目使用本地elixir 模块
    rebar.config
 
{erl_opts, [debug_info]}.
{deps, [
  % 添加引用
  {decimal, "2.0.0"},
  % 使用git 本地项目
  {login,  {git, "file:///Users/dalong/mylearning/elixir-learning/modules/login", {branch, "main"}}}
]}.
 
{shell, [
    {apps, [basic]}
]}.
 
{plugins, [rebar_mix]}.
 
{provider_hooks, [{post, [{compile, {mix, consolidate_protocols}}]}]}.
  • 代码调用
    src/basic_login.erl
 
-module(basic_login).
-export([init/0]).
init() ->
    'Elixir.Login':hello().

测试

  • 初始化依赖
rebar3  get-deps
  • 测试
rebar3 shell

效果

说明

rebar3 对于本地模块的引用不如elixir mix 那样方便,但是基于git 是一个不错的选择,同时也可以保障代码的持续演进

参考资料

https://hexdocs.pm/mix/1.16.0/Mix.html
https://rebar3.org/docs/configuration/dependencies/
https://rebar3.org/docs/configuration/plugins/#elixir-dependencies
https://github.com/tsloughter/rebar_mix
https://github.com/barrel-db/rebar3_elixir_compile
https://rebar3.org/docs/configuration/configuration/#hooks

posted on   荣锋亮  阅读(37)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· .NET10 - 预览版1新功能体验(一)
历史上的今天:
2022-12-27 databend minio 模式试用
2022-12-27 dremio fragment 执行简单说明
2022-12-27 dremio ExecutionPlanCreator 简单说明
2021-12-27 使用juicefs 让s3 更好兼容posix协议
2020-12-27 vlang 0.2 试用&&火焰图简单查看
2020-12-27 micro 试用
2020-12-27 micro cloud native 开发平台

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5
点击右上角即可分享
微信分享提示