Package org.codehaus.mojo.versions
Class UseDepVersionMojo
java.lang.Object
org.apache.maven.plugin.AbstractMojo
org.codehaus.mojo.versions.AbstractVersionsUpdaterMojo
org.codehaus.mojo.versions.AbstractVersionsDependencyUpdaterMojo
org.codehaus.mojo.versions.UseDepVersionMojo
- All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled,org.apache.maven.plugin.Mojo
@Mojo(name="use-dep-version",
aggregator=true,
threadSafe=true)
public class UseDepVersionMojo
extends AbstractVersionsDependencyUpdaterMojo
Updates a dependency to a specific version.
This can be useful if you have to manage versions for a very large (100+ module) projects where you can’t always use
the most up-to-date version of a particular third party component.
- Since:
- 2.3
- Author:
- Dan Arcari
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected StringThe exact version to be applied for the included dependenciesprotected booleanIf set totrue, will use whatever version is supplied without attempting to validate that such a version is obtainable from the repository chain.protected booleanWill augment normal processing by, if a dependency value is set using a property, trying to update the value of the property.Fields inherited from class org.codehaus.mojo.versions.AbstractVersionsDependencyUpdaterMojo
SNAPSHOT_REGEXFields inherited from class org.codehaus.mojo.versions.AbstractVersionsUpdaterMojo
allowSnapshots, artifactHandlerManager, generateBackupPoms, ignoredVersions, project, reactorProjects, repositorySystem, ruleSet, session, wagonMapFields inherited from interface org.apache.maven.plugin.Mojo
ROLE -
Constructor Summary
ConstructorsConstructorDescriptionUseDepVersionMojo(org.apache.maven.artifact.handler.manager.ArtifactHandlerManager artifactHandlerManager, org.eclipse.aether.RepositorySystem repositorySystem, Map<String, org.apache.maven.wagon.Wagon> wagonMap, Map<String, ChangeRecorder> changeRecorders) -
Method Summary
Modifier and TypeMethodDescriptionvoidexecute()protected booleanprocessModel(ModelNode node, Set<String> propertyBacklog, Map<String, Set<org.apache.maven.model.Dependency>> propertyConflicts, Charset charset) Processes a single model and POM file associated with itprotected voidUpdates the pom.protected voidValidates input parametersMethods inherited from class org.codehaus.mojo.versions.AbstractVersionsDependencyUpdaterMojo
findArtifact, getParentDependency, hasIncludes, isExcludeReactor, isHandledByProperty, isIncluded, isProcessingDependencies, isProcessingDependencyManagement, isProcessingParent, isProducedByReactor, separatePatterns, toArtifact, toArtifact, toString, toString, updateDependencyVersionMethods inherited from class org.codehaus.mojo.versions.AbstractVersionsUpdaterMojo
findLatestVersion, getChangeRecorder, getHelper, getProject, getVersion, process, saveChangeRecorderResults, setProject, shouldApplyUpdate, shouldApplyUpdate, updatePropertyToNewestVersionMethods inherited from class org.apache.maven.plugin.AbstractMojo
getLog, getPluginContext, setLog, setPluginContext
-
Field Details
-
depVersion
The exact version to be applied for the included dependencies -
forceVersion
@Parameter(property="forceVersion", defaultValue="false") protected boolean forceVersionIf set totrue, will use whatever version is supplied without attempting to validate that such a version is obtainable from the repository chain. -
processProperties
@Parameter(property="processProperties", defaultValue="false") protected boolean processPropertiesWill augment normal processing by, if a dependency value is set using a property, trying to update the value of the property.
If the property value is specified directly, will process it normally (as with
processPropertiesbeingfalse. If the property being updated is redefined in the reactor tree, will only change the property value which lies closest to the dependency being updated. If the same property is also used to set the value of another dependency, will not update that property value, and log a warning instead. Finally, if the property value is specified in a parent file which is outside of the project, will log a message.Default is
false.- Since:
- 2.15.0
-
-
Constructor Details
-
UseDepVersionMojo
@Inject public UseDepVersionMojo(org.apache.maven.artifact.handler.manager.ArtifactHandlerManager artifactHandlerManager, org.eclipse.aether.RepositorySystem repositorySystem, Map<String, org.apache.maven.wagon.Wagon> wagonMap, Map<String, ChangeRecorder> changeRecorders)
-
-
Method Details
-
validateInput
protected void validateInput() throws org.apache.maven.plugin.MojoExecutionExceptionDescription copied from class:AbstractVersionsUpdaterMojoValidates input parameters- Overrides:
validateInputin classAbstractVersionsUpdaterMojo- Throws:
org.apache.maven.plugin.MojoExecutionException- thrown if any of input parameters is invalid
-
update
protected void update(MutableXMLStreamReader pom) throws org.apache.maven.plugin.MojoExecutionException, org.apache.maven.plugin.MojoFailureException, XMLStreamException, VersionRetrievalException Description copied from class:AbstractVersionsUpdaterMojoUpdates the pom.- Specified by:
updatein classAbstractVersionsUpdaterMojo- Parameters:
pom- The pom to update.- Throws:
org.apache.maven.plugin.MojoExecutionException- If things go wrong.org.apache.maven.plugin.MojoFailureException- If things go wrong.XMLStreamException- If things go wrong.VersionRetrievalException- if version retrieval goes wrong
-
execute
public void execute() throws org.apache.maven.plugin.MojoExecutionException, org.apache.maven.plugin.MojoFailureExceptionDescription copied from class:AbstractVersionsUpdaterMojo- Specified by:
executein interfaceorg.apache.maven.plugin.Mojo- Overrides:
executein classAbstractVersionsUpdaterMojo- Throws:
org.apache.maven.plugin.MojoExecutionExceptionorg.apache.maven.plugin.MojoFailureException
-
processModel
protected boolean processModel(ModelNode node, Set<String> propertyBacklog, Map<String, Set<org.apache.maven.model.Dependency>> propertyConflicts, Charset charset) throws org.apache.maven.plugin.MojoFailureException, org.apache.maven.plugin.MojoExecutionExceptionProcesses a single model and POM file associated with it- Parameters:
node- tree node to processpropertyBacklog- aSetinstance used to store dependencies to be updated, but which were not found in the current subtree. These properties need to be carried over to the parent node for processing.propertyConflicts- anMapinstance to store properties which are associated with dependencies which do not fit the filter and thus may not be changed. This is then used for conflict detection if a dependency to be changed used one of these properties. Such a change is not allowed and must be reported instead.charset- charset for file writing- Returns:
trueif the file has been changed- Throws:
org.apache.maven.plugin.MojoFailureExceptionorg.apache.maven.plugin.MojoExecutionException
-