Class AbstractProject
- All Implemented Interfaces:
Project, ResourceProvider
- Direct Known Subclasses:
AbstractRootProject, BootstrapBuild
A default implementation of a Project.
Noteworthy features:
- Providers are added to a project successively in its constructor.
This implies that the list of providers is incomplete during
the execution of the constructor and may only be accesses via the
lazily evaluated
Streamreturn byproviders. The only place where the registered providers are accessed is the private methoddependencies. Therefore this method checks if access to providers is unlocked. Unlocking happens viaunlockProviders()after new instances of projects have been created, either inAbstractProjectfor regular projects or inDefaultBuildContextfor the root project.
-
Nested Class Summary
Nested classes/interfaces inherited from interface Project
Project.Properties -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractProject(NamedParameter<?>... params) Base class constructor for all projects. -
Method Summary
Modifier and TypeMethodDescriptiondependency(Intent intent, ResourceProvider provider) Adds a provider that contributes resources to the project with the given intended usage.Returns the project's directory.protected static NamedParameter<Path> Named parameter for specifying the directory.doProvide(ResourceRequest<T> request) Invoked byResourceProviderSpi.provide(ResourceRequest)after checking if the invocation is allowed.booleanAdds a provider to the project that generates resources which are then provided by the project.<T> Tget(PropertyKey property) Returns value of the given property of the project.inthashCode()protected static NamedParameter<Path> Hack to passcontext().jdbldDirectory()as named parameter for the directory to the constructor.name()Returns the name of this resource provider.protected static NamedParameter<String> Named parameter for specifying the name.protected static NamedParameter<Class<? extends Project>> Named parameter for specifying the parent project.Returns the parent project.Returns the instance of the given project class.Provide the projects matching the given ant-style path pattern.Return a provider selection without any restrictions.Return a provider selection that is restricted to the given intents.Returns the root project.set(PropertyKey property, Object value) Sets the given property to the given value.toString()Methods inherited from class AbstractProvider
context, of, rename, vavrStreamMethods inherited from interface Project
buildDirectory, dependency, generator, providers, readString, relativizeMethods inherited from interface ResourceProvider
context, of, of, resources
-
Constructor Details
-
AbstractProject
Base class constructor for all projects. The behavior depends on whether the project is a root project (implements
RootProject) or a subproject and on whether the project specifies a parent project.RootProjects must invoke this constructor with a null parent project class.A sub project that wants to specify a parent project must invoke this constructor with the parent project's class. If a sub project does not specify a parent project, the root project is used as parent. In both cases, the constructor adds a
Intent.Forwarddependency between the parent project and the new project. This can then be overridden in the sub project's constructor.- Parameters:
params-the named parameters
-
parent - the class of the parent project
-
name - the name of the project. If not provided the name is set to the (simple) class name
-
directory - the directory of the project. If not provided, the directory is set to the name with uppercase letters converted to lowercase for subprojects.
If a project implements
MergedTestProjectand does not specify a directory, its directory is set to the parent project's directory.For root projects the directory is always set to the current working directory.
-
-
-
Method Details
-
parent
-
name
Named parameter for specifying the name.- Parameters:
name- the name- Returns:
- the named parameter
-
directory
Named parameter for specifying the directory.- Parameters:
directory- the directory- Returns:
- the named parameter
-
jdbldDirectory
Hack to passcontext().jdbldDirectory()as named parameter for the directory to the constructor. This is required because you cannot "refer to an instance method while explicitly invoking a constructor".- Returns:
- the named parameter
-
rootProject
Description copied from interface:ProjectReturns the root project.- Specified by:
rootProjectin interfaceProject- Returns:
- the project
-
project
Description copied from interface:ProjectReturns the instance of the given project class. Projects are created lazily by the builder and must be accessed via this method. -
parentProject
Description copied from interface:ProjectReturns the parent project. The root project has no parent.- Specified by:
parentProjectin interfaceProject- Returns:
- the parent project
-
name
Description copied from interface:ResourceProviderReturns the name of this resource provider.- Specified by:
namein interfaceResourceProvider- Overrides:
namein classAbstractProvider- Returns:
- the string
-
directory
-
generator
Description copied from interface:ProjectAdds a provider to the project that generates resources which are then provided by the project. For "normal" projects, the generated resources are assumed to be provided to dependents of the project, so the invocation is shorthand for
dependency(Intent.Supply, generator).For projects that implement
MergedTestProject, generated resources are usually intended to be used by the project itself only, so the invocation is short fordependency(Intent.Consume, generator). -
dependency
Description copied from interface:ProjectAdds a provider that contributes resources to the project with the given intended usage.
While this could be used to add a
Generatorto the project as a provider withIntent.Supply, it is recommended to use one of the "generator" methods for better readability.- Specified by:
dependencyin interfaceProject- Parameters:
intent- the dependency typeprovider- the provider- Returns:
- the project for method chaining
- See Also:
-
providers
Description copied from interface:ProjectReturn a provider selection without any restrictions. -
providers
-
get
Description copied from interface:ProjectReturns value of the given property of the project. If the property is not set, the parent project's value is returned. If neither is set, the property's default value is returned. -
set
Description copied from interface:ProjectSets the given property to the given value.
Regrettably, there is no way to enforce at compile time that the type of the value passed to
setmatches the type of the property. An implementation must check this at runtime by verifying that the given value is assignable to the default value. -
doProvide
Description copied from class:AbstractProviderInvoked byResourceProviderSpi.provide(ResourceRequest)after checking if the invocation is allowed.- Specified by:
doProvidein classAbstractProvider- Type Parameters:
T- the generic type- Parameters:
request- the request for resources- Returns:
- the stream
-
projects
-
hashCode
-
equals
-
toString
- Overrides:
toStringin classAbstractProvider
-