Class 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 Details

    • depVersion

      @Parameter(property="depVersion", required=true) protected String depVersion
      The exact version to be applied for the included dependencies
    • forceVersion

      @Parameter(property="forceVersion", defaultValue="false") protected boolean forceVersion
      If set to true, 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 processProperties

      Will 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 processProperties being false. 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.MojoExecutionException
      Description copied from class: AbstractVersionsUpdaterMojo
      Validates input parameters
      Overrides:
      validateInput in class AbstractVersionsUpdaterMojo
      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: AbstractVersionsUpdaterMojo
      Updates the pom.
      Specified by:
      update in class AbstractVersionsUpdaterMojo
      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.MojoFailureException
      Description copied from class: AbstractVersionsUpdaterMojo
      Specified by:
      execute in interface org.apache.maven.plugin.Mojo
      Overrides:
      execute in class AbstractVersionsUpdaterMojo
      Throws:
      org.apache.maven.plugin.MojoExecutionException
      org.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.MojoExecutionException
      Processes a single model and POM file associated with it
      Parameters:
      node - tree node to process
      propertyBacklog - a Set instance 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 - an Map instance 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:
      true if the file has been changed
      Throws:
      org.apache.maven.plugin.MojoFailureException
      org.apache.maven.plugin.MojoExecutionException