-
Notifications
You must be signed in to change notification settings - Fork 6
/
mix.exs
91 lines (80 loc) · 3.54 KB
/
mix.exs
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# Copyright(c) 2015-2024 ACCESS CO., LTD. All rights reserved.
antikythera_dep = {:antikythera, [github: "access-company/antikythera", ref: "9cdfb18f02541bc67d62723451eaedb5a782905c"]}
try do
parent_dir = Path.expand("..", __DIR__)
deps_dir =
case Path.basename(parent_dir) do
"deps" -> parent_dir # this antikythera instance project is used by a gear
_ -> Path.join(__DIR__, "deps") # this antikythera instance project is the toplevel mix project
end
mix_common_file_path = Path.join([deps_dir, "antikythera", "mix_common.exs"])
Code.require_file(mix_common_file_path)
defmodule AntikytheraInstanceExample.Mixfile do
use Mix.Project
# Here we strictly enforce Erlang/OTP version during evaluations of `mix.exs`.
# Elixir version is also checked using `:elixir` key in `project/0`.
# Although these version checks are not mandatory for antikythera instances,
# this way an antikythera instance can control Erlang/Elixir versions used in its gear projects.
versions =
File.read!(Path.join(__DIR__, ".tool-versions"))
|> String.split("\n", trim: true)
|> Map.new(fn line ->
[n, v | _] = String.split(line, [" ", "-"], trim: true)
{n, v}
end)
@elixir_version Map.fetch!(versions, "elixir")
case System.argv() do
["deps" <> _ | _] -> :ok # `deps.*` command may resolve incorrect Erlang/OTP version (if any) so we shouldn't interrupt it.
_ ->
otp_version = Map.fetch!(versions, "erlang")
otp_version_path = Path.join([:code.root_dir(), "releases", System.otp_release(), "OTP_VERSION"])
current_otp_version = File.read!(otp_version_path) |> String.trim_trailing()
if current_otp_version != otp_version do
Mix.raise("Incorrect Erlang/OTP version! required: '#{otp_version}', used: '#{current_otp_version}'")
end
end
def project() do
github_url = "https://github.com/access-company/antikythera_instance_example"
base_settings = Antikythera.MixCommon.common_project_settings() |> Keyword.replace!(:elixir, @elixir_version)
[
app: :antikythera_instance_example,
version: Antikythera.MixCommon.version_with_last_commit_info("0.1.0"),
start_permanent: Mix.env() == :prod,
deps: deps(),
source_url: github_url,
homepage_url: github_url,
releases: [
antikythera_instance_example: &Mix.Tasks.AntikytheraCore.GenerateRelease.config_for_mix_release/0
]
] ++ base_settings
end
def application() do
[
applications: [:antikythera | Antikythera.MixCommon.antikythera_runtime_dependency_applications(deps())],
]
end
defp deps() do
[
unquote(antikythera_dep),
{:exsync , "0.2.4" , [only: :dev ]},
{:meck , "0.8.13", [only: :test]}, # required to run testgear tests
{:yaml_elixir , "2.9.0" , [only: :test]}, # required to run testgear tests
{:websocket_client, "1.3.0" , [only: :test]}, # required to run testgear tests (also essential for upgrade_compatibility_test)
# indirect tool deps
# yaml_elixir
{:yamerl, "0.10.0", [indirect: true, only: :test]}
]
end
end
rescue
Code.LoadError ->
defmodule AntikytheraInstanceInitialSetup.Mixfile do
use Mix.Project
def project() do
[
app: :just_to_fetch_antikythera_as_a_dependency,
deps: [unquote(antikythera_dep)],
]
end
end
end