Class PomFileGenerator
- All Implemented Interfaces:
Generator, Renamable, ResourceProvider
A Generator (mainly) for POM files. In response to requests for
PomFile this generator produces a Maven Model containing basic
project information. The following properties are used:
-
The groupId is set to the value of the property
MvnProperties.GroupIdif it is defined. -
The artifactId is set to the property
MvnProperties.ArtifactId, or to the name of the project ifMvnProperties.ArtifactIdis not defined. -
The version is set to the value of the property
Project.Properties.Version.
Dependencies in the model are evaluated by querying the project's providers.
Compile dependencies are evaluated as follows:
-
Resources of type
MvnRepoDependencyare obtained from providers associated viaSupplyandExposethat are not projects. These resources are Maven repository dependencies declared by the project itself. -
Projects associated via
SupplyandExposedependencies are then queried for resources of typeMvnRepoDependencyusing theirSupplydependencies. This yields the Maven repository coordinates of projects required for compilation.
Runtime dependencies are evaluated as follows:
-
Resources of type
MvnRepoDependencyare obtained from providers associated viaRevealthat are not projects. These resources represent Maven repository dependencies declared by the project itself. -
Projects associated via
Revealdependencies are then queried for resources of typeMvnRepoDependencyusing theirSupplydependencies. This yields the Maven repository coordinates of projects required at runtime.
The resulting model is passed to adaptPom(Consumer) for project specific
customization before it is written to the POM file.
In addition to handling PomFile requests, this generator also
responds to requests for MvnRepoDependencies.
In this case, it returns Maven coordinates derived from the
properties MvnProperties.GroupId, MvnProperties.ArtifactId
and Project.Properties.Version (see above). This reflects the
assumption that a project with a POM file is intended to be released
as a Maven artifact. Other projects in a multi-project build will
therefore ultimately depend on the Maven artifact to be released.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAllow derived classes to post process the generated POM.Returns the destination directory.destination(Path destination) Sets the destination directory.destination(Supplier<Path> destination) Sets the destination directory.doProvide(ResourceRequest<T> requested) Invoked byResourceProviderSpi.provide(ResourceRequest)after checking if the invocation is allowed.Methods inherited from class AbstractGenerator
cleanup, name, newResource, project, toStringMethods inherited from class AbstractProvider
context, name, of, rename, vavrStream
-
Field Details
-
GENERATED_BY
-
-
Constructor Details
-
PomFileGenerator
Instantiates a new library generator.- Parameters:
project- the project
-
-
Method Details
-
destination
Returns the destination directory. Defaults to sub directorypublications/mavenin the project's build directory (seeProject.buildDirectory()).- Returns:
- the destination
-
destination
Sets the destination directory. ThePathis resolved against the project's build directory (seeProject.buildDirectory()).- Parameters:
destination- the new destination- Returns:
- the jar generator
-
destination
Sets the destination directory.- Parameters:
destination- the new destination- Returns:
- the jar generator
-
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:
requested- the requested- Returns:
- the stream
-
adaptPom
Allow derived classes to post process the generated POM.- Parameters:
adaptor- the adaptor- Returns:
- the pom file generator
-