Package org.codehaus.mojo.versions
Class AbstractVersionsUpdaterMojo
java.lang.Object
org.apache.maven.plugin.AbstractMojo
org.codehaus.mojo.versions.AbstractVersionsUpdaterMojo
- All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled,org.apache.maven.plugin.Mojo
- Direct Known Subclasses:
AbstractVersionsDependencyUpdaterMojo,AbstractVersionsDisplayMojo,SetMojo,SetPropertyMojo,SetScmTagMojo,UpdateChildModulesMojo,UpdateParentMojo
public abstract class AbstractVersionsUpdaterMojo
extends org.apache.maven.plugin.AbstractMojo
Abstract base class for Versions Mojos.
- Author:
- Stephen Connolly
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanWhether to allow snapshots when searching for the latest version of an artifact.protected final org.apache.maven.artifact.handler.manager.ArtifactHandlerManagerThe (injected)ArtifactHandlerManagerinstance.protected booleanControls whether a backup pom should be created.Allows specifying ignored versions directly as an alternative to providing the ruleSet parameter; mainly created for-Dproperty usage.protected org.apache.maven.project.MavenProjectThe Maven Project.protected List<org.apache.maven.project.MavenProject> protected org.eclipse.aether.RepositorySystemThe (injected)RepositorySysteminstance.protected RuleSetAllows specifying the RuleSet object describing rules on artifact versions to ignore when considering updates.protected org.apache.maven.execution.MavenSessionThe Maven Session.(injected) map ofWagoninstancesFields inherited from interface org.apache.maven.plugin.Mojo
ROLE -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractVersionsUpdaterMojo(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 org.apache.maven.artifact.versioning.ArtifactVersionfindLatestVersion(org.apache.maven.artifact.Artifact artifact, org.apache.maven.artifact.versioning.VersionRange versionRange, Boolean allowingSnapshots, boolean usePluginRepositories) Finds the latest version of the specified artifact that matches the version range.protected ChangeRecorderConfigure and return the change recorder.org.apache.maven.project.MavenProjectGetter for property 'project'.protected voidProcesses the specified file.protected voidSave all of the changes recorded by the change recorder.voidsetProject(org.apache.maven.project.MavenProject project) Setter for property 'project'.protected booleanshouldApplyUpdate(org.apache.maven.artifact.Artifact artifact, String currentVersion, org.apache.maven.artifact.versioning.ArtifactVersion updateVersion) Deprecated.This method no longer supported.protected booleanshouldApplyUpdate(org.apache.maven.artifact.Artifact artifact, String currentVersion, org.apache.maven.artifact.versioning.ArtifactVersion updateVersion, boolean forceUpdate) Returnstrueif the update should be applied.protected abstract voidUpdates the pom.protected org.apache.maven.artifact.versioning.ArtifactVersionupdatePropertyToNewestVersion(MutableXMLStreamReader pom, Property property, PropertyVersions version, String currentVersion, boolean allowDowngrade, Optional<Segment> unchangedSegment) Attempts to update the property to a newer version, if that existsprotected voidValidates input parametersMethods inherited from class org.apache.maven.plugin.AbstractMojo
getLog, getPluginContext, setLog, setPluginContext
-
Field Details
-
project
@Parameter(defaultValue="${project}", required=true, readonly=true) protected org.apache.maven.project.MavenProject projectThe Maven Project.- Since:
- 1.0-alpha-1
-
artifactHandlerManager
protected final org.apache.maven.artifact.handler.manager.ArtifactHandlerManager artifactHandlerManagerThe (injected)ArtifactHandlerManagerinstance. -
repositorySystem
protected org.eclipse.aether.RepositorySystem repositorySystemThe (injected)RepositorySysteminstance. -
reactorProjects
@Parameter(defaultValue="${reactorProjects}", required=true, readonly=true) protected List<org.apache.maven.project.MavenProject> reactorProjects- Since:
- 1.0-alpha-1
-
generateBackupPoms
@Parameter(property="generateBackupPoms", defaultValue="true") protected boolean generateBackupPomsControls whether a backup pom should be created.- Since:
- 1.0-alpha-3
-
allowSnapshots
@Parameter(property="allowSnapshots", defaultValue="false") protected boolean allowSnapshotsWhether to allow snapshots when searching for the latest version of an artifact.- Since:
- 1.0-alpha-1
-
session
@Parameter(defaultValue="${session}", required=true, readonly=true) protected org.apache.maven.execution.MavenSession sessionThe Maven Session.- Since:
- 1.0-alpha-1
-
ruleSet
Allows specifying the RuleSet object describing rules on artifact versions to ignore when considering updates.
- Since:
- 2.13.0
- See Also:
-
ignoredVersions
Allows specifying ignored versions directly as an alternative to providing the ruleSet parameter; mainly created for
-Dproperty usage.Example:
"1\.0\.1,.+-M.,.*-SNAPSHOT"Currently, this parameter will override the defined
ruleSet- Since:
- 2.13.0
-
wagonMap
(injected) map ofWagoninstances- Since:
- 2.14.0
-
-
Constructor Details
-
AbstractVersionsUpdaterMojo
@Inject protected AbstractVersionsUpdaterMojo(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
-
getHelper
- Throws:
org.apache.maven.plugin.MojoExecutionException
-
getProject
public org.apache.maven.project.MavenProject getProject()Getter for property 'project'.- Returns:
- Value for property 'project'.
- Since:
- 1.0-alpha-1
-
setProject
public void setProject(org.apache.maven.project.MavenProject project) Setter for property 'project'.- Parameters:
project- Value to set for property 'project'.- Since:
- 1.0-alpha-1
-
getVersion
-
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- Since:
- 1.0-alpha-1
-
validateInput
protected void validateInput() throws org.apache.maven.plugin.MojoExecutionExceptionValidates input parameters- Throws:
org.apache.maven.plugin.MojoExecutionException- thrown if any of input parameters is invalid
-
findLatestVersion
protected org.apache.maven.artifact.versioning.ArtifactVersion findLatestVersion(org.apache.maven.artifact.Artifact artifact, org.apache.maven.artifact.versioning.VersionRange versionRange, Boolean allowingSnapshots, boolean usePluginRepositories) throws org.apache.maven.plugin.MojoExecutionException, VersionRetrievalException Finds the latest version of the specified artifact that matches the version range.- Parameters:
artifact- The artifact.versionRange- The version range.allowingSnapshots-nullfor no override, otherwise the local override to apply.usePluginRepositories- Use plugin repositories- Returns:
- The latest version of the specified artifact that matches the specified version range or
nullif no matching version could be found. - Throws:
VersionRetrievalException- If the artifact metadata could not be found.org.apache.maven.plugin.MojoExecutionException- if something goes wrong.- Since:
- 1.0-alpha-1
-
process
protected void process(File outFile) throws org.apache.maven.plugin.MojoExecutionException, org.apache.maven.plugin.MojoFailureException Processes the specified file. This is an extension point to allow updating a file external to the reactor.- Parameters:
outFile- The file to process.- Throws:
org.apache.maven.plugin.MojoExecutionException- If things go wrong.org.apache.maven.plugin.MojoFailureException- If things go wrong.- Since:
- 1.0-alpha-1
-
update
protected abstract void update(MutableXMLStreamReader pom) throws org.apache.maven.plugin.MojoExecutionException, org.apache.maven.plugin.MojoFailureException, XMLStreamException, VersionRetrievalException Updates the pom.- 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- Since:
- 1.0-alpha-1
-
shouldApplyUpdate
@Deprecated protected boolean shouldApplyUpdate(org.apache.maven.artifact.Artifact artifact, String currentVersion, org.apache.maven.artifact.versioning.ArtifactVersion updateVersion) Deprecated.This method no longer supported. use shouldApplyUpdate( Artifact artifact, String currentVersion, ArtifactVersion updateVersion, Boolean forceUpdate )Returns
trueif the update should be applied.- Parameters:
artifact- The artifact.currentVersion- The current version of the artifact.updateVersion- The proposed new version of the artifact.- Returns:
trueif the update should be applied.- Since:
- 1.0-alpha-1
-
shouldApplyUpdate
protected boolean shouldApplyUpdate(org.apache.maven.artifact.Artifact artifact, String currentVersion, org.apache.maven.artifact.versioning.ArtifactVersion updateVersion, boolean forceUpdate) Returnstrueif the update should be applied.- Parameters:
artifact- The artifact.currentVersion- The current version of the artifact.updateVersion- The proposed new version of the artifact.forceUpdate- if true, LATEST and RELEASE versions will be overwritten with the real version- Returns:
trueif the update should be applied to the pom.- Since:
- 2.9
-
updatePropertyToNewestVersion
protected org.apache.maven.artifact.versioning.ArtifactVersion updatePropertyToNewestVersion(MutableXMLStreamReader pom, Property property, PropertyVersions version, String currentVersion, boolean allowDowngrade, Optional<Segment> unchangedSegment) throws XMLStreamException, org.apache.maven.artifact.versioning.InvalidVersionSpecificationException, InvalidSegmentException, org.apache.maven.plugin.MojoExecutionException Attempts to update the property to a newer version, if that exists- Parameters:
pom- pom to updateproperty- property to updateversion-PropertyVersionsobjectcurrentVersion- current versionallowDowngrade- if downgrades should be allowed if snapshots are not allowedunchangedSegment- most major segment not to be changed- Returns:
- new version of the artifact, if the property was updated;
nullif there was no update - Throws:
XMLStreamException- thrown fromMutableXMLStreamReaderif the update doesn't succeedorg.apache.maven.artifact.versioning.InvalidVersionSpecificationException- thrown ifunchangedSegmentdoesn't match the versionInvalidSegmentException- thrown ifunchangedSegmentis invalidorg.apache.maven.plugin.MojoExecutionException- thrown if any other error occurs
-
getChangeRecorder
Configure and return the change recorder.- Returns:
- The change recorder
- Throws:
org.apache.maven.plugin.MojoExecutionException- if something goes wrong.
-
saveChangeRecorderResults
protected void saveChangeRecorderResults() throws IOException, org.apache.maven.plugin.MojoExecutionExceptionSave all of the changes recorded by the change recorder.- Throws:
IOException- On I/O errorsorg.apache.maven.plugin.MojoExecutionException- if something goes wrong.
-