Workspace.Project (Workspace v0.3.1)
View SourceA struct holding a workspace project info.
Workspace project config
Each workspace project may optionally have some workspace related settings defined
in it's Mix.Project config. There isn't a comprehensive list of all supported
options since various plugins or mix tasks may define their own options that can
be read from this configuration.
The following are the global workspace supported settings:
:tags- Tags associated with the current project. A single tags can be either anatomor a tuple of the form{atom, atom}. In the latter case this is considered a scoped tag. For example:tags: [:utils, {:scope, :shared}]The default value is
[].:affected_by(list ofString.t/0) - List of file paths that if changed will mark this project as affected. This is useful when a project depends on files outside of its root path. Paths are relative to the project's root directory and support wildcards.affected_by: ["../shared/config.ex", "../../docs/*.md", "config/*.json"]Supported wildcards:
*matches any characters except path separators?matches a single character- Directory paths will match any file within that directory
The default value is
[].
Summary
Functions
Marks the given project as :affected.
Returns true if the project is affected, false otherwise.
Returns the Mix.Project config of the given mix.exs file.
Ensures that the given path is an existing mix.exs file.
Formats a tag as a binary.
Returns true if the project has any of the given tags.
Returns true if the project has at least one scoped tag with the
given scope, false otherwise.
Returns true if the project has the given tag, false otherwise.
Runs the given function inside the given project.
Marks the given project as :modified.
Returns true if the project is modified, false otherwise
Creates a new project for the given project path.
Returns the project type of a project given the mix config.
Relative path of the project to the workspace
Returns all tags with the given scope.
Flags the given project as root project or not.
Sets the status of the given project.
Marks the given project as skippable.
Returns a map including the key properties of the given project.
Types
@type t() :: %Workspace.Project{ affected_by: [String.t()], app: atom(), changes: nil | [{Path.t(), Workspace.Git.change_type()}], config: keyword(), mix_path: binary(), module: module(), path: String.t(), root?: nil | boolean(), skip: term(), status: :undefined | :unaffected | :modified | :affected, tags: [tag()], workspace_path: binary() }
Struct holding info about a mix project
A project's tag.
It can either be a single atom or a tuple of atoms. In the latter case this is considered a scoped tag.
Functions
Marks the given project as :affected.
A project is considered affected if any of it's dependencies (either direct or indirect) is modified.
Notice that if the project is already marked as :modified it's status
does not change to :affected since by default modified projects are
considered affected.
Returns true if the project is affected, false otherwise.
A project is considered :affected if it is either modified or indirectly
affected from a modified dependency.
Returns the Mix.Project config of the given mix.exs file.
The project will be loaded using Mix.Project.in_project/4.
@spec ensure_mix_file!(path :: String.t()) :: :ok
Ensures that the given path is an existing mix.exs file.
If the file does not exist or the filename is not mix.exs it will raise.
Formats a tag as a binary.
Returns true if the project has any of the given tags.
Returns true if the project has at least one scoped tag with the
given scope, false otherwise.
Returns true if the project has the given tag, false otherwise.
Special tags
:*- matches all tags, it always returnstrue
Runs the given function inside the given project.
path can be one of the following:
- a path to a
mix.exsfile - a path to a folder containing a
mix.exsfile
Both absolute and relative paths are supported.
This function will delegate to Mix.Project.in_project/4. The app name is
extracted from the project folder name, so it is expected to match the internal
defined :app name in mix.exs.
The return value of this function is the return value of fun
Examples
Mix.Project.in_project("/path/to/my_app/mix.exs", fn module -> module end)
#=> MyApp.MixProject
Marks the given project as :modified.
The changes is the list of changed files belonging to the current
project that have changed.
An exception will be raised if the changes list is empty.
Returns true if the project is modified, false otherwise
Creates a new project for the given project path.
The path can be one of the following:
- A path to a
mix.exsfile - A path to a project containing a
mix.exsfile
You can pass both absolute and relative paths. All paths will be expanded by default.
This will raise if the path does not correspond to a valid
mix project.
Returns the project type of a project given the mix config.
The project type is defined under a :type attribute in the :workspace
config. It can take an arbitrary value. If set to :workspace it indicates
that the project is a root workspace project.
Relative path of the project to the workspace
Returns all tags with the given scope.
Flags the given project as root project or not.
Sets the status of the given project.
Marks the given project as skippable.
Returns a map including the key properties of the given project.
Only :app, :module, :mix_path, :path, :workspace_path, :status,
:root and :changes are included.
Options
:relative- If set totruethe paths will be relative with respect to the workspace path. Notice that theworkspace_pathattribute will be set to"."ifrelativeis set.