elixir 使用mix umbrella 模块化项目
备注:
项目比较大, 模块比较多,一般使用mix 的方式是大家进行文件夹的划分,但是使用mix 的umbrella 可能会更方便
1. 安装
默认安装elixir 的时候已经包含了这个功能
a. 创建根项目
mix new <projectname> --umbrella
生成的项目如下:
* creating README.md
* creating .formatter.exs
* creating .gitignore
* creating mix.exs
* creating apps
* creating config
* creating config/config.exs
Your umbrella project was created successfully.
Inside your project, you will find an apps/ directory
where you can create and host many apps:
cd opsplatform
cd apps
mix new my_app
Commands like "mix compile" and "mix test" when executed
in the umbrella project root will automatically run
for each application in the apps/ directory.
b. 添加子项目
cd <projectname>/apps 我的是opsplatform
cd opsplatform/apps/
mix new platformuserlogin
mix new platformrunnuer
mix new platformdao
项目代码结构如下:
├── apps
│ ├── platformdao
│ │ ├── config
│ │ ├── lib
│ │ └── test
│ ├── platformrunnuer
│ │ ├── config
│ │ ├── lib
│ │ └── test
│ └── platformuserlogin
│ ├── config
│ ├── lib
│ └── test
└── config
d. 编译
mix compile # 根项目,进入子模块进行编译也是可以的
e. 模块引用(比如platformrunnuer 需要platformdao)
进入platformrunnuer 编辑 mix.exs
defp deps do
[
# {:dep_from_hexpm, "~> 0.3.0"},
{:platformdao, in_umbrella: true}
# {:dep_from_git, git: "https://github.com/elixir-lang/my_dep.git", tag: "0.1.0"},
# {:sibling_app_in_umbrella, in_umbrella: true},
]
end
mix.exs
defmodule Platformdao.MixProject do
use Mix.Project
# 处理引用的是根目录的,对于配置信息以及依赖可以方便的共享
def project do
[
app: :platformdao,
version: "0.1.0",
build_path: "../../_build",
config_path: "../../config/config.exs",
deps_path: "../../deps",
lockfile: "../../mix.lock",
elixir: "~> 1.6",
start_permanent: Mix.env() == :prod,
deps: deps()
]
end
# Run "mix help compile.app" to learn about applications.
def application do
[
extra_applications: [:logger]
]
end
# Run "mix help deps" to learn about dependencies.
defp deps do
[
# {:dep_from_hexpm, "~> 0.3.0"},
# {:dep_from_git, git: "https://github.com/elixir-lang/my_dep.git", tag: "0.1.0"},
# {:sibling_app_in_umbrella, in_umbrella: true},
]
end
end
一般来说我们在使用umbrella 的时候,同时会使用distillery && edeliver
一个负责构建,一个负责部署,还是比较方便的
https://hex.pm/packages/edeliver
https://hex.pm/packages/distillery
https://hexdocs.pm/mix/Mix.html
https://github.com/wojtekmach/acme_bank
elixir 使用mix umbrella 模块化项目的更多相关文章
- 在Android上编写模块化项目(翻译)
来源博客:Wang Jie's Blog 本文链接:http://blog.wangjiegulu.com/2018/02/13/writing_a_modular_project_on_androi ...
- spring-boot 多模块化项目和EurekaServer的搭建
Spring boot由于其 1.易于开发和维护.2.单个微服务启动快.3.局部修改部署容易.4.技术栈不受语言限制等优点受到越来越多公司的重视.spring-boot还集成了许多关于微服务开发的框架 ...
- 简单Elixir游戏服设计- 创建项目
反正是写到哪算哪. 创建umbrella项目 mix new simple_game --umbrella 创建model项目 cd simple_game\apps mix new model 创建 ...
- gulp基于seaJs模块化项目打包实践【原创】
公司还一直在延续使用jq+seajs的技术栈,所以只能基于现在的技术栈进行静态文件打包,而众所周知seajs的打包比较"偏门",在查了不少的文档和技术分享后终于琢磨出了自己的打包策 ...
- springboot之多模块化项目打包
1.目录结构 2.打成war包,只需在web子项目中的pom文件中添加 <packaging>war</packaging> <build> <!-- 为ja ...
- go创建模块化项目
比如我要创建一个xxx-system,里面可能有多个子模块,步骤如下: 1.mkdir xxx-system 2.cd xxx-system 3.在xxx-system目录下创建一系列的service ...
- elixir mix 简介
概述 mix 是 elixir 工程的构建工具,利用 mix,可以快速方便的创建 elixir 工程,写单元测试,管理 elixir 包的依赖管理等等. 我觉得刚开始学习 elixir 的时候,先简单 ...
- laravel elixir
npm install npm install jquery --save //bootsrap3.36 与 jquery3不兼容,下载jquery时可能需要确定版本号 npm install jqu ...
- elixir 集成ejabberd
备注: 我开发测试的环境时centos 1. 预备环境 1. openssl yum install -y openssl-devel 2. xml yum install -y expat-dev ...
随机推荐
- 初识 JVM
发展历史 1996年,SUN JDK 1.0 Classic VM 发布,纯解释运行,使用外挂进行JIT 1997年 JDK1.1 发布.包含了:AWT.内部类.JDBC.RMI.反射 1998年 J ...
- Oracle 冷备份详解【实战案例】
Oracle 冷备份详解 --准备工作 select * from v$database; select file_name from dba_data_files; create tablespac ...
- TileMode(平铺模式) 枚举的成员:
TileMode(平铺模式) 枚举的成员: 成员名称 说明 FlipX 与 Tile 相同,只不过图块的交替列被水平翻转. 基本图块本身不翻转. FlipXY FlipX 和 FlipY ...
- 学习opencv(持续更新)
redhat安装,报错解决方法 1 升级GCC,http://mirrors.kernel.org/gnu/gcc/ 2 更换稳定版本 #!/bin/bash yum -y install gcc g ...
- wireshark初学者使用
介绍 Wireshark是一款网络封包分析软件,截取网络封包,显示其封包的详细信息.日常工作中用的比较多.在使用wireshark之前须了解常用的网络协议.如:tcp,http,ip,udp等.(其实 ...
- SPOJ-394-ACODE - Alphacode / dp
ACODE - Alphacode #dynamic-programming Alice and Bob need to send secret messages to each other and ...
- LeetCode OJ:Gray Code(格林码)
The gray code is a binary numeral system where two successive values differ in only one bit. Given a ...
- 【LeetCode 28_字符串_匹配】Implement strStr()
解法一:Brute-force int strStr(string haystack, string needle) { int m = haystack.size(); int n = needle ...
- react 问题
安装依赖报错问题 可能需要按顺序安装, 不能cnpm npm 混合安装, 参考react项目入门 react an ...
- The Interview Outline
************************* 一.基础部分************************* 1.1 常用数据类型 - 字符串 split/strip/replace/find/ ...