Package org.codehaus.mojo.versions
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
Base class for a mojo that updates dependency versions.
- Since:
- 1.0-alpha-3
- Author:
- Paul Gier, Stephen Connolly
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final PatternPattern to match snapshot versionsFields 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
ConstructorsModifierConstructorDescriptionprotectedAbstractVersionsDependencyUpdaterMojo(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 TypeMethodDescriptionprotected org.apache.maven.artifact.ArtifactfindArtifact(org.apache.maven.model.Dependency dependency) Try to find the dependency artifact that matches the given dependency.protected org.apache.maven.model.DependencyReturns theDependencyinstance for the parent projectprotected booleanIndicates whether any includes were specified via the 'includes' or 'includesList' options.booleanShould the artifacts produced in the current reactor be excluded from processing.protected booleanisHandledByProperty(org.apache.maven.model.Dependency dependency) Should the dependency be updated itself or is it handled by properties.protected booleanisIncluded(org.apache.maven.artifact.Artifact artifact) Determine if the artifact is included in the list of artifacts to be processed.booleanShould the project/dependencies section of the pom be processed.booleanShould the project/dependencyManagement section of the pom be processed.booleanShould the project/parent section of the pom be processed.protected booleanisProducedByReactor(org.apache.maven.model.Dependency dependency) Returnstrueif the dependency is produced by the current reactor.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().protected org.apache.maven.artifact.ArtifacttoArtifact(org.apache.maven.model.Dependency dependency) Try to find the dependency artifact that matches the given dependency.protected org.apache.maven.artifact.ArtifacttoArtifact(org.apache.maven.model.Parent model) protected StringtoString(org.apache.maven.model.Dependency d) protected StringtoString(org.apache.maven.project.MavenProject project) protected booleanupdateDependencyVersion(MutableXMLStreamReader pom, org.apache.maven.model.Dependency dep, String newVersion, DependencyChangeRecord.ChangeKind changeKind) Attempts to update the dependencydepto the givennewVersion.Methods inherited from class org.codehaus.mojo.versions.AbstractVersionsUpdaterMojo
execute, findLatestVersion, getChangeRecorder, getHelper, getProject, getVersion, process, saveChangeRecorderResults, setProject, shouldApplyUpdate, shouldApplyUpdate, update, updatePropertyToNewestVersion, validateInputMethods inherited from class org.apache.maven.plugin.AbstractMojo
getLog, getPluginContext, setLog, setPluginContext
-
Field Details
-
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
trueif 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
trueif 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
trueif 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
trueif 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 theDependencyinstance for the parent project- Returns:
Dependencyobject for the parent
-
toString
-
toString
-
isProducedByReactor
protected boolean isProducedByReactor(org.apache.maven.model.Dependency dependency) Returnstrueif the dependency is produced by the current reactor.- Parameters:
dependency- the dependency to heck.- Returns:
trueif 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
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 dependencydepto the givennewVersion. The dependency can either be the parent project or any given dependency.- Parameters:
pom-MutableXMLStreamReaderinstance to update the POM XML documentdep- dependency to be updated (can also be a dependency made from the parent)newVersion- new version to update the dependency tochangeKind- title for theChangeRecorderlog- Returns:
trueif an update has been made,falseotherwise- Throws:
XMLStreamException- thrown if updating the XML doesn't succeedorg.apache.maven.plugin.MojoExecutionException
-