Class FlattenMojo
- java.lang.Object
-
- org.apache.maven.plugin.AbstractMojo
-
- org.codehaus.mojo.flatten.AbstractFlattenMojo
-
- org.codehaus.mojo.flatten.FlattenMojo
-
- All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled,org.apache.maven.plugin.Mojo
@Mojo(name="flatten", requiresDependencyCollection=RUNTIME, threadSafe=true) public class FlattenMojo extends AbstractFlattenMojoThis MOJO realizes the goalflattenthat generates the flattened POM andpotentially updates the POM fileso that the currentMavenProject'sfilepoints to the flattened POM instead of the originalpom.xmlfile. The flattened POM is a reduced version of the original POM with the focus to contain only the important information for consuming it. Therefore information that is only required for maintenance by developers and to build the project artifact(s) are stripped. Starting from here we specify how the flattened POM is created from the original POM and its project:
Element Transformation Note modelVersionFixed to "4.0.0" New maven versions will once be able to evolve the model version without incompatibility to older versions if flattened POMs get deployed. groupId
artifactId
version
packagingresolved copied to the flattened POM but with inheritance from parentas well as with all variables and defaults resolved. These elements are technically required for consumption.licensesresolved copied to the flattened POM but with inheritance from parentas well as with all variables and defaults resolved. The licenses would not be required in flattened POM. However, they make sense for publication and deployment and are important for consumers of your artifact.dependenciesresolved specially flattened POM contains the actual dependencies of the project. Test dependencies are removed. Variables and dependencyManagementis resolved to get fixed dependency attributes (especiallyversion). IfembedBuildProfileDependenciesis set totrue, then also build-time drivenProfiles will be evaluated and may adddependencies. For further details seeProfiles below.profilesresolved specially only the Activationand thedependenciesof aProfileare copied to the flattened POM. If you set the parameterembedBuildProfileDependenciestotruethen only profilesactivatedbyJDKorOSwill be added to the flattened POM while the other profiles are triggered by the current build setup and if activated their impact on dependencies is embedded into the resulting flattened POM.name
description
url
inceptionYear
organization
scm
developers
contributors
mailingLists
pluginRepositories
issueManagement
ciManagement
distributionManagementconfigurable Will be stripped from the flattened POM by default. You can configure all of the listed elements inside pomElementsthat should be kept in the flattened POM (e.g. <pomElements><name/><description/><developers/><contributors/></pomElements>). For common use-cases there are predefined modes available via the parameterflattenModethat should be used in preference.prerequisitesconfigurable Like above but by default NOT removed if packaging is "maven-plugin". repositoriesconfigurable Like two above but by default NOT removed. If you want have it removed, you need to use the parameter pomElementsand configure the child elementrepositorieswith valueflatten.parent
build
dependencyManagement
properties
modules
reportingconfigurable These elements should typically be completely stripped from the flattened POM. However for ultimate flexibility (e.g. if you only want to resolve variables in a POM with packaging pom) you can also configure to keep these elements. We strictly recommend to use this feature with extreme care and only if packaging is pom (for "Bill of Materials"). In the latter case you configure the parameter flattenModeto the valuebom.
If thebuildelement contains plugins in thebuild/pluginssection which are configured to load extensions, a reducedbuildelement containing these plugins will be kept in the flattened pom.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private classFlattenMojo.ModelsFactoryprivate classFlattenMojo.SaxHeaderCommentHandlerThis class is a simple SAX handler that extracts the first comment located before the root tag in an XML document.
-
Field Summary
Fields Modifier and Type Field Description private org.apache.maven.artifact.handler.manager.ArtifactHandlerManagerartifactHandlerManagerprivate ElementHandlingdefaultOperationThe default operation to use when no element handling is given.private java.lang.BooleanembedBuildProfileDependenciesProfiles activated by OS or JDK are valid ways to have different dependencies per environment.private ExtendedModelInterpolatorextendedModelInterpolatorTheModelInterpolatorused to resolve variables.private FlattenDependencyModeflattenDependencyModeThe different possible values for flattenDependencyMode: Mode Description directprivate FlattenModeflattenModeThe different possible values for flattenMode: Mode Description oss For Open-Source-Software projects that want to keep alloptional POM elementsexcept forrepositoriesandpluginRepositories. ossrh Keeps alloptional POM elementsthat are required for OSS Repository-Hosting. bom Likeossrhbut additionally keepsdependencyManagementandproperties.private DirectDependenciesInheritanceAssemblerinheritanceAssemblerprivate static intINITIAL_POM_WRITER_SIZEprivate booleankeepCommentsInPomThe core maven model readers/writers are discarding the comments of the pom.xml.private ModelBuilderThreadSafetyWorkaroundmodelBuilderThreadSafetyWorkaroundprivate CiInterpolatormodelCiFriendlyInterpolatorTheModelInterpolatorused to resolve variables.private org.apache.maven.plugin.MojoExecutionmojoExecutionTheMojoExecutionused to get access to the raw configuration ofpomElementsas empty tags are mapped to null.private static java.util.regex.PatternNEW_LINE_PATTERNprivate booleanomitExclusionsDictates whether dependency exclusions stanzas should be included in the flattened POM.private FlattenDescriptorpomElementsTheModelthat defines how to handle additional POM elements.private org.apache.maven.project.MavenProjectprojectThe Maven Project.private org.eclipse.aether.RepositorySystemrepositorySystemprivate org.apache.maven.execution.MavenSessionsessionTheMavenSessionused to get user properties.private org.apache.maven.settings.SettingssettingsTheSettingsused to get active profile properties.private booleanskipFlattenIftruethe flatten goal will be skipped.private java.lang.BooleanupdatePomFileThe flag to indicate if the generated flattened POM shall be set as POM file to the current project.
-
Constructor Summary
Constructors Constructor Description FlattenMojo()The constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private org.apache.maven.model.ModelcreateCleanPom(org.apache.maven.model.Model effectivePom)protected org.apache.maven.model.ModelcreateCleanPomImpl(org.apache.maven.model.Model effectivePom)This method creates the clean POM as aModelwhere to copy elements from that shall beflattened.(package private) org.apache.maven.model.ModelcreateEffectivePom(org.apache.maven.model.building.ModelBuildingRequest buildingRequest)protected org.apache.maven.model.ModelcreateEffectivePomImpl(org.apache.maven.model.building.ModelBuildingRequest buildingRequest)Creates the effective POM for the givenpomFiletrying its best to match the core maven behaviour.private org.apache.maven.model.ModelcreateExtendedInterpolatedPom(org.apache.maven.model.building.ModelBuildingRequest buildingRequest, org.apache.maven.model.Model originalPom, org.apache.maven.model.Model effectivePom, java.io.File projectDirectory)protected java.util.List<org.apache.maven.model.Dependency>createFlattenedDependencies(org.apache.maven.model.Model effectiveModel)Creates theListofdependenciesfor the flattened POM.protected voidcreateFlattenedDependencies(org.apache.maven.model.Model effectiveModel, java.util.List<org.apache.maven.model.Dependency> flattenedDependencies)Collects the resolveddependenciesfrom the giveneffectiveModel.private voidcreateFlattenedDependenciesAll(java.util.List<org.apache.maven.model.Dependency> projectDependencies, java.util.List<org.apache.maven.model.Dependency> managedDependencies, java.util.List<org.apache.maven.model.Dependency> flattenedDependencies)Collects the resolved direct and transitivedependenciesfrom the giveneffectiveModel.private voidcreateFlattenedDependenciesDirect(java.util.List<org.apache.maven.model.Dependency> projectDependencies, java.util.List<org.apache.maven.model.Dependency> flattenedDependencies)Collects the resolveddependenciesfrom the giveneffectiveModel.protected org.apache.maven.model.DependencycreateFlattenedDependency(org.apache.maven.model.Dependency projectDependency)protected org.apache.maven.model.ModelcreateFlattenedPom(java.io.File pomFile)This method creates the flattened POM what is the main task of this plugin.protected static java.util.List<org.apache.maven.model.Repository>createFlattenedRepositories(java.util.List<org.apache.maven.model.Repository> repositories)Creates a flattenedListofRepositoryelements where those from super-POM are omitted.private org.apache.maven.model.ModelcreateInterpolatedPom(org.apache.maven.model.building.ModelBuildingRequest buildingRequest, org.apache.maven.model.Model originalPom, java.io.File projectDirectory)private org.apache.maven.model.building.ModelBuildingRequestcreateModelBuildingRequest(java.io.File pomFile)private org.apache.maven.model.ModelcreateOriginalPom(java.io.File pomFile)voidexecute()protected java.lang.StringextractHeaderComment(java.io.File xmlFile)This method extracts the XML header comment if available.private FlattenDescriptorgetFlattenDescriptor()private java.lang.StringgetKey(org.apache.maven.artifact.Artifact a)Keep in sync withgetKey(org.eclipse.aether.graph.Dependency)andgetKey(Dependency).private java.lang.StringgetKey(org.apache.maven.model.Dependency d)Keep in sync withgetKey(org.eclipse.aether.graph.Dependency)andgetKey(Artifact)private java.lang.StringgetKey(org.eclipse.aether.graph.Dependency dependency)Keep in sync withgetKey(Dependency)andgetKey(Artifact).private static java.lang.StringgetModelEncoding(org.apache.maven.model.Model pom)private java.util.List<org.apache.maven.project.MavenProject>getReactorModelsFromSession()private org.apache.maven.model.ModelgetSourceModel(FlattenDescriptor descriptor, PomProperty<?> property, FlattenMojo.ModelsFactory modelsFactory)protected static booleanisBuildTimeDriven(org.apache.maven.model.Activation activation)private static booleanisCentralRepositoryFromSuperPom(org.apache.maven.model.Repository repo)This method determines if the givenRepositorysection is identical to what is defined from the super POM.booleanisEmbedBuildProfileDependencies()private booleanisEmpty(java.util.Collection<?> collection)Null-safe check forCollection.isEmpty().booleanisUpdatePomFile()protected booleanshouldSkipGoal()protected voidwritePom(org.apache.maven.model.Model pom, java.io.File pomFile, java.lang.String headerComment, KeepCommentsInPom anOriginalCommentsPath)Writes the given POMModelto the givenFile.protected voidwriteStringToFile(java.lang.String data, java.io.File file, java.lang.String encoding)Writes the givendatato the givenfileusing the specifiedencoding.-
Methods inherited from class org.codehaus.mojo.flatten.AbstractFlattenMojo
getFlattenedPomFile, getFlattenedPomFilename, getOutputDirectory, shouldSkip
-
-
-
-
Field Detail
-
INITIAL_POM_WRITER_SIZE
private static final int INITIAL_POM_WRITER_SIZE
- See Also:
- Constant Field Values
-
NEW_LINE_PATTERN
private static final java.util.regex.Pattern NEW_LINE_PATTERN
-
settings
@Parameter(defaultValue="${settings}", readonly=true, required=true) private org.apache.maven.settings.Settings settingsTheSettingsused to get active profile properties.
-
session
@Parameter(defaultValue="${session}", readonly=true, required=true) private org.apache.maven.execution.MavenSession sessionTheMavenSessionused to get user properties.
-
project
@Parameter(defaultValue="${project}", readonly=true, required=true) private org.apache.maven.project.MavenProject projectThe Maven Project.
-
updatePomFile
@Parameter(property="updatePomFile") private java.lang.Boolean updatePomFile
The flag to indicate if the generated flattened POM shall be set as POM file to the current project. By default this is only done for projects with packaging other thanpom. You may want to also do this forpompackages projects by setting this parameter totrueor you can usefalsein order to only generate the flattened POM but never set it as POM file. IfflattenModeis set to bom the default value will betrue.
-
embedBuildProfileDependencies
@Parameter(defaultValue="false") private java.lang.Boolean embedBuildProfileDependencies
Profiles activated by OS or JDK are valid ways to have different dependencies per environment. However, profiles activated by property of file are less clear. When setting this parameter totrue, the latter dependencies will be written as direct dependencies of the project. This is not how Maven2 and Maven3 handles dependencies. When keeping this propertyfalse, all profiles will stay in the flattened-pom.
-
mojoExecution
@Parameter(defaultValue="${mojo}", readonly=true, required=true) private org.apache.maven.plugin.MojoExecution mojoExecutionTheMojoExecutionused to get access to the raw configuration ofpomElementsas empty tags are mapped to null.
-
pomElements
@Parameter(required=false) private FlattenDescriptor pomElements
TheModelthat defines how to handle additional POM elements. Please useflattenModein preference if possible. This parameter is only for ultimate flexibility.
-
omitExclusions
@Parameter(defaultValue="false", required=false) private boolean omitExclusionsDictates whether dependency exclusions stanzas should be included in the flattened POM. By default exclusions will be included in the flattened POM but if you wish to omit exclusions stanzas from being present then set this configuration property totrue.- Since:
- 1.3.0
-
flattenMode
@Parameter(property="flatten.mode", required=false) private FlattenMode flattenModeThe different possible values for flattenMode:Mode Description oss For Open-Source-Software projects that want to keep all optional POM elementsexcept forrepositoriesandpluginRepositories.ossrh Keeps all optional POM elementsthat are required for OSS Repository-Hosting.bom Like ossrhbut additionally keepsdependencyManagementandproperties. Especially it will keep thedependencyManagementas-is without resolving parent influences and import-scoped dependencies. This is useful if your POM represents a BOM (Bill Of Material) and you do not want to deploy it as is (to remove parent and resolve version variables, etc.).defaults The default mode that removes all optional POM elementsexceptrepositories.clean Removes all optional POM elements.fatjar Removes all optional POM elementsand alldependencies.resolveCiFriendliesOnly Only resolves variables revision, sha1 and changelist. Keeps everything else. See Maven CI Friendly for further details.
-
flattenDependencyMode
@Parameter(property="flatten.dependency.mode", required=false) private FlattenDependencyMode flattenDependencyModeThe different possible values for flattenDependencyMode:Mode Description direct Flatten only the direct dependency versions, excluding inherited dependencies from a parent module.
This was the default mode with Flatten Plugin in versions 1.4.0 up to 1.6.0.
inherited Flatten the dependency versions, including inherited dependencies from a parent module
This is the default mode and compatible with Flatten Plugin prior to 1.2.0, this mode was called direct between versions 1.2.0 and 1.3.0.
all Flatten both direct and transitive dependencies. This will examine the full dependency tree, and pull up all transitive dependencies as a direct dependency, and setting their versions appropriately.
This is recommended if you are releasing a library that uses dependency management to manage dependency versions.
-
keepCommentsInPom
@Parameter(property="flatten.dependency.keepComments", required=false, defaultValue="false") private boolean keepCommentsInPomThe core maven model readers/writers are discarding the comments of the pom.xml. By setting keepCommentsInPom to true the current comments are moved to the flattened pom.xml. Default value is false (= not re-adding comments).- Since:
- 1.3.0
-
skipFlatten
@Parameter(property="flatten.flatten.skip", defaultValue="false") private boolean skipFlattenIftruethe flatten goal will be skipped.- Since:
- 1.6.0
-
defaultOperation
@Parameter(property="flatten.dependency.defaultOperation", required=false, defaultValue="flatten") private ElementHandling defaultOperationThe default operation to use when no element handling is given. Defaults toflatten.- Since:
- 1.6.0
-
inheritanceAssembler
@Inject private DirectDependenciesInheritanceAssembler inheritanceAssembler
-
extendedModelInterpolator
@Inject private ExtendedModelInterpolator extendedModelInterpolator
TheModelInterpolatorused to resolve variables.
-
modelCiFriendlyInterpolator
@Inject private CiInterpolator modelCiFriendlyInterpolator
TheModelInterpolatorused to resolve variables.
-
modelBuilderThreadSafetyWorkaround
@Inject private ModelBuilderThreadSafetyWorkaround modelBuilderThreadSafetyWorkaround
-
artifactHandlerManager
@Inject private org.apache.maven.artifact.handler.manager.ArtifactHandlerManager artifactHandlerManager
-
repositorySystem
@Inject private org.eclipse.aether.RepositorySystem repositorySystem
-
-
Method Detail
-
execute
public void execute() throws org.apache.maven.plugin.MojoExecutionException, org.apache.maven.plugin.MojoFailureException- Throws:
org.apache.maven.plugin.MojoExecutionExceptionorg.apache.maven.plugin.MojoFailureException
-
shouldSkipGoal
protected boolean shouldSkipGoal()
- Specified by:
shouldSkipGoalin classAbstractFlattenMojo
-
extractHeaderComment
protected java.lang.String extractHeaderComment(java.io.File xmlFile) throws org.apache.maven.plugin.MojoExecutionExceptionThis method extracts the XML header comment if available.- Parameters:
xmlFile- is the XMLFileto parse.- Returns:
- the XML comment between the XML header declaration and the root tag or
nullif NOT available. - Throws:
org.apache.maven.plugin.MojoExecutionException- if anything goes wrong.
-
writePom
protected void writePom(org.apache.maven.model.Model pom, java.io.File pomFile, java.lang.String headerComment, KeepCommentsInPom anOriginalCommentsPath) throws org.apache.maven.plugin.MojoExecutionExceptionWrites the given POMModelto the givenFile.- Parameters:
pom- theModelof the POM to write.pomFile- theFilewhere to write the given POM will be written to.Parent directoriesarecreatedautomatically.headerComment- is the content of a potential XML comment at the top of the XML (after XML declaration and before root tag). May benullif not present and to be omitted in target POM.- Throws:
org.apache.maven.plugin.MojoExecutionException- if the operation failed (e.g. due to anIOException).
-
writeStringToFile
protected void writeStringToFile(java.lang.String data, java.io.File file, java.lang.String encoding) throws org.apache.maven.plugin.MojoExecutionExceptionWrites the givendatato the givenfileusing the specifiedencoding.- Parameters:
data- is theStringto write.file- is theFileto write to.encoding- is the encoding to use for writing the file.- Throws:
org.apache.maven.plugin.MojoExecutionException- if anything goes wrong.
-
createFlattenedPom
protected org.apache.maven.model.Model createFlattenedPom(java.io.File pomFile) throws org.apache.maven.plugin.MojoExecutionException, org.apache.maven.plugin.MojoFailureExceptionThis method creates the flattened POM what is the main task of this plugin.- Parameters:
pomFile- is the name of the original POM file to read and transform.- Returns:
- the
Modelof the flattened POM. - Throws:
org.apache.maven.plugin.MojoExecutionException- if anything goes wrong (e.g. POM can not be processed).org.apache.maven.plugin.MojoFailureException- if anything goes wrong (logical error).
-
createEffectivePom
org.apache.maven.model.Model createEffectivePom(org.apache.maven.model.building.ModelBuildingRequest buildingRequest) throws org.apache.maven.plugin.MojoExecutionException- Throws:
org.apache.maven.plugin.MojoExecutionException
-
createCleanPom
private org.apache.maven.model.Model createCleanPom(org.apache.maven.model.Model effectivePom) throws org.apache.maven.plugin.MojoExecutionException- Throws:
org.apache.maven.plugin.MojoExecutionException
-
createInterpolatedPom
private org.apache.maven.model.Model createInterpolatedPom(org.apache.maven.model.building.ModelBuildingRequest buildingRequest, org.apache.maven.model.Model originalPom, java.io.File projectDirectory)
-
createExtendedInterpolatedPom
private org.apache.maven.model.Model createExtendedInterpolatedPom(org.apache.maven.model.building.ModelBuildingRequest buildingRequest, org.apache.maven.model.Model originalPom, org.apache.maven.model.Model effectivePom, java.io.File projectDirectory)
-
createOriginalPom
private org.apache.maven.model.Model createOriginalPom(java.io.File pomFile) throws org.apache.maven.plugin.MojoExecutionException- Throws:
org.apache.maven.plugin.MojoExecutionException
-
createCleanPomImpl
protected org.apache.maven.model.Model createCleanPomImpl(org.apache.maven.model.Model effectivePom) throws org.apache.maven.plugin.MojoExecutionExceptionThis method creates the clean POM as aModelwhere to copy elements from that shall beflattened. Will be mainly empty but contains some the minimum elements that have to be kept in flattened POM.- Parameters:
effectivePom- is the effective POM.- Returns:
- the clean POM.
- Throws:
org.apache.maven.plugin.MojoExecutionException- if anything goes wrong.
-
getSourceModel
private org.apache.maven.model.Model getSourceModel(FlattenDescriptor descriptor, PomProperty<?> property, FlattenMojo.ModelsFactory modelsFactory) throws org.apache.maven.plugin.MojoExecutionException
- Throws:
org.apache.maven.plugin.MojoExecutionException
-
createFlattenedRepositories
protected static java.util.List<org.apache.maven.model.Repository> createFlattenedRepositories(java.util.List<org.apache.maven.model.Repository> repositories)
Creates a flattenedListofRepositoryelements where those from super-POM are omitted.- Parameters:
repositories- is theListofRepositoryelements. May benull.- Returns:
- the flattened
ListofRepositoryelements ornullifnullwas given.
-
getFlattenDescriptor
private FlattenDescriptor getFlattenDescriptor()
-
getModelEncoding
private static java.lang.String getModelEncoding(org.apache.maven.model.Model pom)
-
isCentralRepositoryFromSuperPom
private static boolean isCentralRepositoryFromSuperPom(org.apache.maven.model.Repository repo)
This method determines if the givenRepositorysection is identical to what is defined from the super POM.- Parameters:
repo- is theRepositorysection to check.- Returns:
trueif maven central default configuration,falseotherwise.
-
createModelBuildingRequest
private org.apache.maven.model.building.ModelBuildingRequest createModelBuildingRequest(java.io.File pomFile)
-
getReactorModelsFromSession
private java.util.List<org.apache.maven.project.MavenProject> getReactorModelsFromSession()
-
createEffectivePomImpl
protected org.apache.maven.model.Model createEffectivePomImpl(org.apache.maven.model.building.ModelBuildingRequest buildingRequest) throws org.apache.maven.plugin.MojoExecutionExceptionCreates the effective POM for the givenpomFiletrying its best to match the core maven behaviour.- Parameters:
buildingRequest-ModelBuildingRequest- Returns:
- the parsed and calculated effective POM.
- Throws:
org.apache.maven.plugin.MojoExecutionException- if anything goes wrong.
-
isEmpty
private boolean isEmpty(java.util.Collection<?> collection)
Null-safe check forCollection.isEmpty().- Parameters:
collection- is theCollectionto test. May benull.- Returns:
trueifnullorempty,falseotherwise.
-
isEmbedBuildProfileDependencies
public boolean isEmbedBuildProfileDependencies()
- Returns:
trueif build-dependent profiles (triggered by OS or JDK) should be evaluated and their effect (variables and dependencies) are resolved and embedded into the flattened POM while the profile itself is stripped. Otherwise iffalsethe profiles will remain untouched.
-
isBuildTimeDriven
protected static boolean isBuildTimeDriven(org.apache.maven.model.Activation activation)
- Parameters:
activation- is theActivationof aProfile.- Returns:
trueif the givenActivationis build-time driven,falseotherwise (if it is triggered by OS or JDK).
-
createFlattenedDependencies
protected java.util.List<org.apache.maven.model.Dependency> createFlattenedDependencies(org.apache.maven.model.Model effectiveModel) throws org.apache.maven.plugin.MojoExecutionExceptionCreates theListofdependenciesfor the flattened POM. These are all resolveddependenciesexcept for those added fromprofiles.- Parameters:
effectiveModel- is the effective POMModelto process.- Returns:
- the
Listofdependencies. - Throws:
org.apache.maven.plugin.MojoExecutionException- if anything goes wrong.
-
createFlattenedDependenciesDirect
private void createFlattenedDependenciesDirect(java.util.List<org.apache.maven.model.Dependency> projectDependencies, java.util.List<org.apache.maven.model.Dependency> flattenedDependencies)Collects the resolveddependenciesfrom the giveneffectiveModel.- Parameters:
projectDependencies- is the effective POMModel's current dependenciesflattenedDependencies- is theListwhere to add the collecteddependencies.
-
createFlattenedDependenciesAll
private void createFlattenedDependenciesAll(java.util.List<org.apache.maven.model.Dependency> projectDependencies, java.util.List<org.apache.maven.model.Dependency> managedDependencies, java.util.List<org.apache.maven.model.Dependency> flattenedDependencies) throws org.eclipse.aether.resolution.ArtifactDescriptorException, org.eclipse.aether.collection.DependencyCollectionExceptionCollects the resolved direct and transitivedependenciesfrom the giveneffectiveModel. The collected dependencies are stored in order, so that the leaf dependencies are prioritized in front of direct dependencies. In addition, every non-leaf dependencies will exclude its own direct dependency, since all transitive dependencies will be collected.Transitive dependencies are all going to be collected and become a direct dependency. Maven should already resolve versions properly because now the transitive dependencies are closer to the artifact. However, when this artifact is being consumed, Maven Enforcer Convergence rule will fail because there may be multiple versions for the same transitive dependency.
Typically, exclusion can be done by using the wildcard. However, a known Maven issue prevents convergence enforcer from working properly w/ wildcard exclusions. Thus, this will exclude each dependencies explicitly rather than using the wildcard.
- Parameters:
projectDependencies- is the effective POMModel's current dependenciesflattenedDependencies- is theListwhere to add the collecteddependencies.- Throws:
org.eclipse.aether.collection.DependencyCollectionExceptionorg.eclipse.aether.resolution.ArtifactDescriptorException
-
getKey
private java.lang.String getKey(org.apache.maven.artifact.Artifact a)
Keep in sync withgetKey(org.eclipse.aether.graph.Dependency)andgetKey(Dependency).
-
getKey
private java.lang.String getKey(org.apache.maven.model.Dependency d)
Keep in sync withgetKey(org.eclipse.aether.graph.Dependency)andgetKey(Artifact)
-
getKey
private java.lang.String getKey(org.eclipse.aether.graph.Dependency dependency)
Keep in sync withgetKey(Dependency)andgetKey(Artifact).
-
createFlattenedDependencies
protected void createFlattenedDependencies(org.apache.maven.model.Model effectiveModel, java.util.List<org.apache.maven.model.Dependency> flattenedDependencies) throws org.apache.maven.plugin.MojoExecutionExceptionCollects the resolveddependenciesfrom the giveneffectiveModel.- Parameters:
effectiveModel- is the effective POMModelto process.flattenedDependencies- is theListwhere to add the collecteddependencies.- Throws:
org.apache.maven.plugin.MojoExecutionException- if anything goes wrong.
-
createFlattenedDependency
protected org.apache.maven.model.Dependency createFlattenedDependency(org.apache.maven.model.Dependency projectDependency)
- Parameters:
projectDependency- is the projectDependency.- Returns:
- the flattened
Dependencyornullif the givenDependencyis NOT relevant for flattened POM.
-
isUpdatePomFile
public boolean isUpdatePomFile()
- Returns:
trueif the generated flattened POM shall besetas POM artifact of theMavenProject,falseotherwise.
-
-