From 34d6dbca61e91d0a048c0e637619174cb7c8738b Mon Sep 17 00:00:00 2001 From: Thales Macedo Garitezi Date: Tue, 21 Dec 2021 20:38:11 -0300 Subject: [PATCH] chore(mix): simplify build by using rebar3 for umbrella apps By treating the apps in the umbrella as dependencies to be managed and built by rebar3, we can simplify the maintenance of the release, at the cost of increased build times: using Mix as before, it could track changed files better than using rebar. But the complexity and possibility of discrepancies make it using rebar much more compelling. --- .formatter.exs | 6 + .tool-versions | 2 +- apps/emqx/mix.exs | 39 ------- apps/emqx_authn/mix.exs | 21 ---- apps/emqx_authn/rebar.config | 3 +- apps/emqx_authz/mix.exs | 23 ---- apps/emqx_authz/rebar.config | 2 +- apps/emqx_auto_subscribe/mix.exs | 21 ---- apps/emqx_auto_subscribe/rebar.config | 3 +- apps/emqx_bridge/mix.exs | 21 ---- apps/emqx_bridge/rebar.config | 3 +- apps/emqx_conf/mix.exs | 23 ---- apps/emqx_conf/rebar.config | 3 +- apps/emqx_conf/src/emqx_conf.app.src | 1 - apps/emqx_connector/mix.exs | 28 ----- apps/emqx_connector/rebar.config | 1 + .../emqx_connector/src/emqx_connector.app.src | 1 + apps/emqx_dashboard/mix.exs | 23 ---- apps/emqx_dashboard/rebar.config | 4 +- apps/emqx_exhook/mix.exs | 29 ----- apps/emqx_exhook/rebar.config | 3 +- apps/emqx_gateway/mix.exs | 32 ------ apps/emqx_gateway/rebar.config | 1 + apps/emqx_machine/mix.exs | 21 ---- apps/emqx_machine/rebar.config | 2 + apps/emqx_management/mix.exs | 21 ---- apps/emqx_management/rebar.config | 3 +- apps/emqx_modules/mix.exs | 21 ---- apps/emqx_modules/rebar.config | 3 +- apps/emqx_plugin_libs/mix.exs | 21 ---- apps/emqx_plugins/mix.exs | 21 ---- apps/emqx_plugins/rebar.config | 2 + apps/emqx_prometheus/mix.exs | 21 ---- apps/emqx_prometheus/rebar.config | 4 +- apps/emqx_psk/mix.exs | 21 ---- apps/emqx_psk/rebar.config | 3 +- apps/emqx_resource/mix.exs | 21 ---- apps/emqx_retainer/mix.exs | 21 ---- apps/emqx_retainer/rebar.config | 3 +- apps/emqx_rule_engine/mix.exs | 21 ---- apps/emqx_rule_engine/rebar.config | 3 +- apps/emqx_slow_subs/mix.exs | 21 ---- apps/emqx_slow_subs/rebar.config | 2 + apps/emqx_statsd/mix.exs | 21 ---- lib/emqx/mix/common.ex | 107 ------------------ mix.exs | 94 ++++++++++----- mix.lock | 11 +- mix_release.sh | 1 + rebar.config.erl | 1 + 49 files changed, 116 insertions(+), 668 deletions(-) create mode 100644 .formatter.exs delete mode 100644 apps/emqx/mix.exs delete mode 100644 apps/emqx_authn/mix.exs delete mode 100644 apps/emqx_authz/mix.exs delete mode 100644 apps/emqx_auto_subscribe/mix.exs delete mode 100644 apps/emqx_bridge/mix.exs delete mode 100644 apps/emqx_conf/mix.exs delete mode 100644 apps/emqx_connector/mix.exs delete mode 100644 apps/emqx_dashboard/mix.exs delete mode 100644 apps/emqx_exhook/mix.exs delete mode 100644 apps/emqx_gateway/mix.exs delete mode 100644 apps/emqx_machine/mix.exs create mode 100644 apps/emqx_machine/rebar.config delete mode 100644 apps/emqx_management/mix.exs delete mode 100644 apps/emqx_modules/mix.exs delete mode 100644 apps/emqx_plugin_libs/mix.exs delete mode 100644 apps/emqx_plugins/mix.exs create mode 100644 apps/emqx_plugins/rebar.config delete mode 100644 apps/emqx_prometheus/mix.exs delete mode 100644 apps/emqx_psk/mix.exs delete mode 100644 apps/emqx_resource/mix.exs delete mode 100644 apps/emqx_retainer/mix.exs delete mode 100644 apps/emqx_rule_engine/mix.exs delete mode 100644 apps/emqx_slow_subs/mix.exs create mode 100644 apps/emqx_slow_subs/rebar.config delete mode 100644 apps/emqx_statsd/mix.exs delete mode 100644 lib/emqx/mix/common.ex diff --git a/.formatter.exs b/.formatter.exs new file mode 100644 index 000000000..5cad8a0ad --- /dev/null +++ b/.formatter.exs @@ -0,0 +1,6 @@ +[ + inputs: [ + "mix.exs", + "config/*.exs" + ] +] diff --git a/.tool-versions b/.tool-versions index 1c687075b..cdb7ea9a8 100644 --- a/.tool-versions +++ b/.tool-versions @@ -1,2 +1,2 @@ -erlang 24.1.5-3 +erlang 24.1.2 elixir 1.13.1-otp-24 diff --git a/apps/emqx/mix.exs b/apps/emqx/mix.exs deleted file mode 100644 index 847002cc2..000000000 --- a/apps/emqx/mix.exs +++ /dev/null @@ -1,39 +0,0 @@ -defmodule EMQX.MixProject do - use Mix.Project - Code.require_file("../../lib/emqx/mix/common.ex") - - @app :emqx - - def project() do - EMQX.Mix.Common.project( - @app, - deps: deps() - ) - end - - def application() do - [ - mod: EMQX.Mix.Common.from_erl!(:emqx, :mod), - applications: EMQX.Mix.Common.from_erl!(:emqx, :applications) - ] - end - - # since emqx app is more complicated than others, we manually set - # its dependencies here - defp deps() do - [ - {:lc, git: "https://github.com/qzhuyan/lc.git", tag: "0.1.2"}, - {:gproc, git: "https://github.com/uwiger/gproc", tag: "0.8.0"}, - {:typerefl, git: "https://github.com/k32/typerefl", tag: "0.8.5"}, - {:jiffy, git: "https://github.com/emqx/jiffy", tag: "1.0.5"}, - {:cowboy, git: "https://github.com/emqx/cowboy", tag: "2.9.0"}, - {:esockd, git: "https://github.com/emqx/esockd", tag: "5.9.0"}, - {:ekka, git: "https://github.com/emqx/ekka", tag: "0.11.1"}, - {:gen_rpc, git: "https://github.com/emqx/gen_rpc", tag: "2.5.1"}, - {:hocon, git: "https://github.com/emqx/hocon.git", tag: "0.22.0"}, - {:pbkdf2, git: "https://github.com/emqx/erlang-pbkdf2.git", tag: "2.0.4"}, - {:recon, git: "https://github.com/ferd/recon", tag: "2.5.1"}, - {:snabbkaffe, git: "https://github.com/kafka4beam/snabbkaffe.git", tag: "0.16.0"} - ] - end -end diff --git a/apps/emqx_authn/mix.exs b/apps/emqx_authn/mix.exs deleted file mode 100644 index 07af06495..000000000 --- a/apps/emqx_authn/mix.exs +++ /dev/null @@ -1,21 +0,0 @@ -defmodule EMQXAuthn.MixProject do - use Mix.Project - Code.require_file("../../lib/emqx/mix/common.ex") - - @app :emqx_authn - - def project() do - EMQX.Mix.Common.project( - @app, - deps: deps() - ) - end - - def application() do - EMQX.Mix.Common.application(@app) - end - - defp deps() do - [] - end -end diff --git a/apps/emqx_authn/rebar.config b/apps/emqx_authn/rebar.config index 73696b033..3def1d00e 100644 --- a/apps/emqx_authn/rebar.config +++ b/apps/emqx_authn/rebar.config @@ -1,4 +1,5 @@ -{deps, []}. +{deps, [ {emqx, {path, "../emqx"}} + ]}. {edoc_opts, [{preprocess, true}]}. {erl_opts, [warn_unused_vars, diff --git a/apps/emqx_authz/mix.exs b/apps/emqx_authz/mix.exs deleted file mode 100644 index 06a5792b4..000000000 --- a/apps/emqx_authz/mix.exs +++ /dev/null @@ -1,23 +0,0 @@ -defmodule EMQXAuthz.MixProject do - use Mix.Project - Code.require_file("../../lib/emqx/mix/common.ex") - - @app :emqx_authz - - def project() do - EMQX.Mix.Common.project( - @app, - deps: deps() - ) - end - - def application() do - EMQX.Mix.Common.application(@app, - extra_applications: [:crypto] - ) - end - - defp deps() do - [] - end -end diff --git a/apps/emqx_authz/rebar.config b/apps/emqx_authz/rebar.config index ba38cc642..b1479d434 100644 --- a/apps/emqx_authz/rebar.config +++ b/apps/emqx_authz/rebar.config @@ -1,5 +1,5 @@ {erl_opts, [debug_info, nowarn_unused_import]}. -{deps, []}. +{deps, [{emqx, {path, "../emqx"}}]}. {shell, [ % {config, "config/sys.config"}, diff --git a/apps/emqx_auto_subscribe/mix.exs b/apps/emqx_auto_subscribe/mix.exs deleted file mode 100644 index d60e8f03e..000000000 --- a/apps/emqx_auto_subscribe/mix.exs +++ /dev/null @@ -1,21 +0,0 @@ -defmodule EMQXAutoSubscribe.MixProject do - use Mix.Project - Code.require_file("../../lib/emqx/mix/common.ex") - - @app :emqx_auto_subscribe - - def project() do - EMQX.Mix.Common.project( - @app, - deps: deps() - ) - end - - def application() do - EMQX.Mix.Common.application(@app) - end - - defp deps() do - [] - end -end diff --git a/apps/emqx_auto_subscribe/rebar.config b/apps/emqx_auto_subscribe/rebar.config index 88793f7ba..91cdd39d9 100644 --- a/apps/emqx_auto_subscribe/rebar.config +++ b/apps/emqx_auto_subscribe/rebar.config @@ -1,5 +1,6 @@ {erl_opts, [debug_info]}. -{deps, []}. +{deps, [ {emqx, {path, "../emqx"}} + ]}. {shell, [ {apps, [emqx_auto_subscribe]} diff --git a/apps/emqx_bridge/mix.exs b/apps/emqx_bridge/mix.exs deleted file mode 100644 index 629f1295c..000000000 --- a/apps/emqx_bridge/mix.exs +++ /dev/null @@ -1,21 +0,0 @@ -defmodule EMQXBridge.MixProject do - use Mix.Project - Code.require_file("../../lib/emqx/mix/common.ex") - - @app :emqx_bridge - - def project() do - EMQX.Mix.Common.project( - @app, - deps: deps() - ) - end - - def application() do - EMQX.Mix.Common.application(@app) - end - - defp deps() do - [] - end -end diff --git a/apps/emqx_bridge/rebar.config b/apps/emqx_bridge/rebar.config index 3fd6b41e0..d24d23f8c 100644 --- a/apps/emqx_bridge/rebar.config +++ b/apps/emqx_bridge/rebar.config @@ -1,5 +1,6 @@ {erl_opts, [debug_info]}. -{deps, []}. +{deps, [ {emqx, {path, "../emqx"}} + ]}. {shell, [ % {config, "config/sys.config"}, diff --git a/apps/emqx_conf/mix.exs b/apps/emqx_conf/mix.exs deleted file mode 100644 index 1ad98ee70..000000000 --- a/apps/emqx_conf/mix.exs +++ /dev/null @@ -1,23 +0,0 @@ -defmodule EMQXConf.MixProject do - use Mix.Project - Code.require_file("../../lib/emqx/mix/common.ex") - - @app :emqx_conf - - def project() do - EMQX.Mix.Common.project( - @app, - deps: deps() - ) - end - - def application() do - EMQX.Mix.Common.application(@app) - end - - defp deps() do - [ - {:emqx, in_umbrella: true} - ] - end -end diff --git a/apps/emqx_conf/rebar.config b/apps/emqx_conf/rebar.config index e0456112b..35563d233 100644 --- a/apps/emqx_conf/rebar.config +++ b/apps/emqx_conf/rebar.config @@ -1,5 +1,6 @@ {erl_opts, [debug_info]}. -{deps, []}. +{deps, [ {emqx, {path, "../emqx"}} + ]}. {shell, [ % {config, "config/sys.config"}, diff --git a/apps/emqx_conf/src/emqx_conf.app.src b/apps/emqx_conf/src/emqx_conf.app.src index 563c9dc1d..e9fbbb4b9 100644 --- a/apps/emqx_conf/src/emqx_conf.app.src +++ b/apps/emqx_conf/src/emqx_conf.app.src @@ -3,7 +3,6 @@ {vsn, "0.1.0"}, {registered, []}, {mod, {emqx_conf_app, []}}, - {included_applications, [hocon]}, {applications, [kernel, stdlib]}, {env, []}, {modules, []} diff --git a/apps/emqx_connector/mix.exs b/apps/emqx_connector/mix.exs deleted file mode 100644 index 86c40a6d2..000000000 --- a/apps/emqx_connector/mix.exs +++ /dev/null @@ -1,28 +0,0 @@ -defmodule EMQXConnector.MixProject do - use Mix.Project - Code.require_file("../../lib/emqx/mix/common.ex") - - @app :emqx_connector - - def project() do - EMQX.Mix.Common.project( - @app, - deps: deps() - ) - end - - def application() do - EMQX.Mix.Common.application(@app) - end - - defp deps() do - [ - {:emqx_resource, in_umbrella: true, runtime: false}, - {:epgsql, github: "epgsql/epgsql", tag: "4.4.0"}, - {:mysql, github: "emqx/mysql-otp", tag: "1.7.1"}, - {:emqtt, github: "emqx/emqtt", tag: "1.4.3"}, - {:eredis_cluster, github: "emqx/eredis_cluster", tag: "0.6.7"}, - {:mongodb, github: "emqx/mongodb-erlang", tag: "v3.0.10"} - ] - end -end diff --git a/apps/emqx_connector/rebar.config b/apps/emqx_connector/rebar.config index 58706e950..f919fc943 100644 --- a/apps/emqx_connector/rebar.config +++ b/apps/emqx_connector/rebar.config @@ -4,6 +4,7 @@ ]}. {deps, [ + {emqx, {path, "../emqx"}}, {eldap2, {git, "https://github.com/emqx/eldap2", {tag, "v0.2.2"}}}, {mysql, {git, "https://github.com/emqx/mysql-otp", {tag, "1.7.1"}}}, {epgsql, {git, "https://github.com/emqx/epgsql", {tag, "4.6.0"}}}, diff --git a/apps/emqx_connector/src/emqx_connector.app.src b/apps/emqx_connector/src/emqx_connector.app.src index fe8bb6c97..d83d16764 100644 --- a/apps/emqx_connector/src/emqx_connector.app.src +++ b/apps/emqx_connector/src/emqx_connector.app.src @@ -12,6 +12,7 @@ eredis_cluster, eredis, epgsql, + eldap2, mysql, mongodb, ehttpc, diff --git a/apps/emqx_dashboard/mix.exs b/apps/emqx_dashboard/mix.exs deleted file mode 100644 index e70feef50..000000000 --- a/apps/emqx_dashboard/mix.exs +++ /dev/null @@ -1,23 +0,0 @@ -defmodule EMQXDashboard.MixProject do - use Mix.Project - Code.require_file("../../lib/emqx/mix/common.ex") - - @app :emqx_dashboard - - def project() do - EMQX.Mix.Common.project( - @app, - deps: deps() - ) - end - - def application() do - EMQX.Mix.Common.application(@app) - end - - defp deps() do - [ - {:emqx, in_umbrella: true} - ] - end -end diff --git a/apps/emqx_dashboard/rebar.config b/apps/emqx_dashboard/rebar.config index d0a1fbde4..618fc203d 100644 --- a/apps/emqx_dashboard/rebar.config +++ b/apps/emqx_dashboard/rebar.config @@ -1,4 +1,6 @@ -{deps, []}. +{deps, [ {typerefl, {git, "https://github.com/k32/typerefl", {tag, "0.8.5"}}} + , {emqx, {path, "../emqx"}} + ]}. {edoc_opts, [{preprocess, true}]}. {erl_opts, [warn_unused_vars, diff --git a/apps/emqx_exhook/mix.exs b/apps/emqx_exhook/mix.exs deleted file mode 100644 index 85f67b40c..000000000 --- a/apps/emqx_exhook/mix.exs +++ /dev/null @@ -1,29 +0,0 @@ -defmodule EMQXExhook.MixProject do - use Mix.Project - Code.require_file("../../lib/emqx/mix/common.ex") - - @app :emqx_exhook - - def project() do - EMQX.Mix.Common.project( - @app, - deps: deps(), - compilers: [:protos | Mix.compilers()], - aliases: ["compile.protos": &protos/1] - ) - end - - def application() do - EMQX.Mix.Common.application(@app) - end - - defp deps() do - [] - end - - defp protos(_args) do - __ENV__.file - |> Path.dirname() - |> EMQX.Mix.Common.compile_protos() - end -end diff --git a/apps/emqx_exhook/rebar.config b/apps/emqx_exhook/rebar.config index afdaad084..8229c3a55 100644 --- a/apps/emqx_exhook/rebar.config +++ b/apps/emqx_exhook/rebar.config @@ -5,7 +5,8 @@ ]}. {deps, - [{grpc, {git, "https://github.com/emqx/grpc-erl", {tag, "0.6.4"}}} + [ {emqx, {path, "../emqx"}} + , {grpc, {git, "https://github.com/emqx/grpc-erl", {tag, "0.6.4"}}} ]}. {grpc, diff --git a/apps/emqx_gateway/mix.exs b/apps/emqx_gateway/mix.exs deleted file mode 100644 index 07267088d..000000000 --- a/apps/emqx_gateway/mix.exs +++ /dev/null @@ -1,32 +0,0 @@ -defmodule EMQXGateway.MixProject do - use Mix.Project - Code.require_file("../../lib/emqx/mix/common.ex") - - @app :emqx_gateway - - def project() do - EMQX.Mix.Common.project( - @app, - deps: deps(), - compilers: [:protos | Mix.compilers()], - aliases: ["compile.protos": &protos/1] - ) - end - - def application() do - EMQX.Mix.Common.application(@app) - end - - defp protos(_args) do - __ENV__.file - |> Path.dirname() - |> EMQX.Mix.Common.compile_protos() - end - - defp deps() do - EMQX.Mix.Common.from_rebar_deps!() ++ - [ - {:emqx, in_umbrella: true} - ] - end -end diff --git a/apps/emqx_gateway/rebar.config b/apps/emqx_gateway/rebar.config index 44f74eacf..c94a84de9 100644 --- a/apps/emqx_gateway/rebar.config +++ b/apps/emqx_gateway/rebar.config @@ -1,5 +1,6 @@ {erl_opts, [debug_info]}. {deps, [ + {emqx, {path, "../emqx"}}, {grpc, {git, "https://github.com/emqx/grpc-erl", {tag, "0.6.4"}}} ]}. diff --git a/apps/emqx_machine/mix.exs b/apps/emqx_machine/mix.exs deleted file mode 100644 index 2943fe1fa..000000000 --- a/apps/emqx_machine/mix.exs +++ /dev/null @@ -1,21 +0,0 @@ -defmodule EMQXMachine.MixProject do - use Mix.Project - Code.require_file("../../lib/emqx/mix/common.ex") - - @app :emqx_machine - - def project() do - EMQX.Mix.Common.project( - @app, - deps: deps() - ) - end - - def application() do - EMQX.Mix.Common.application(@app) - end - - defp deps() do - [] - end -end diff --git a/apps/emqx_machine/rebar.config b/apps/emqx_machine/rebar.config new file mode 100644 index 000000000..07646091a --- /dev/null +++ b/apps/emqx_machine/rebar.config @@ -0,0 +1,2 @@ +{deps, [ {emqx, {path, "../emqx"}} + ]}. diff --git a/apps/emqx_management/mix.exs b/apps/emqx_management/mix.exs deleted file mode 100644 index d175bc801..000000000 --- a/apps/emqx_management/mix.exs +++ /dev/null @@ -1,21 +0,0 @@ -defmodule EMQXManagement.MixProject do - use Mix.Project - Code.require_file("../../lib/emqx/mix/common.ex") - - @app :emqx_management - - def project() do - EMQX.Mix.Common.project( - @app, - deps: deps() - ) - end - - def application() do - EMQX.Mix.Common.application(@app) - end - - defp deps() do - [] - end -end diff --git a/apps/emqx_management/rebar.config b/apps/emqx_management/rebar.config index e5e336e34..0cc5ace2a 100644 --- a/apps/emqx_management/rebar.config +++ b/apps/emqx_management/rebar.config @@ -1,4 +1,5 @@ -{deps, []}. +{deps, [ {emqx, {path, "../emqx"}} + ]}. {edoc_opts, [{preprocess, true}]}. {erl_opts, [warn_unused_vars, diff --git a/apps/emqx_modules/mix.exs b/apps/emqx_modules/mix.exs deleted file mode 100644 index e41d907cc..000000000 --- a/apps/emqx_modules/mix.exs +++ /dev/null @@ -1,21 +0,0 @@ -defmodule EMQXModules.MixProject do - use Mix.Project - Code.require_file("../../lib/emqx/mix/common.ex") - - @app :emqx_modules - - def project() do - EMQX.Mix.Common.project( - @app, - deps: deps() - ) - end - - def application() do - EMQX.Mix.Common.application(@app) - end - - defp deps() do - [] - end -end diff --git a/apps/emqx_modules/rebar.config b/apps/emqx_modules/rebar.config index 7b30a8fd8..07646091a 100644 --- a/apps/emqx_modules/rebar.config +++ b/apps/emqx_modules/rebar.config @@ -1 +1,2 @@ -{deps, []}. +{deps, [ {emqx, {path, "../emqx"}} + ]}. diff --git a/apps/emqx_plugin_libs/mix.exs b/apps/emqx_plugin_libs/mix.exs deleted file mode 100644 index 74ee89c02..000000000 --- a/apps/emqx_plugin_libs/mix.exs +++ /dev/null @@ -1,21 +0,0 @@ -defmodule EMQXPluginLibs.MixProject do - use Mix.Project - Code.require_file("../../lib/emqx/mix/common.ex") - - @app :emqx_plugin_libs - - def project() do - EMQX.Mix.Common.project( - @app, - deps: deps() - ) - end - - def application() do - EMQX.Mix.Common.application(@app) - end - - defp deps() do - [] - end -end diff --git a/apps/emqx_plugins/mix.exs b/apps/emqx_plugins/mix.exs deleted file mode 100644 index 4b5ffdda2..000000000 --- a/apps/emqx_plugins/mix.exs +++ /dev/null @@ -1,21 +0,0 @@ -defmodule EMQXPlugins.MixProject do - use Mix.Project - Code.require_file("../../lib/emqx/mix/common.ex") - - @app :emqx_plugins - - def project() do - EMQX.Mix.Common.project( - @app, - deps: deps() - ) - end - - def application() do - EMQX.Mix.Common.application(@app) - end - - defp deps() do - [] - end -end diff --git a/apps/emqx_plugins/rebar.config b/apps/emqx_plugins/rebar.config new file mode 100644 index 000000000..07646091a --- /dev/null +++ b/apps/emqx_plugins/rebar.config @@ -0,0 +1,2 @@ +{deps, [ {emqx, {path, "../emqx"}} + ]}. diff --git a/apps/emqx_prometheus/mix.exs b/apps/emqx_prometheus/mix.exs deleted file mode 100644 index 84985fc41..000000000 --- a/apps/emqx_prometheus/mix.exs +++ /dev/null @@ -1,21 +0,0 @@ -defmodule EMQXPrometheus.MixProject do - use Mix.Project - Code.require_file("../../lib/emqx/mix/common.ex") - - @app :emqx_prometheus - - def project() do - EMQX.Mix.Common.project( - @app, - deps: deps() - ) - end - - def application() do - EMQX.Mix.Common.application(@app, deps: deps()) - end - - defp deps() do - EMQX.Mix.Common.from_rebar_deps!() - end -end diff --git a/apps/emqx_prometheus/rebar.config b/apps/emqx_prometheus/rebar.config index c18bde7a0..8b7e0c67e 100644 --- a/apps/emqx_prometheus/rebar.config +++ b/apps/emqx_prometheus/rebar.config @@ -1,6 +1,8 @@ {deps, [ %% FIXME: tag this as v3.1.3 - {prometheus, {git, "https://github.com/emqx/prometheus.erl", {ref, "9994c76adca40d91a2545102230ccce2423fd8a7"}}} + {prometheus, {git, "https://github.com/emqx/prometheus.erl", {ref, "9994c76adca40d91a2545102230ccce2423fd8a7"}}}, + {hocon, {git, "https://github.com/emqx/hocon.git", {tag, "0.22.0"}}}, + {minirest, {git, "https://github.com/emqx/minirest", {tag, "1.2.7"}}} ]}. {edoc_opts, [{preprocess, true}]}. diff --git a/apps/emqx_psk/mix.exs b/apps/emqx_psk/mix.exs deleted file mode 100644 index 3395a5a33..000000000 --- a/apps/emqx_psk/mix.exs +++ /dev/null @@ -1,21 +0,0 @@ -defmodule EmqxPSK.MixProject do - use Mix.Project - Code.require_file("../../lib/emqx/mix/common.ex") - - @app :emqx_psk - - def project() do - EMQX.Mix.Common.project( - @app, - deps: deps() - ) - end - - def application() do - EMQX.Mix.Common.application(@app) - end - - defp deps() do - [] - end -end diff --git a/apps/emqx_psk/rebar.config b/apps/emqx_psk/rebar.config index 73696b033..3def1d00e 100644 --- a/apps/emqx_psk/rebar.config +++ b/apps/emqx_psk/rebar.config @@ -1,4 +1,5 @@ -{deps, []}. +{deps, [ {emqx, {path, "../emqx"}} + ]}. {edoc_opts, [{preprocess, true}]}. {erl_opts, [warn_unused_vars, diff --git a/apps/emqx_resource/mix.exs b/apps/emqx_resource/mix.exs deleted file mode 100644 index 7520758e7..000000000 --- a/apps/emqx_resource/mix.exs +++ /dev/null @@ -1,21 +0,0 @@ -defmodule EMQXResource.MixProject do - use Mix.Project - Code.require_file("../../lib/emqx/mix/common.ex") - - @app :emqx_resource - - def project() do - EMQX.Mix.Common.project( - @app, - deps: deps() - ) - end - - def application() do - EMQX.Mix.Common.application(@app) - end - - defp deps() do - [] - end -end diff --git a/apps/emqx_retainer/mix.exs b/apps/emqx_retainer/mix.exs deleted file mode 100644 index 57d1f9ddf..000000000 --- a/apps/emqx_retainer/mix.exs +++ /dev/null @@ -1,21 +0,0 @@ -defmodule EMQXRetainer.MixProject do - use Mix.Project - Code.require_file("../../lib/emqx/mix/common.ex") - - @app :emqx_retainer - - def project() do - EMQX.Mix.Common.project( - @app, - deps: deps() - ) - end - - def application() do - EMQX.Mix.Common.application(@app) - end - - defp deps() do - [] - end -end diff --git a/apps/emqx_retainer/rebar.config b/apps/emqx_retainer/rebar.config index b49f979ac..8ab1ad7b0 100644 --- a/apps/emqx_retainer/rebar.config +++ b/apps/emqx_retainer/rebar.config @@ -1,4 +1,5 @@ -{deps, []}. +{deps, [ {emqx, {path, "../emqx"}} + ]}. {edoc_opts, [{preprocess, true}]}. {erl_opts, [warn_unused_vars, diff --git a/apps/emqx_rule_engine/mix.exs b/apps/emqx_rule_engine/mix.exs deleted file mode 100644 index bb5c0c895..000000000 --- a/apps/emqx_rule_engine/mix.exs +++ /dev/null @@ -1,21 +0,0 @@ -defmodule EMQXRuleEngine.MixProject do - use Mix.Project - Code.require_file("../../lib/emqx/mix/common.ex") - - @app :emqx_rule_engine - - def project() do - EMQX.Mix.Common.project( - @app, - deps: deps() - ) - end - - def application() do - EMQX.Mix.Common.application(@app) - end - - defp deps() do - [] - end -end diff --git a/apps/emqx_rule_engine/rebar.config b/apps/emqx_rule_engine/rebar.config index 097c18a3d..56a64b436 100644 --- a/apps/emqx_rule_engine/rebar.config +++ b/apps/emqx_rule_engine/rebar.config @@ -1,4 +1,5 @@ -{deps, []}. +{deps, [ {emqx, {path, "../emqx"}} + ]}. {erl_opts, [warn_unused_vars, warn_shadow_vars, diff --git a/apps/emqx_slow_subs/mix.exs b/apps/emqx_slow_subs/mix.exs deleted file mode 100644 index 15f845837..000000000 --- a/apps/emqx_slow_subs/mix.exs +++ /dev/null @@ -1,21 +0,0 @@ -defmodule EMQXSlowSubs.MixProject do - use Mix.Project - Code.require_file("../../lib/emqx/mix/common.ex") - - @app :emqx_slow_subs - - def project() do - EMQX.Mix.Common.project( - @app, - deps: deps() - ) - end - - def application() do - EMQX.Mix.Common.application(@app) - end - - defp deps() do - [] - end -end diff --git a/apps/emqx_slow_subs/rebar.config b/apps/emqx_slow_subs/rebar.config new file mode 100644 index 000000000..07646091a --- /dev/null +++ b/apps/emqx_slow_subs/rebar.config @@ -0,0 +1,2 @@ +{deps, [ {emqx, {path, "../emqx"}} + ]}. diff --git a/apps/emqx_statsd/mix.exs b/apps/emqx_statsd/mix.exs deleted file mode 100644 index 4969eff3e..000000000 --- a/apps/emqx_statsd/mix.exs +++ /dev/null @@ -1,21 +0,0 @@ -defmodule EMQXStatsd.MixProject do - use Mix.Project - Code.require_file("../../lib/emqx/mix/common.ex") - - @app :emqx_statsd - - def project() do - EMQX.Mix.Common.project( - @app, - deps: deps() - ) - end - - def application() do - EMQX.Mix.Common.application(@app) - end - - defp deps() do - EMQX.Mix.Common.from_rebar_deps!() - end -end diff --git a/lib/emqx/mix/common.ex b/lib/emqx/mix/common.ex deleted file mode 100644 index 5a276cb0c..000000000 --- a/lib/emqx/mix/common.ex +++ /dev/null @@ -1,107 +0,0 @@ -defmodule EMQX.Mix.Common do - @kernel_apps [:kernel, :stdlib, :sasl, :elixir] - - def project(app, overrides \\ []) when is_atom(app) and app != nil do - %{ - vsn: version, - description: description - } = - app - |> erl_app_props!() - |> Map.take([:vsn, :description]) - |> Map.new(fn {k, v} -> {k, to_string(v)} end) - - Keyword.merge( - [ - app: app, - version: version, - description: description, - build_path: "../../_build", - config_path: "../../config/config.exs", - deps_path: "../../deps", - lockfile: "../../mix.lock", - elixir: "~> 1.13" - ], - overrides - ) - end - - def application(app, overrides \\ []) when app != nil do - {deps, overrides} = Keyword.pop(overrides, :deps, []) - # get only the dependency names - deps = Enum.map(deps, &elem(&1, 0)) - - app - |> erl_app_props!() - |> Map.take([:registered, :mod, :applications]) - |> Map.update!(:applications, - fn apps -> - deps ++ apps -- @kernel_apps - end) - |> Enum.reject(fn {_k, v} -> is_nil(v) end) - |> Keyword.new() - |> Keyword.merge(overrides) - end - - def erl_apps(app) when app != nil do - from_erl!(app, :applications) - end - - def erl_app_props!(app) do - path = Path.join("src", "#{app}.app.src") - {:ok, [{:application, ^app, props}]} = :file.consult(path) - Map.new(props) - end - - def from_erl!(app, key) when app != nil do - app - |> erl_app_props!() - |> Map.fetch!(key) - end - - def from_rebar_deps!() do - path = "rebar.config" - {:ok, props} = :file.consult(path) - - props - |> Keyword.fetch!(:deps) - |> Enum.map(&rebar_to_mix_dep/1) - end - - def rebar_to_mix_dep({name, {:git, url, {:tag, tag}}}), - do: {name, git: to_string(url), tag: to_string(tag)} - - def rebar_to_mix_dep({name, {:git, url, {:ref, ref}}}), - do: {name, git: to_string(url), ref: to_string(ref)} - - def rebar_to_mix_dep({name, {:git, url, {:branch, branch}}}), - do: {name, git: to_string(url), branch: to_string(branch)} - - def rebar_to_mix_dep({name, vsn}) when is_list(vsn), - do: {name, to_string(vsn)} - - def compile_protos(mix_filepath) do - app_path = Path.dirname(mix_filepath) - - config = [ - :use_packages, - :maps, - :strings_as_binaries, - rename: {:msg_name, :snake_case}, - rename: {:msg_fqname, :base_name}, - i: '.', - report_errors: false, - o: app_path |> Path.join("src") |> to_charlist(), - module_name_prefix: 'emqx_', - module_name_suffix: '_pb' - ] - - app_path - |> Path.join("priv/protos/*.proto") - |> Path.wildcard() - |> Enum.map(&to_charlist/1) - |> Enum.each(&:gpb_compile.file(&1, config)) - - :ok - end -end diff --git a/mix.exs b/mix.exs index 7525df5a1..c0c02f9e3 100644 --- a/mix.exs +++ b/mix.exs @@ -10,7 +10,7 @@ defmodule EMQXUmbrella.MixProject do def project do [ - apps_path: "apps", + app: :emqx_mix, version: pkg_vsn(), deps: deps(), releases: releases() @@ -31,19 +31,19 @@ defmodule EMQXUmbrella.MixProject do {:mria, github: "emqx/mria", tag: "0.1.5", override: true}, {:ekka, github: "emqx/ekka", tag: "0.11.1", override: true}, {:gen_rpc, github: "emqx/gen_rpc", tag: "2.5.1", override: true}, - {:minirest, github: "emqx/minirest", tag: "1.2.7"}, + {:minirest, github: "emqx/minirest", tag: "1.2.7", override: true}, {:ecpool, github: "emqx/ecpool", tag: "0.5.1"}, {:replayq, "0.3.3", override: true}, {:pbkdf2, github: "emqx/erlang-pbkdf2", tag: "2.0.4", override: true}, - {:emqtt, github: "emqx/emqtt", tag: "1.4.3"}, + {:emqtt, github: "emqx/emqtt", tag: "1.4.3", override: true}, {:rulesql, github: "emqx/rulesql", tag: "0.1.4"}, {:observer_cli, "1.7.1"}, {:system_monitor, github: "klarna-incubator/system_monitor", tag: "2.2.0"}, # in conflict by emqtt and hocon {:getopt, "1.0.2", override: true}, {:snabbkaffe, github: "kafka4beam/snabbkaffe", tag: "0.16.0", override: true}, - {:hocon, github: "emqx/hocon", tag: "0.22.0"}, - {:emqx_http_lib, github: "emqx/emqx_http_lib", tag: "0.4.1"}, + {:hocon, github: "emqx/hocon", tag: "0.22.0", override: true}, + {:emqx_http_lib, github: "emqx/emqx_http_lib", tag: "0.4.1", override: true}, {:esasl, github: "emqx/esasl", tag: "0.2.0"}, {:jose, github: "potatosalad/erlang-jose", tag: "1.11.2"}, # in conflict by ehttpc and emqtt @@ -57,11 +57,41 @@ defmodule EMQXUmbrella.MixProject do # in conflict by cowboy_swagger and cowboy {:ranch, "1.8.0", override: true}, # in conflict by emqx and observer_cli - {:recon, github: "ferd/recon", tag: "2.5.1", override: true} - ] ++ bcrypt_dep() ++ quicer_dep() + {:recon, github: "ferd/recon", tag: "2.5.1", override: true}, + {:jsx, github: "talentdeficit/jsx", tag: "v3.1.0", override: true} + ] ++ + Enum.map( + [ + :emqx, + :emqx_conf, + :emqx_machine, + :emqx_plugin_libs, + :emqx_resource, + :emqx_connector, + :emqx_authn, + :emqx_authz, + :emqx_auto_subscribe, + :emqx_gateway, + :emqx_exhook, + :emqx_bridge, + :emqx_rule_engine, + :emqx_modules, + :emqx_management, + :emqx_dashboard, + :emqx_statsd, + :emqx_retainer, + :emqx_prometheus, + :emqx_psk, + :emqx_slow_subs, + :emqx_plugins + ], + &umbrella/1 + ) ++ bcrypt_dep() ++ quicer_dep() end - defp releases do + defp umbrella(app), do: {app, path: "apps/#{app}", manager: :rebar3, override: true} + + defp releases() do [ emqx: [ applications: [ @@ -102,7 +132,8 @@ defmodule EMQXUmbrella.MixProject do emqx_prometheus: :permanent, emqx_psk: :permanent, emqx_slow_subs: :permanent, - emqx_plugins: :permanent + emqx_plugins: :permanent, + emqx_mix: :none ], skip_mode_validation_for: [ :emqx_gateway, @@ -122,7 +153,7 @@ defmodule EMQXUmbrella.MixProject do :assemble, &create_RELEASES/1, ©_files/1, - ©_nodetool/1, + ©_nodetool/1 ] ] ] @@ -149,35 +180,40 @@ defmodule EMQXUmbrella.MixProject do Path.join(etc, "vm.args"), force: overwrite? ) + Mix.Generator.copy_file( "apps/emqx/etc/emqx_cloud/vm.args", Path.join(release.version_path, "vm.args"), force: overwrite? ) - release end # needed by nodetool and by release_handler def create_RELEASES(release) do - apps = Enum.map(release.applications, fn {app_name, app_props} -> - app_vsn = Keyword.fetch!(app_props, :vsn) - app_path = - "./lib" - |> Path.join("#{app_name}-#{app_vsn}") - |> to_charlist() - {app_name, app_vsn, app_path} - end) - release_entry = - [{ - :release, - to_charlist(release.name), - to_charlist(release.version), - release.erts_version, - apps, - :permanent - }] + apps = + Enum.map(release.applications, fn {app_name, app_props} -> + app_vsn = Keyword.fetch!(app_props, :vsn) + + app_path = + "./lib" + |> Path.join("#{app_name}-#{app_vsn}") + |> to_charlist() + + {app_name, app_vsn, app_path} + end) + + release_entry = [ + { + :release, + to_charlist(release.name), + to_charlist(release.version), + release.erts_version, + apps, + :permanent + } + ] release.path |> Path.join("releases") @@ -207,7 +243,7 @@ defmodule EMQXUmbrella.MixProject do def bcrypt_dep() do if enable_bcrypt?(), - do: [{:bcrypt, github: "emqx/erlang-bcrypt", tag: "0.6.0"}], + do: [{:bcrypt, github: "emqx/erlang-bcrypt", tag: "0.6.0", override: true}], else: [] end diff --git a/mix.lock b/mix.lock index 54812891f..3213601fc 100644 --- a/mix.lock +++ b/mix.lock @@ -10,11 +10,12 @@ "eetcd": {:git, "https://github.com/zhongwencool/eetcd", "69d50aca98247953ee8a3ff58423a693f8318d90", [tag: "v0.3.4"]}, "ehttpc": {:git, "https://github.com/emqx/ehttpc.git", "7b1a76b2353b385725e62f948cd399c7040467f8", [tag: "0.1.12"]}, "ekka": {:git, "https://github.com/emqx/ekka.git", "005fd6bb94199dc2ecb4ba03284f253b408e02d9", [tag: "0.11.1"]}, + "eldap2": {:git, "https://github.com/emqx/eldap2", "f595f67b094db3b9dc07941337706621e815431f", [tag: "v0.2.2"]}, "emqtt": {:git, "https://github.com/emqx/emqtt.git", "25892ef48a979a9dfbd74d86133cb28cf11f3cf4", [tag: "1.4.3"]}, "emqx_http_lib": {:git, "https://github.com/emqx/emqx_http_lib.git", "b84d42239fb09fecf50d9469fac914fb9b8efe34", [tag: "0.4.1"]}, "epgsql": {:git, "https://github.com/epgsql/epgsql.git", "f7530f63ae40ea2b81bae7d4a33292212349b761", [tag: "4.6.0"]}, - "eredis": {:hex, :eredis, "1.2.0", "0b8e9cfc2c00fa1374cd107ea63b49be08d933df2cf175e6a89b73dd9c380de4", [:rebar3], [], "hexpm", "d9b5abef2c2c8aba8f32aa018203e0b3dc8b1157773b254ab1d4c2002317f1e1"}, - "eredis_cluster": {:git, "https://github.com/emqx/eredis_cluster.git", "624749b4aef25668e9c7a545427fdc663a04faef", [tag: "0.6.7"]}, + "eredis": {:git, "https://github.com/emqx/eredis", "75f2b8eedbe631136326680225efbcd2684e93e7", [tag: "1.2.5"]}, + "eredis_cluster": {:git, "https://github.com/emqx/eredis_cluster", "624749b4aef25668e9c7a545427fdc663a04faef", [tag: "0.6.7"]}, "esasl": {:git, "https://github.com/emqx/esasl.git", "96d7ac9f6c156017dd35b30df2dd722ae469c7f0", [tag: "0.2.0"]}, "esockd": {:git, "https://github.com/emqx/esockd.git", "abb01f31c47303b4b4eecdbfe8401feedb6b4216", [tag: "5.9.0"]}, "estatsd": {:git, "https://github.com/emqx/estatsd", "5184d846b7ecb83509bd4d32695c60428c0198cd", [tag: "0.1.0"]}, @@ -29,15 +30,15 @@ "hut": {:hex, :hut, "1.3.0", "71f2f054e657c03f959cf1acc43f436ea87580696528ca2a55c8afb1b06c85e7", [:"erlang.mk", :rebar, :rebar3], [], "hexpm", "7e15d28555d8a1f2b5a3a931ec120af0753e4853a4c66053db354f35bf9ab563"}, "jiffy": {:git, "https://github.com/emqx/jiffy.git", "baa1f4e750ae3c5c9e54f9c2e52280b7fc24a8d9", [tag: "1.0.5"]}, "jose": {:git, "https://github.com/potatosalad/erlang-jose.git", "991649695aaccd92c8effb1c1e88e6159fe8e9a6", [tag: "1.11.2"]}, - "jsx": {:hex, :jsx, "2.9.0", "d2f6e5f069c00266cad52fb15d87c428579ea4d7d73a33669e12679e203329dd", [:mix, :rebar3], [], "hexpm", "8ee1db1cabafdd578a2776a6aaae87c2a8ce54b47b59e9ec7dab5d7eb71cd8dc"}, + "jsx": {:git, "https://github.com/talentdeficit/jsx.git", "bb9b3e570a7efe331eed0900c3a5188043a850d7", [tag: "v3.1.0"]}, "lc": {:git, "https://github.com/qzhuyan/lc.git", "6f98d098e5aaf4fcd6afbbb2acca96855c474600", [tag: "0.1.2"]}, "makeup": {:hex, :makeup, "1.0.5", "d5a830bc42c9800ce07dd97fa94669dfb93d3bf5fcf6ea7a0c67b2e0e4a7f26c", [:mix], [{:nimble_parsec, "~> 0.5 or ~> 1.0", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "cfa158c02d3f5c0c665d0af11512fed3fba0144cf1aadee0f2ce17747fba2ca9"}, "makeup_elixir": {:hex, :makeup_elixir, "0.15.2", "dc72dfe17eb240552857465cc00cce390960d9a0c055c4ccd38b70629227e97c", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.1", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "fd23ae48d09b32eff49d4ced2b43c9f086d402ee4fd4fcb2d7fad97fa8823e75"}, "minirest": {:git, "https://github.com/emqx/minirest.git", "f3f80b3e07295d8b6db22ed456318e0cc9dd167f", [tag: "1.2.7"]}, "mnesia_rocksdb": {:git, "https://github.com/k32/mnesia_rocksdb", "68a80d127c49005480e0dd1f73149e8621052100", [tag: "0.1.5-k32"]}, - "mongodb": {:git, "https://github.com/emqx/mongodb-erlang.git", "2ffe62f42dafb98eaafead9d340a674c5f9279a5", [tag: "v3.0.10"]}, + "mongodb": {:git, "https://github.com/emqx/mongodb-erlang", "2ffe62f42dafb98eaafead9d340a674c5f9279a5", [tag: "v3.0.10"]}, "mria": {:git, "https://github.com/emqx/mria.git", "2bf3a71abc3635f910be4b943fa4ccbf8b8257fa", [tag: "0.1.5"]}, - "mysql": {:git, "https://github.com/emqx/mysql-otp.git", "bdabac44cc8836a9e23897b7e1b77c7df7e04f70", [tag: "1.7.1"]}, + "mysql": {:git, "https://github.com/emqx/mysql-otp", "bdabac44cc8836a9e23897b7e1b77c7df7e04f70", [tag: "1.7.1"]}, "nimble_parsec": {:hex, :nimble_parsec, "1.2.0", "b44d75e2a6542dcb6acf5d71c32c74ca88960421b6874777f79153bbbbd7dccc", [:mix], [], "hexpm", "52b2871a7515a5ac49b00f214e4165a40724cf99798d8e4a65e4fd64ebd002c1"}, "observer_cli": {:hex, :observer_cli, "1.7.1", "c9ca1f623a3ef0158283a3c37cd7b7235bfe85927ad6e26396dd247e2057f5a1", [:mix, :rebar3], [{:recon, "~>2.5.1", [hex: :recon, repo: "hexpm", optional: false]}], "hexpm", "4ccafaaa2ce01b85ddd14591f4d5f6731b4e13b610a70fb841f0701178478280"}, "pbkdf2": {:git, "https://github.com/emqx/erlang-pbkdf2.git", "45d9981209ea07a83a58cf85aaf8236457da4342", [tag: "2.0.4"]}, diff --git a/mix_release.sh b/mix_release.sh index 321f0fbe1..729647e84 100755 --- a/mix_release.sh +++ b/mix_release.sh @@ -22,5 +22,6 @@ sed -i -E 's#level => warning#level => debug#g' _build/dev/rel/emqx/releases/5.0 # cp _build/emqx/rel/emqx/releases/emqx_vars _build/dev/rel/emqx/releases/ cp _build/emqx/rel/emqx/etc/emqx.conf _build/dev/rel/emqx/etc/ +cp -r apps/emqx/etc/certs _build/dev/rel/emqx/etc/ echo "telemetry { enable = false }" >> _build/dev/rel/emqx/etc/emqx.conf diff --git a/rebar.config.erl b/rebar.config.erl index dbaf9d6a3..55004569c 100644 --- a/rebar.config.erl +++ b/rebar.config.erl @@ -248,6 +248,7 @@ relx_apps(ReleaseType, Edition) -> , inets , compiler , runtime_tools + , {hocon, load} , {emqx, load} % started by emqx_machine , {emqx_conf, load} , emqx_machine