Class AbstractVersionsDependencyUpdaterMojo

java.lang.Object
org.apache.maven.plugin.AbstractMojo
org.codehaus.mojo.versions.AbstractVersionsUpdaterMojo
org.codehaus.mojo.versions.AbstractVersionsDependencyUpdaterMojo
All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled, org.apache.maven.plugin.Mojo
Direct Known Subclasses:
CompareDependenciesMojo, ForceReleasesMojo, LockSnapshotsMojo, ResolveRangesMojo, UnlockSnapshotsMojo, UpdatePropertiesMojoBase, UseDepVersionMojo, UseLatestVersionsMojoBase, UseReactorMojo, UseReleasesMojo

public abstract class AbstractVersionsDependencyUpdaterMojo extends AbstractVersionsUpdaterMojo
Base class for a mojo that updates dependency versions.
Since:
1.0-alpha-3
Author:
Paul Gier, Stephen Connolly
  • Field Details

    • SNAPSHOT_REGEX

      protected static final Pattern SNAPSHOT_REGEX
      Pattern to match snapshot versions
  • Constructor Details

    • AbstractVersionsDependencyUpdaterMojo

      @Inject protected AbstractVersionsDependencyUpdaterMojo(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

    • isProcessingDependencies

      public boolean isProcessingDependencies()
      Should the project/dependencies section of the pom be processed.
      Returns:
      returns true if the project/dependencies section of the pom should be processed.
      Since:
      1.0-alpha-3
    • isProcessingDependencyManagement

      public boolean isProcessingDependencyManagement()
      Should the project/dependencyManagement section of the pom be processed.
      Returns:
      returns true if the project/dependencyManagement section of the pom should be processed.
      Since:
      1.0-alpha-3
    • isProcessingParent

      public boolean isProcessingParent()
      Should the project/parent section of the pom be processed.
      Returns:
      returns true if the project/parent section of the pom should be processed.
      Since:
      2.3
    • isExcludeReactor

      public boolean isExcludeReactor()
      Should the artifacts produced in the current reactor be excluded from processing.
      Returns:
      returns true if the artifacts produced in the current reactor should be excluded from processing.
      Since:
      1.0-alpha-3
    • isHandledByProperty

      protected boolean isHandledByProperty(org.apache.maven.model.Dependency dependency)
      Should the dependency be updated itself or is it handled by properties.
      Parameters:
      dependency - Dependency
      Returns:
      true if the version starts with '${'
      Since:
      2.8
    • findArtifact

      protected org.apache.maven.artifact.Artifact findArtifact(org.apache.maven.model.Dependency dependency)
      Try to find the dependency artifact that matches the given dependency.
      Parameters:
      dependency - Dependency
      Returns:
      Artifact
      Since:
      1.0-alpha-3
    • toArtifact

      protected org.apache.maven.artifact.Artifact toArtifact(org.apache.maven.model.Dependency dependency) throws org.apache.maven.plugin.MojoExecutionException
      Try to find the dependency artifact that matches the given dependency.
      Parameters:
      dependency - Dependency
      Returns:
      Artifact
      Throws:
      org.apache.maven.plugin.MojoExecutionException - Mojo execution exception
      Since:
      1.0-alpha-3
    • toArtifact

      protected org.apache.maven.artifact.Artifact toArtifact(org.apache.maven.model.Parent model) throws org.apache.maven.plugin.MojoExecutionException
      Throws:
      org.apache.maven.plugin.MojoExecutionException
    • getParentDependency

      protected org.apache.maven.model.Dependency getParentDependency()
      Returns the Dependency instance for the parent project
      Returns:
      Dependency object for the parent
    • toString

      protected String toString(org.apache.maven.project.MavenProject project)
    • toString

      protected String toString(org.apache.maven.model.Dependency d)
    • isProducedByReactor

      protected boolean isProducedByReactor(org.apache.maven.model.Dependency dependency)
      Returns true if the dependency is produced by the current reactor.
      Parameters:
      dependency - the dependency to heck.
      Returns:
      true if the dependency is produced by the current reactor.
      Since:
      1.0-alpha-3
    • isIncluded

      protected boolean isIncluded(org.apache.maven.artifact.Artifact artifact)
      Determine if the artifact is included in the list of artifacts to be processed.
      Parameters:
      artifact - The artifact we want to check.
      Returns:
      true if the artifact should be processed, false otherwise.
    • hasIncludes

      protected boolean hasIncludes()
      Indicates whether any includes were specified via the 'includes' or 'includesList' options.
      Returns:
      true if includes were specified, false otherwise.
    • separatePatterns

      protected List<String> separatePatterns(String includeString)
      To handle multiple includes with version range like "group:artifact:jar:[1.0.0,2.2)", we have to use a parsing a little bit more complex than split().
      Parameters:
      includeString - the string to parse
      Returns:
      list of patterns
    • updateDependencyVersion

      protected boolean updateDependencyVersion(MutableXMLStreamReader pom, org.apache.maven.model.Dependency dep, String newVersion, DependencyChangeRecord.ChangeKind changeKind) throws XMLStreamException, org.apache.maven.plugin.MojoExecutionException
      Attempts to update the dependency dep to the given newVersion. The dependency can either be the parent project or any given dependency.
      Parameters:
      pom - MutableXMLStreamReader instance to update the POM XML document
      dep - dependency to be updated (can also be a dependency made from the parent)
      newVersion - new version to update the dependency to
      changeKind - title for the ChangeRecorder log
      Returns:
      true if an update has been made, false otherwise
      Throws:
      XMLStreamException - thrown if updating the XML doesn't succeed
      org.apache.maven.plugin.MojoExecutionException