forked from happening-oss/kafka-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mix.exs
78 lines (67 loc) · 1.84 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
defmodule KafkaClient.MixProject do
use Mix.Project
def project do
[
app: :kafka_client,
version: "0.1.0",
elixir: "~> 1.13",
elixirc_paths: elixirc_paths(Mix.env()),
start_permanent: Mix.env() == :prod,
deps: deps(),
aliases: aliases()
]
end
def application do
[
extra_applications: [:crypto, :logger]
]
end
defp elixirc_paths(env) when env in [:test, :prod_test], do: ["lib", "test/support"]
defp elixirc_paths(_), do: ["lib"]
defp deps do
[
{:credo, "~> 1.6", only: [:dev, :test]},
{:dialyxir, "~> 1.2", only: [:dev, :test], runtime: false},
{:parent, "~> 0.12"},
{:statistex, "~> 1.0", only: [:dev, :test]},
{:telemetry, "~> 1.0"}
]
end
defp aliases do
[
compile: [&compile_port/1, "compile"]
]
end
defp compile_port(_args) do
if recompile_port?() do
Mix.shell().info("Recompiling java port")
src_hash = src_hash()
case System.cmd(
"mvn",
~w/clean compile assembly:single/,
cd: "port",
stderr_to_stdout: true
) do
{_output, 0} ->
File.write("port/target/src_hash", src_hash)
File.mkdir_p!("priv")
File.cp(
"port/target/kafka-client-1.0-SNAPSHOT-jar-with-dependencies.jar",
"priv/kafka-client-1.0.jar"
)
{output, status} ->
Mix.raise("#{output}\n\nPort project build exited with the status #{status}")
end
end
end
defp recompile_port? do
case File.read("port/target/src_hash") do
{:ok, src_hash} -> src_hash != src_hash()
{:error, _posix} -> true
end
end
defp src_hash do
src_files = ["port/pom.xml" | Path.wildcard("port/src/**/*.java")]
:crypto.hash(:sha256, Enum.map(src_files, &File.read!/1))
end
end