Skip to content

Commit

Permalink
Topic: Dependencies And Umbrella Projects implemented
Browse files Browse the repository at this point in the history
  • Loading branch information
SlapBot committed Oct 19, 2019
0 parents commit 7834972
Show file tree
Hide file tree
Showing 14 changed files with 200 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .formatter.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Used by "mix format"
[
inputs: ["mix.exs", "config/*.exs"],
subdirectories: ["apps/*"]
]
21 changes: 21 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# The directory Mix will write compiled artifacts to.
/_build/

# If you run "mix test --cover", coverage assets end up here.
/cover/

# The directory Mix downloads your dependencies sources to.
/deps/

# Where third-party dependencies like ExDoc output generated docs.
/doc/

# Ignore .fetch files in case you like to edit your project deps locally.
/.fetch

# If the VM crashes, it generates a dump, let's ignore it too.
erl_crash.dump

# Also ignore archive artifacts (built via "mix archive.build").
*.ez

4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# KvUmbrella

**TODO: Add description**

1 change: 1 addition & 0 deletions apps/kv
Submodule kv added at 4534e2
4 changes: 4 additions & 0 deletions apps/kv_server/.formatter.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Used by "mix format"
[
inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"]
]
24 changes: 24 additions & 0 deletions apps/kv_server/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# The directory Mix will write compiled artifacts to.
/_build/

# If you run "mix test --cover", coverage assets end up here.
/cover/

# The directory Mix downloads your dependencies sources to.
/deps/

# Where third-party dependencies like ExDoc output generated docs.
/doc/

# Ignore .fetch files in case you like to edit your project deps locally.
/.fetch

# If the VM crashes, it generates a dump, let's ignore it too.
erl_crash.dump

# Also ignore archive artifacts (built via "mix archive.build").
*.ez

# Ignore package tarball (built via "mix hex.build").
kv_server-*.tar

21 changes: 21 additions & 0 deletions apps/kv_server/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# KVServer

**TODO: Add description**

## Installation

If [available in Hex](https://hex.pm/docs/publish), the package can be installed
by adding `kv_server` to your list of dependencies in `mix.exs`:

```elixir
def deps do
[
{:kv_server, "~> 0.1.0"}
]
end
```

Documentation can be generated with [ExDoc](https://github.com/elixir-lang/ex_doc)
and published on [HexDocs](https://hexdocs.pm). Once published, the docs can
be found at [https://hexdocs.pm/kv_server](https://hexdocs.pm/kv_server).

18 changes: 18 additions & 0 deletions apps/kv_server/lib/kv_server.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
defmodule KVServer do
@moduledoc """
Documentation for KVServer.
"""

@doc """
Hello world.
## Examples
iex> KVServer.hello()
:world
"""
def hello do
:world
end
end
19 changes: 19 additions & 0 deletions apps/kv_server/lib/kv_server/application.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
defmodule KVServer.Application do
# See https://hexdocs.pm/elixir/Application.html
# for more information on OTP Applications
@moduledoc false

use Application

def start(_type, _args) do
children = [
# Starts a worker by calling: KVServer.Worker.start_link(arg)
# {KVServer.Worker, arg}
]

# See https://hexdocs.pm/elixir/Supervisor.html
# for other strategies and supported options
opts = [strategy: :one_for_one, name: KVServer.Supervisor]
Supervisor.start_link(children, opts)
end
end
35 changes: 35 additions & 0 deletions apps/kv_server/mix.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
defmodule KVServer.MixProject do
use Mix.Project

def project do
[
app: :kv_server,
version: "0.1.0",
build_path: "../../_build",
config_path: "../../config/config.exs",
deps_path: "../../deps",
lockfile: "../../mix.lock",
elixir: "~> 1.9",
start_permanent: Mix.env() == :prod,
deps: deps()
]
end

# Run "mix help compile.app" to learn about applications.
def application do
[
extra_applications: [:logger],
mod: {KVServer.Application, []}
]
end

# Run "mix help deps" to learn about dependencies.
defp deps do
[
{:kv, in_umbrella: true}
# {: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
8 changes: 8 additions & 0 deletions apps/kv_server/test/kv_server_test.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
defmodule KVServerTest do
use ExUnit.Case
doctest KVServer

test "greets the world" do
assert KVServer.hello() == :world
end
end
1 change: 1 addition & 0 deletions apps/kv_server/test/test_helper.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ExUnit.start()
18 changes: 18 additions & 0 deletions config/config.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# This file is responsible for configuring your umbrella
# and **all applications** and their dependencies with the
# help of the Config module.
#
# Note that all applications in your umbrella share the
# same configuration and dependencies, which is why they
# all use the same configuration file. If you want different
# configurations or dependencies per app, it is best to
# move said applications out of the umbrella.
import Config

# Sample configuration:
#
# config :logger, :console,
# level: :info,
# format: "$date $time [$level] $metadata$message\n",
# metadata: [:user_id]
#
21 changes: 21 additions & 0 deletions mix.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
defmodule KvUmbrella.MixProject do
use Mix.Project

def project do
[
apps_path: "apps",
version: "0.1.0",
start_permanent: Mix.env() == :prod,
deps: deps()
]
end

# Dependencies listed here are available only for this
# project and cannot be accessed from applications inside
# the apps folder.
#
# Run "mix help deps" for examples and options.
defp deps do
[]
end
end

0 comments on commit 7834972

Please sign in to comment.