Skip to content

Commit 9a0317d

Browse files
authored
Merge pull request rabbitmq#3 from rabbitmq/lrb-mozilla-2.0
Update license
2 parents 75882db + 228a757 commit 9a0317d

File tree

7 files changed

+90
-620
lines changed

7 files changed

+90
-620
lines changed

LICENSE

Lines changed: 4 additions & 468 deletions
Large diffs are not rendered by default.

lib/helpers.ex

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,15 @@
1+
## This Source Code Form is subject to the terms of the Mozilla Public
2+
## License, v. 2.0. If a copy of the MPL was not distributed with this
3+
## file, You can obtain one at https://mozilla.org/MPL/2.0/.
14
##
2-
## The contents of this file are subject to the Mozilla Public License
3-
## Version 1.1 (the "License"); you may not use this file except in
4-
## compliance with the License. You may obtain a copy of the License
5-
## at https://www.mozilla.org/MPL/
6-
##
7-
## Software distributed under the License is distributed on an "AS IS"
8-
## basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
9-
## the License for the specific language governing rights and
10-
## limitations under the License.
11-
##
12-
## The Original Code is mix_task_archive_deps.
13-
##
14-
## The Initial Developer of the Original Code is Daniil Fedotov.
15-
## Copyright (c) 2017 Daniil Fedotov. All rights reserved.
16-
##
5+
## Copyright (c) 2007-2020 VMware, Inc. or its affiliates. All rights reserved.
176

187
defmodule Mix.Archive.Build.Helpers do
198
def destination(opts) do
20-
opts[:destination] || Path.join(Mix.Project.build_path, "archives")
9+
opts[:destination] || Path.join(Mix.Project.build_path(), "archives")
2110
end
11+
2212
def skipped_apps(opts) do
2313
(opts[:skip] || "") |> String.split(" ") |> Enum.map(&String.to_atom/1)
2414
end
25-
end
15+
end

lib/mix/tasks/archive/build.all.ex

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,8 @@
1+
## This Source Code Form is subject to the terms of the Mozilla Public
2+
## License, v. 2.0. If a copy of the MPL was not distributed with this
3+
## file, You can obtain one at https://mozilla.org/MPL/2.0/.
14
##
2-
## The contents of this file are subject to the Mozilla Public License
3-
## Version 1.1 (the "License"); you may not use this file except in
4-
## compliance with the License. You may obtain a copy of the License
5-
## at https://www.mozilla.org/MPL/
6-
##
7-
## Software distributed under the License is distributed on an "AS IS"
8-
## basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
9-
## the License for the specific language governing rights and
10-
## limitations under the License.
11-
##
12-
## The Original Code is mix_task_archive_deps.
13-
##
14-
## The Initial Developer of the Original Code is Daniil Fedotov.
15-
## Copyright (c) 2017 Daniil Fedotov. All rights reserved.
16-
##
17-
5+
## Copyright (c) 2007-2020 VMware, Inc. or its affiliates. All rights reserved.
186

197
defmodule Mix.Tasks.Archive.Build.All do
208
use Mix.Task
@@ -50,24 +38,24 @@ defmodule Mix.Tasks.Archive.Build.All do
5038
* `--skip` - a space-separated list of dependencies to skip
5139
"""
5240

53-
5441
@switches [destination: :string, elixir: :boolean, skip: :string]
5542
@aliases [o: :destination, e: :elixir, l: :list]
5643

57-
@spec run(OptionParser.argv) :: :ok
44+
@spec run(OptionParser.argv()) :: :ok
5845
def run(argv) do
5946
Mix.Tasks.Loadpaths.run([])
6047
{opts, _} = OptionParser.parse!(argv, aliases: @aliases, strict: @switches)
6148
destination = Mix.Archive.Build.Helpers.destination(opts)
6249
Mix.Tasks.Archive.Build.Deps.build_archives(opts)
6350

64-
archive_name = Mix.Local.name_for(:archives, Mix.Project.config)
51+
archive_name = Mix.Local.name_for(:archives, Mix.Project.config())
6552
archive_path = Path.join([destination, archive_name])
6653
Mix.Tasks.Archive.Build.run(["-o", archive_path])
6754

6855
if opts[:elixir] do
6956
Mix.Tasks.Archive.Build.Elixir.build_archives(opts)
7057
end
58+
7159
:ok
7260
end
7361
end

lib/mix/tasks/archive/build.all.list.ex

Lines changed: 15 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,8 @@
1+
## This Source Code Form is subject to the terms of the Mozilla Public
2+
## License, v. 2.0. If a copy of the MPL was not distributed with this
3+
## file, You can obtain one at https://mozilla.org/MPL/2.0/.
14
##
2-
## The contents of this file are subject to the Mozilla Public License
3-
## Version 1.1 (the "License"); you may not use this file except in
4-
## compliance with the License. You may obtain a copy of the License
5-
## at https://www.mozilla.org/MPL/
6-
##
7-
## Software distributed under the License is distributed on an "AS IS"
8-
## basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
9-
## the License for the specific language governing rights and
10-
## limitations under the License.
11-
##
12-
## The Original Code is mix_task_archive_deps.
13-
##
14-
## The Initial Developer of the Original Code is Daniil Fedotov.
15-
## Copyright (c) 2017 Daniil Fedotov. All rights reserved.
16-
##
17-
5+
## Copyright (c) 2007-2020 VMware, Inc. or its affiliates. All rights reserved.
186

197
defmodule Mix.Tasks.Archive.Build.All.List do
208
use Mix.Task
@@ -36,36 +24,33 @@ defmodule Mix.Tasks.Archive.Build.All.List do
3624
* `--skip` - a space-separated list of dependencies to skip
3725
"""
3826

