pub struct Project { /* private fields */ }
Expand description
The Project contains the tasks, layout information, and other related objects that would help with project building.
The project itself should be able to provide all information required to build a project, but should not be the driver of the building itself. Instead, project visitors should be driven to create project files.
By default, projects are created in the current directory.
§Example
let mut task_provider = project.tasks().register_task::<Empty>("hello_world").expect("Couldn't create 'hello_task'");
task_provider.configure_with(|empty, _project| {
empty.do_first(|_, _| {
println!("Hello, World");
Ok(())
}).unwrap();
Ok(())
}).unwrap();
Implementations§
Source§impl Project
impl Project
Sourcepub fn new() -> Result<SharedProject, PayloadError<ProjectError>>
pub fn new() -> Result<SharedProject, PayloadError<ProjectError>>
Create a new Project, with the current directory as the the directory to load
Sourcepub fn in_dir(
path: impl AsRef<Path>,
) -> Result<SharedProject, PayloadError<ProjectError>>
pub fn in_dir( path: impl AsRef<Path>, ) -> Result<SharedProject, PayloadError<ProjectError>>
Creates an assemble project in a specified directory.
Sourcepub fn with_id<I>(id: I) -> Result<SharedProject, PayloadError<ProjectError>>
pub fn with_id<I>(id: I) -> Result<SharedProject, PayloadError<ProjectError>>
Creates an assemble project in the current directory using an identifier
Sourcepub fn in_dir_with_id<Id, P>(
path: P,
id: Id,
) -> Result<SharedProject, PayloadError<ProjectError>>
pub fn in_dir_with_id<Id, P>( path: P, id: Id, ) -> Result<SharedProject, PayloadError<ProjectError>>
Creates an assemble project in a specified directory.
Sourcepub fn in_dir_with_id_and_root<Id, P>(
path: P,
id: Id,
root: Option<&SharedProject>,
settings: Option<Weak<RwLock<RawRwLock, Settings>>>,
) -> Result<SharedProject, PayloadError<ProjectError>>
pub fn in_dir_with_id_and_root<Id, P>( path: P, id: Id, root: Option<&SharedProject>, settings: Option<Weak<RwLock<RawRwLock, Settings>>>, ) -> Result<SharedProject, PayloadError<ProjectError>>
Creates an assemble project in a specified directory.
Sourcepub fn build_dir(&self) -> impl Provider<PathBuf> + Clone
pub fn build_dir(&self) -> impl Provider<PathBuf> + Clone
Gets the directory where created files should be stored
Sourcepub fn set_build_dir(&mut self, dir: &str)
pub fn set_build_dir(&mut self, dir: &str)
Always set as relative to the project dir
Sourcepub fn registered_tasks(&self) -> Vec<TaskId>
pub fn registered_tasks(&self) -> Vec<TaskId>
Gets a list of all tasks by TaskId
Sourcepub fn file<T>(
&self,
any_value: T,
) -> Result<RegularFile, PayloadError<ProjectError>>
pub fn file<T>( &self, any_value: T, ) -> Result<RegularFile, PayloadError<ProjectError>>
Create files using some valid types
Allowed types:
- &str
- String
- Path
- Regular File
Sourcepub fn visitor<R, V>(&self, visitor: &mut V) -> Rwhere
V: VisitProject<R>,
pub fn visitor<R, V>(&self, visitor: &mut V) -> Rwhere
V: VisitProject<R>,
Run a visitor on the project
Sourcepub fn visitor_mut<R, V>(&mut self, visitor: &mut V) -> Rwhere
V: VisitMutProject<R>,
pub fn visitor_mut<R, V>(&mut self, visitor: &mut V) -> Rwhere
V: VisitMutProject<R>,
Run a mutable visitor on the project
Sourcepub fn project_dir(&self) -> PathBuf
pub fn project_dir(&self) -> PathBuf
The directory of the project
Sourcepub fn task_container(&self) -> &TaskContainer
pub fn task_container(&self) -> &TaskContainer
Get access to the task container
Sourcepub fn task_container_mut(&mut self) -> &mut TaskContainer
pub fn task_container_mut(&mut self) -> &mut TaskContainer
Get access to the task container
Sourcepub fn variant(
&self,
variant: &str,
) -> Option<impl Provider<ConfigurableArtifact>>
pub fn variant( &self, variant: &str, ) -> Option<impl Provider<ConfigurableArtifact>>
Get an outgoing variant
Gets the shared reference version of this project
Sourcepub fn task_id_factory(&self) -> &TaskIdFactory
pub fn task_id_factory(&self) -> &TaskIdFactory
Gets the factory for generating task ids
pub fn properties(&self) -> &HashMap<String, Option<String>>
pub fn set_property(&mut self, key: String, value: impl Into<Option<String>>)
pub fn get_property(&self, key: &str) -> Option<&Option<String>>
pub fn has_property(&self, key: &str) -> bool
Sourcepub fn subprojects(&self) -> Vec<&SharedProject>
pub fn subprojects(&self) -> Vec<&SharedProject>
Gets the subprojects for this project.
Sourcepub fn default_tasks(&self) -> &Vec<TaskId>
pub fn default_tasks(&self) -> &Vec<TaskId>
Gets the default tasks for this project.
Default tasks are executed if no other tasks are provided.
Sourcepub fn set_default_tasks<I>(&mut self, iter: I)where
I: IntoIterator<Item = TaskId>,
pub fn set_default_tasks<I>(&mut self, iter: I)where
I: IntoIterator<Item = TaskId>,
Set the default tasks for this project.
Sourcepub fn registries_mut<F>(
&mut self,
configure: F,
) -> Result<(), PayloadError<ProjectError>>
pub fn registries_mut<F>( &mut self, configure: F, ) -> Result<(), PayloadError<ProjectError>>
apply a configuration function on the registries container
Sourcepub fn registries<R, F>(
&self,
configure: F,
) -> Result<R, PayloadError<ProjectError>>
pub fn registries<R, F>( &self, configure: F, ) -> Result<R, PayloadError<ProjectError>>
apply a function on the registries container
Sourcepub fn configurations(&self) -> &ConfigurationHandler
pub fn configurations(&self) -> &ConfigurationHandler
Get the dependencies for this project
Sourcepub fn configurations_mut(&mut self) -> &mut ConfigurationHandler
pub fn configurations_mut(&mut self) -> &mut ConfigurationHandler
Get a mutable reference to the dependencies container for this project
pub fn get_subproject<P>( &self, project: P, ) -> Result<&SharedProject, PayloadError<ProjectError>>
Sourcepub fn subproject<F>(
&mut self,
name: &str,
configure: F,
) -> Result<(), PayloadError<ProjectError>>
pub fn subproject<F>( &mut self, name: &str, configure: F, ) -> Result<(), PayloadError<ProjectError>>
Create a sub project with a given name. The path used is the $PROJECT_DIR/name
Sourcepub fn subproject_in<P, F>(
&mut self,
name: &str,
path: P,
configure: F,
) -> Result<(), PayloadError<ProjectError>>
pub fn subproject_in<P, F>( &mut self, name: &str, path: P, configure: F, ) -> Result<(), PayloadError<ProjectError>>
Create a sub project with a given name at a path.
Sourcepub fn root_project(&self) -> SharedProject
pub fn root_project(&self) -> SharedProject
Gets the root project of this project.
Sourcepub fn parent_project(&self) -> Option<SharedProject>
pub fn parent_project(&self) -> Option<SharedProject>
Gets the parent project of this project, if it exists
Sourcepub fn variants(&self) -> &VariantHandler
pub fn variants(&self) -> &VariantHandler
The variants of this project
Sourcepub fn variants_mut(&mut self) -> &mut VariantHandler
pub fn variants_mut(&mut self) -> &mut VariantHandler
The mutable variants of this project
Trait Implementations§
Source§impl CreateProjectDependencies for Project
impl CreateProjectDependencies for Project
Source§fn project<S>(&self, path: S) -> ProjectDependency
fn project<S>(&self, path: S) -> ProjectDependency
Source§fn project_with<P, C>(&self, path: P, config: C) -> ProjectDependency
fn project_with<P, C>(&self, path: P, config: C) -> ProjectDependency
Source§impl ExtensionAware for Project
impl ExtensionAware for Project
Source§fn extensions(&self) -> &ExtensionContainer
fn extensions(&self) -> &ExtensionContainer
Source§fn extensions_mut(&mut self) -> &mut ExtensionContainer
fn extensions_mut(&mut self) -> &mut ExtensionContainer
Source§fn extension<E>(&self) -> Result<&E, PayloadError<ProjectError>>where
E: Extension,
fn extension<E>(&self) -> Result<&E, PayloadError<ProjectError>>where
E: Extension,
Some(_)
Source§fn extension_mut<E>(&mut self) -> Result<&mut E, PayloadError<ProjectError>>where
E: Extension,
fn extension_mut<E>(&mut self) -> Result<&mut E, PayloadError<ProjectError>>where
E: Extension,
Some(_)
Source§impl GetProjectId for Project
impl GetProjectId for Project
Source§impl Plugin<Project> for BasePlugin
impl Plugin<Project> for BasePlugin
Source§impl Plugin<Project> for ProjectDependencyPlugin
impl Plugin<Project> for ProjectDependencyPlugin
Source§impl PluginAware for Project
impl PluginAware for Project
Source§fn plugin_manager(&self) -> &PluginManager<Project>
fn plugin_manager(&self) -> &PluginManager<Project>
Source§fn plugin_manager_mut(&mut self) -> &mut PluginManager<Project>
fn plugin_manager_mut(&mut self) -> &mut PluginManager<Project>
Source§fn apply_plugin<P>(&mut self) -> Result<(), PayloadError<ProjectError>>where
P: Plugin<Self>,
fn apply_plugin<P>(&mut self) -> Result<(), PayloadError<ProjectError>>where
P: Plugin<Self>,
Source§impl ProjectExec for Project
impl ProjectExec for Project
Source§fn exec<E>(&self, spec: E) -> ProjectResult<ExecHandle>
fn exec<E>(&self, spec: E) -> ProjectResult<ExecHandle>
ExecSpec
Source§fn exec_with<F>(&self, config: F) -> ProjectResult<ExecResult>where
F: FnOnce(&mut ExecSpecBuilder),
fn exec_with<F>(&self, config: F) -> ProjectResult<ExecResult>where
F: FnOnce(&mut ExecSpecBuilder),
Source§fn builder(&self) -> ExecSpecBuilder
fn builder(&self) -> ExecSpecBuilder
Source§impl ProjectResourceExt for Project
impl ProjectResourceExt for Project
Source§fn get_resource<R>(
&self,
resource: R,
) -> Result<Box<dyn Artifact>, PayloadError<InvalidResourceLocation>>where
R: TryInto<ResourceLocation>,
fn get_resource<R>(
&self,
resource: R,
) -> Result<Box<dyn Artifact>, PayloadError<InvalidResourceLocation>>where
R: TryInto<ResourceLocation>,
Source§impl SettingsAware for Project
impl SettingsAware for Project
fn with_settings<F, R>(&self, func: F) -> R
fn with_settings_mut<F, R>(&mut self, func: F) -> R
Auto Trait Implementations§
impl !Freeze for Project
impl !RefUnwindSafe for Project
impl Send for Project
impl Sync for Project
impl Unpin for Project
impl !UnwindSafe for Project
Blanket Implementations§
Source§impl<S> AssembleAware for Swhere
S: SettingsAware,
impl<S> AssembleAware for Swhere
S: SettingsAware,
Source§fn with_assemble<F, R>(&self, func: F) -> R
fn with_assemble<F, R>(&self, func: F) -> R
Source§fn with_assemble_mut<F, R>(&mut self, func: F) -> R
fn with_assemble_mut<F, R>(&mut self, func: F) -> R
fn start_parameter(&self) -> StartParameter
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> InstanceOf for T
impl<T> InstanceOf for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more