Packages

A DMN engine that compiles models to prepared, typed FEEL expressions.

Current section

Files

Jump to
dmn mix.exs
Raw

mix.exs

defmodule Dmn.MixProject do
  use Mix.Project

  @version "0.1.0"
  @source_url "https://github.com/FeeJai/BDM"
  @source_ref if String.ends_with?(@version, "-dev"), do: "main", else: "dmn-v#{@version}"

  def project do
    [
      app: :dmn,
      version: @version,
      elixir: "~> 1.20",
      start_permanent: Mix.env() == :prod,
      build_path: "../../_build",
      config_path: "../../config/config.exs",
      deps_path: "../../deps",
      lockfile: "../../mix.lock",
      description: "A DMN engine that compiles models to prepared, typed FEEL expressions.",
      package: package(),
      docs: docs(),
      deps: deps(),
      test_coverage: [
        # 95.5 % on 2026-10-17, by the tests of this application alone (`boxed_test.exs` runs each kind of boxed expression
        # from XML to a value, `edges_test.exs` the edges of a run, `fuzz_test.exs` models changed at random); a run below
        # this floor fails, so that a module added without tests is seen.
        summary: [threshold: 95]
      ],
      dialyzer: [
        plt_core_path: "../../priv/plts",
        plt_local_path: "../../priv/plts",
        flags: [:error_handling, :unmatched_returns, :missing_return, :extra_return, :unknown]
      ]
    ]
  end

  def application do
    [extra_applications: [:logger, :xmerl]]
  end

  defp package do
    [
      files: ~w(lib mix.exs README.md LICENSE),
      licenses: ["AGPL-3.0-only"],
      links: %{"GitHub" => "#{@source_url}/tree/main/apps/dmn"}
    ]
  end

  # The tag of a release names the application (`dmn-v0.1.0`), and the paths that ExDoc
  # gives are those under apps/dmn, so the pattern says what the guess from `source_url` would leave out.
  # A `-dev` version has no tag yet, so its links go to main.
  defp docs do
    [
      main: "readme",
      extras: ["README.md"] ++ Path.wildcard("docs/*.md"),
      assets: %{"docs/assets" => "assets"},
      source_url: @source_url,
      source_ref: @source_ref,
      source_url_pattern: "#{@source_url}/blob/#{@source_ref}/apps/dmn/%{path}#L%{line}"
    ]
  end

  defp deps do
    [
      feel_dep(),
      {:credo, "~> 1.7", only: [:dev, :test], runtime: false},
      {:dialyxir, "~> 1.4", only: [:dev, :test], runtime: false},
      {:ex_doc, "~> 0.38", only: :dev, runtime: false}
    ]
  end

  # Hex takes a package only if every dependency of it is a Hex package, so `in_umbrella: true` cannot be published.
  # This file goes into the package as it is and is read on the machine of whoever depends on dmn, so the Hex
  # requirement is the default, and the sibling application is used only inside this umbrella (the directory of
  # this file is in `apps/`). To publish from the umbrella, set HEX_PUBLISH=1, from `apps/dmn` and not from the
  # root, which also has the applications that need the sibling `feel`. `feel` must be on Hex first.
  defp feel_dep do
    if Path.basename(Path.dirname(__DIR__)) == "apps" and System.get_env("HEX_PUBLISH") != "1" do
      {:feel, in_umbrella: true}
    else
      {:feel, "~> 0.1.0"}
    end
  end
end