39-
40-
@switches [destination: :string,
41-
elixir: :boolean,
42-
separator: :string,
43-
skip: :string]
27+
@switches [destination: :string, elixir: :boolean, separator: :string, skip: :string]
4428
@aliases [o: :destination, e: :elixir, s: :separator]
4529

46-
@spec run(OptionParser.argv) :: :ok
30+
@spec run(OptionParser.argv()) :: :ok
4731
def run(argv) do
4832
Mix.Tasks.Loadpaths.run([])
4933
{opts, _} = OptionParser.parse!(argv, aliases: @aliases, strict: @switches)
5034
destination = Mix.Archive.Build.Helpers.destination(opts)
5135
elixir = opts[:elixir] || false
5236
separator = opts[:separator] || "\n"
5337

54-
archive_name = Mix.Local.name_for(:archives, Mix.Project.config)
38+
archive_name = Mix.Local.name_for(:archives, Mix.Project.config())
5539
archive_path = Path.join([destination, archive_name])
5640

5741
deps_archives = Mix.Tasks.Archive.Build.Deps.list_archives(opts)
5842

59-
elixir_archives = if elixir do
60-
Mix.Tasks.Archive.Build.Elixir.list_archives(opts)
61-
else
62-
[]
63-
end
43+
elixir_archives =
44+
if elixir do
45+
Mix.Tasks.Archive.Build.Elixir.list_archives(opts)
46+
else
47+
[]
48+
end
6449

6550
[[archive_path], deps_archives, elixir_archives]
66-
|> Enum.concat
51+
|> Enum.concat()
6752
|> Enum.join(separator)
68-
|> IO.puts
53+
|> IO.puts()
6954

7055
:ok
7156
end

lib/mix/tasks/archive/build.deps.ex

Lines changed: 21 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,12 @@
1+
## This Source Code Form is subject to the terms of the Mozilla Public
2+
## License, v. 2.0. If a copy of the MPL was not distributed with this
3+
## file, You can obtain one at https://mozilla.org/MPL/2.0/.
14
##
2-
## The contents of this file are subject to the Mozilla Public License
3-
## Version 1.1 (the "License"); you may not use this file except in
4-
## compliance with the License. You may obtain a copy of the License
5-
## at https://www.mozilla.org/MPL/
6-
##
7-
## Software distributed under the License is distributed on an "AS IS"
8-
## basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
9-
## the License for the specific language governing rights and
10-
## limitations under the License.
11-
##
12-
## The Original Code is mix_task_archive_deps.
13-
##
14-
## The Initial Developer of the Original Code is Daniil Fedotov.
15-
## Copyright (c) 2017 Daniil Fedotov. All rights reserved.
16-
##
17-
5+
## Copyright (c) 2007-2020 VMware, Inc. or its affiliates. All rights reserved.
186

197
defmodule Mix.Tasks.Archive.Build.Deps do
208
use Mix.Task
21-
alias Mix.Archive.Build.Helpers, as: Helpers
9+
alias Mix.Archive.Build.Helpers, as: Helpers
2210

2311
@shortdoc "Archives the project dependencies into .ez files"
2412

@@ -44,38 +32,41 @@ defmodule Mix.Tasks.Archive.Build.Deps do
4432
@switches [destination: :string, skip: :string]
4533
@aliases [o: :destination]
4634

