备注:html
项目比较大, 模块比较多,通常使用mix 的方式是你们进行文件夹的划分,可是使用mix 的umbrella 可能会更方便git
1. 安装github
默认安装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