Struct assemble_core::project::Project
source · 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>
pub fn new() -> Result<SharedProject>
Create a new Project, with the current directory as the the directory to load
sourcepub fn in_dir(path: impl AsRef<Path>) -> Result<SharedProject>
pub fn in_dir(path: impl AsRef<Path>) -> Result<SharedProject>
Creates an assemble project in a specified directory.
sourcepub fn with_id<I: TryInto<ProjectId>>(id: I) -> Result<SharedProject>where
ProjectError: From<<I as TryInto<ProjectId>>::Error>,
pub fn with_id<I: TryInto<ProjectId>>(id: I) -> Result<SharedProject>where
ProjectError: From<<I as TryInto<ProjectId>>::Error>,
Creates an assemble project in the current directory using an identifier
sourcepub fn in_dir_with_id<Id: TryInto<ProjectId>, P: AsRef<Path>>(
path: P,
id: Id
) -> Result<SharedProject>where
ProjectError: From<<Id as TryInto<ProjectId>>::Error>,
pub fn in_dir_with_id<Id: TryInto<ProjectId>, P: AsRef<Path>>(
path: P,
id: Id
) -> Result<SharedProject>where
ProjectError: From<<Id as TryInto<ProjectId>>::Error>,
Creates an assemble project in a specified directory.
sourcepub fn in_dir_with_id_and_root<Id: TryInto<ProjectId>, P: AsRef<Path>>(
path: P,
id: Id,
root: Option<&SharedProject>,
settings: Option<Weak<RwLock<Settings>>>
) -> Result<SharedProject>where
ProjectError: From<<Id as TryInto<ProjectId>>::Error>,
pub fn in_dir_with_id_and_root<Id: TryInto<ProjectId>, P: AsRef<Path>>(
path: P,
id: Id,
root: Option<&SharedProject>,
settings: Option<Weak<RwLock<Settings>>>
) -> Result<SharedProject>where
ProjectError: From<<Id as TryInto<ProjectId>>::Error>,
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 file<T: AsRef<Path>>(&self, any_value: T) -> Result<RegularFile>
pub fn file<T: AsRef<Path>>(&self, any_value: T) -> Result<RegularFile>
Create files using some valid types
Allowed types:
- &str
- String
- Path
- Regular File
sourcepub fn visitor<R, V: VisitProject<R>>(&self, visitor: &mut V) -> R
pub fn visitor<R, V: VisitProject<R>>(&self, visitor: &mut V) -> R
Run a visitor on the project
sourcepub fn visitor_mut<R, V: VisitMutProject<R>>(&mut self, visitor: &mut V) -> R
pub fn visitor_mut<R, V: VisitMutProject<R>>(&mut self, visitor: &mut V) -> 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: IntoIterator<Item = TaskId>>(&mut self, iter: I)
pub fn set_default_tasks<I: IntoIterator<Item = TaskId>>(&mut self, iter: I)
Set the default tasks for this project.
sourcepub fn registries_mut<F: FnOnce(&mut RegistryContainer) -> ProjectResult>(
&mut self,
configure: F
) -> ProjectResult
pub fn registries_mut<F: FnOnce(&mut RegistryContainer) -> ProjectResult>(
&mut self,
configure: F
) -> ProjectResult
apply a configuration function on the registries container
sourcepub fn registries<R, F: FnOnce(&RegistryContainer) -> ProjectResult<R>>(
&self,
configure: F
) -> ProjectResult<R>
pub fn registries<R, F: FnOnce(&RegistryContainer) -> ProjectResult<R>>(
&self,
configure: F
) -> ProjectResult<R>
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: AsRef<str>>(&self, project: P) -> Result<&SharedProject>
sourcepub fn subproject<F>(&mut self, name: &str, configure: F) -> ProjectResultwhere
F: FnOnce(&mut Project) -> ProjectResult,
pub fn subproject<F>(&mut self, name: &str, configure: F) -> ProjectResultwhere
F: FnOnce(&mut Project) -> ProjectResult,
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
) -> ProjectResultwhere
F: FnOnce(&mut Project) -> ProjectResult,
P: AsRef<Path>,
pub fn subproject_in<P, F>(
&mut self,
name: &str,
path: P,
configure: F
) -> ProjectResultwhere
F: FnOnce(&mut Project) -> ProjectResult,
P: AsRef<Path>,
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: AsRef<str>>(&self, path: S) -> ProjectDependency
fn project<S: AsRef<str>>(&self, path: S) -> ProjectDependency
source§fn project_with<P: AsRef<str>, C: AsRef<str>>(
&self,
path: P,
config: C
) -> ProjectDependency
fn project_with<P: AsRef<str>, C: AsRef<str>>(
&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: Extension>(&self) -> ProjectResult<&E>
fn extension<E: Extension>(&self) -> ProjectResult<&E>
Some(_)
source§fn extension_mut<E: Extension>(&mut self) -> ProjectResult<&mut E>
fn extension_mut<E: Extension>(&mut self) -> ProjectResult<&mut E>
Some(_)