47-
@spec run(OptionParser.argv) :: :ok
35+
@spec run(OptionParser.argv()) :: :ok
4836
def run(argv) do
4937
{opts, _} = OptionParser.parse!(argv, aliases: @aliases, strict: @switches)
5038
build_archives(opts)
5139
end
5240

5341
def build_archives(opts) do
5442
list(opts)
55-
|> Enum.each(fn({app_dir, archive_path}) ->
56-
Mix.Tasks.Archive.Build.run(["-i", app_dir, "-o", archive_path])
57-
end)
43+
|> Enum.each(fn {app_dir, archive_path} ->
44+
Mix.Tasks.Archive.Build.run(["-i", app_dir, "-o", archive_path])
45+
end)
46+
5847
:ok
5948
end
6049

6150
def list_archives(opts) do
6251
list(opts)
63-
|> Enum.map(fn({_, archive_path}) -> archive_path end)
52+
|> Enum.map(fn {_, archive_path} -> archive_path end)
6453
end
6554

6655
defp list(opts) do
67-
build_path = Mix.Project.build_path
56+
build_path = Mix.Project.build_path()
6857
destination = Helpers.destination(opts)
6958
skip = Helpers.skipped_apps(opts)
7059

7160
## Build delendencies archives
72-
Mix.Dep.load_on_environment(env: Mix.env)
73-
|> Enum.filter(fn(%Mix.Dep{app: app}) -> not Enum.member?(skip, app) end)
74-
|> Enum.map(fn(%Mix.Dep{app: app, status: status}) ->
75-
version = case status do
76-
{:ok, vsn} when vsn != nil -> vsn
77-
reason -> :erlang.error({:invalid_status, reason})
78-
end
61+
Mix.Dep.load_on_environment(env: Mix.env())
62+
|> Enum.filter(fn %Mix.Dep{app: app} -> not Enum.member?(skip, app) end)
63+
|> Enum.map(fn %Mix.Dep{app: app, status: status} ->
64+
version =
65+
case status do
66+
{:ok, vsn} when vsn != nil -> vsn
67+
reason -> :erlang.error({:invalid_status, reason})
68+
end
69+
7970
archive_path = Path.join([destination, "#{app}-#{version}.ez"])
8071
app_dir = Path.join([build_path, "lib", "#{app}"])
8172
{app_dir, archive_path}

lib/mix/tasks/archive/build.elixir.ex

Lines changed: 29 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,13 @@
1+
## This Source Code Form is subject to the terms of the Mozilla Public
2+
## License, v. 2.0. If a copy of the MPL was not distributed with this
3+
## file, You can obtain one at https://mozilla.org/MPL/2.0/.
14
##
2-
## The contents of this file are subject to the Mozilla Public License
3-
## Version 1.1 (the "License"); you may not use this file except in
4-
## compliance with the License. You may obtain a copy of the License
5-
## at https://www.mozilla.org/MPL/
6-
##
7-
## Software distributed under the License is distributed on an "AS IS"
8-
## basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
9-
## the License for the specific language governing rights and
10-
## limitations under the License.
11-
##
12-
## The Original Code is mix_task_archive_deps.
13-
##
14-
## The Initial Developer of the Original Code is Daniil Fedotov.
15-
## Copyright (c) 2017 Daniil Fedotov. All rights reserved.
16-
##
17-
5+
## Copyright (c) 2007-2020 VMware, Inc. or its affiliates. All rights reserved.
186

197
defmodule Mix.Tasks.Archive.Build.Elixir do
208
use Mix.Task
219

22-
alias Mix.Archive.Build.Helpers, as: Helpers
10+
alias Mix.Archive.Build.Helpers, as: Helpers
2311

2412
@shortdoc "Archives elixir applications referenced by the project into .ez files"
2513

@@ -53,7 +41,7 @@ defmodule Mix.Tasks.Archive.Build.Elixir do
5341
@aliases [o: :destination, a: :all_applications]
5442
@elixir_apps [:elixir, :eex, :ex_unit, :iex, :logger, :mix]
5543

56-
@spec run(OptionParser.argv) :: :ok
44+
@spec run(OptionParser.argv()) :: :ok
5745
def run(argv) do
5846
Mix.Tasks.Loadpaths.run([])
5947
{opts, _} = OptionParser.parse!(argv, aliases: @aliases, strict: @switches)
@@ -62,17 +50,16 @@ defmodule Mix.Tasks.Archive.Build.Elixir do
6250

6351
def build_archives(opts) do
6452
list(opts)
65-
|> Enum.each(fn({lib_dir, archive_path}) ->
66-
Mix.Tasks.Archive.Build.run(["-i", lib_dir,
67-
"-o", archive_path])
68-
end)
53+
|> Enum.each(fn {lib_dir, archive_path} ->
54+
Mix.Tasks.Archive.Build.run(["-i", lib_dir, "-o", archive_path])
55+
end)
6956

7057
:ok
7158
end
7259

7360
def list_archives(opts) do
7461
list(opts)
75-
|> Enum.map(fn({_, archive_path}) -> archive_path end)
62+
|> Enum.map(fn {_, archive_path} -> archive_path end)
7663
end
7764

7865
defp list(opts) do
@@ -81,35 +68,39 @@ defmodule Mix.Tasks.Archive.Build.Elixir do
8168
skip = Helpers.skipped_apps(opts)
8269

8370
get_required_apps(all_applications)
84-
|> Enum.filter(fn(elixir_app) -> not Enum.member?(skip, elixir_app) end)
85-
|> Enum.map(fn(elixir_app) ->
86-
lib_dir = :code.lib_dir(elixir_app)
87-
archive_name = "#{elixir_app}-#{Application.spec(elixir_app, :vsn)}.ez"
88-
archive_path = Path.join([destination, archive_name])
89-
{lib_dir, archive_path}
90-
end)
71+
|> Enum.filter(fn elixir_app -> not Enum.member?(skip, elixir_app) end)
72+
|> Enum.map(fn elixir_app ->
73+
lib_dir = :code.lib_dir(elixir_app)
74+
archive_name = "#{elixir_app}-#{Application.spec(elixir_app, :vsn)}.ez"
75+
archive_path = Path.join([destination, archive_name])
76+
{lib_dir, archive_path}
77+
end)
9178
end
9279

9380
defp get_required_apps(true) do
9481
@elixir_apps
9582
end
83+
9684
defp get_required_apps(false) do
9785
required_apps = get_applications()
86+
9887
@elixir_apps
99-
|> Enum.filter(fn(app) -> Enum.member?(required_apps, app) end)
88+
|> Enum.filter(fn app -> Enum.member?(required_apps, app) end)
10089
end
10190

10291
defp get_applications() do
103-
application = Mix.Project.config[:app]
92+
application = Mix.Project.config()[:app]
10493
get_applications_recursively([application])
10594
end
10695

10796
defp get_applications_recursively(applications) do
108-
Enum.flat_map(applications,
109-
fn(app) ->
110-
Application.load(app)
111-
deps = Application.spec(app, :applications) || []
112-
[app | get_applications_recursively(deps)]
113-
end)
97+
Enum.flat_map(
98+
applications,
99+
fn app ->
100+
Application.load(app)
101+
deps = Application.spec(app, :applications) || []
102+
[app | get_applications_recursively(deps)]
103+
end
104+
)
114105
end
115106
end

mix.exs

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,8 @@
1+
## This Source Code Form is subject to the terms of the Mozilla Public
2+
## License, v. 2.0. If a copy of the MPL was not distributed with this
3+
## file, You can obtain one at https://mozilla.org/MPL/2.0/.
14
##
2-
## The contents of this file are subject to the Mozilla Public License
3-
## Version 1.1 (the "License"); you may not use this file except in
4-
## compliance with the License. You may obtain a copy of the License
5-
## at https://www.mozilla.org/MPL/
6-
##
7-
## Software distributed under the License is distributed on an "AS IS"
8-
## basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
9-
## the License for the specific language governing rights and
10-
## limitations under the License.
11-
##
12-
## The Original Code is mix_task_archive_deps.
13-
##
14-
## The Initial Developer of the Original Code is Daniil Fedotov.
15-
## Copyright (c) 2017 Daniil Fedotov. All rights reserved.
16-
##
5+
## Copyright (c) 2007-2020 VMware, Inc. or its affiliates. All rights reserved.
176

187

198
defmodule MixTaskArchiveDeps.Mixfile do
@@ -55,8 +44,8 @@ defmodule MixTaskArchiveDeps.Mixfile do
5544
defp package() do
5645
[name: :mix_task_archive_deps,
5746
files: ["lib", "mix.exs", "README*", "LICENSE*"],
58-
maintainers: ["Daniil Fedotov"],
59-
licenses: ["MPL 1.1"],
60-
links: %{"GitHub" => "https://github.com/hairyhum/mix_task_archive_deps"}]
47+
maintainers: ["Luke Bakken", "Michael Klishin"],
48+
licenses: ["MPL 2.0"],
49+
links: %{"GitHub" => "https://github.com/rabbitmq/mix_task_archive_deps"}]
6150
end
6251
end

0 commit comments

Comments
 (0)