public abstract class AbstractVersionsUpdaterMojo
extends org.apache.maven.plugin.AbstractMojo
| Modifier and Type | Field and Description |
|---|---|
protected org.eclipse.aether.RepositorySystem |
aetherRepositorySystem
The (injected)
RepositorySystem instance. |
protected boolean |
allowSnapshots
Whether to allow snapshots when searching for the latest version of an artifact.
|
protected Set<String> |
ignoredVersions
Allows specifying ignored versions directly as an alternative
to providing the ruleSet parameter; mainly created
for
-D property usage. |
protected org.apache.maven.project.MavenProject |
project
The Maven Project.
|
protected List<org.apache.maven.project.MavenProject> |
reactorProjects |
protected org.apache.maven.repository.RepositorySystem |
repositorySystem
The (injected)
RepositorySystem instance. |
protected RuleSet |
ruleSet
Allows specifying the RuleSet object describing rules
on artifact versions to ignore when considering updates.
|
protected org.apache.maven.execution.MavenSession |
session
The Maven Session.
|
protected Map<String,org.apache.maven.wagon.Wagon> |
wagonMap
(injected) map of
Wagon instances |
| Modifier | Constructor and Description |
|---|---|
protected |
AbstractVersionsUpdaterMojo(org.apache.maven.repository.RepositorySystem repositorySystem,
org.eclipse.aether.RepositorySystem aetherRepositorySystem,
Map<String,org.apache.maven.wagon.Wagon> wagonMap,
Map<String,org.codehaus.mojo.versions.api.recording.ChangeRecorder> changeRecorders) |
| Modifier and Type | Method and Description |
|---|---|
void |
execute() |
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)
Finds the latest version of the specified artifact that matches the version range.
|
protected org.codehaus.mojo.versions.api.recording.ChangeRecorder |
getChangeRecorder()
Configure and return the change recorder.
|
VersionsHelper |
getHelper() |
org.apache.maven.project.MavenProject |
getProject()
Getter for property 'project'.
|
protected String |
getPropertyValue(StringBuilder pom,
String property)
Gets the property value that is defined in the pom.
|
String |
getVersion() |
protected ModifiedPomXMLEventReader |
newModifiedPomXER(StringBuilder input,
String path)
Creates a
ModifiedPomXMLEventReader from a StringBuilder. |
protected void |
process(File outFile)
Processes the specified file.
|
protected void |
saveChangeRecorderResults()
Save all of the changes recorded by the change recorder.
|
void |
setProject(org.apache.maven.project.MavenProject project)
Setter for property 'project'.
|
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 |
protected boolean |
shouldApplyUpdate(org.apache.maven.artifact.Artifact artifact,
String currentVersion,
org.apache.maven.artifact.versioning.ArtifactVersion updateVersion,
boolean forceUpdate)
Returns
true if the update should be applied. |
protected abstract void |
update(ModifiedPomXMLEventReader pom)
Updates the pom.
|
protected org.apache.maven.artifact.versioning.ArtifactVersion |
updatePropertyToNewestVersion(ModifiedPomXMLEventReader pom,
Property property,
PropertyVersions version,
String currentVersion,
boolean allowDowngrade,
Optional<Segment> unchangedSegment)
Attempts to update the property to a newer version, if that exists
|
protected void |
validateInput()
Validates input parameters
|
protected void |
writeFile(File outFile,
StringBuilder input)
Writes a StringBuilder into a file.
|
@Parameter(defaultValue="${project}",
required=true,
readonly=true)
protected org.apache.maven.project.MavenProject project
protected final org.apache.maven.repository.RepositorySystem repositorySystem
RepositorySystem instance.protected org.eclipse.aether.RepositorySystem aetherRepositorySystem
RepositorySystem instance.@Parameter(defaultValue="${reactorProjects}",
required=true,
readonly=true)
protected List<org.apache.maven.project.MavenProject> reactorProjects
@Parameter(property="allowSnapshots",
defaultValue="false")
protected boolean allowSnapshots
@Parameter(defaultValue="${session}",
required=true,
readonly=true)
protected org.apache.maven.execution.MavenSession session
@Parameter protected RuleSet ruleSet
Allows specifying the RuleSet object describing rules on artifact versions to ignore when considering updates.
@Parameter(property="maven.version.ignore") protected Set<String> ignoredVersions
Allows specifying ignored versions directly as an alternative
to providing the ruleSet parameter; mainly created
for -D property usage.
Example: "1\.0\.1,.+-M.,.*-SNAPSHOT"
Currently, this parameter will override the defined ruleSet
@Inject
protected AbstractVersionsUpdaterMojo(org.apache.maven.repository.RepositorySystem repositorySystem,
org.eclipse.aether.RepositorySystem aetherRepositorySystem,
Map<String,org.apache.maven.wagon.Wagon> wagonMap,
Map<String,org.codehaus.mojo.versions.api.recording.ChangeRecorder> changeRecorders)
public VersionsHelper getHelper() throws org.apache.maven.plugin.MojoExecutionException
org.apache.maven.plugin.MojoExecutionExceptionpublic org.apache.maven.project.MavenProject getProject()
public void setProject(org.apache.maven.project.MavenProject project)
project - Value to set for property 'project'.public String getVersion()
public void execute()
throws org.apache.maven.plugin.MojoExecutionException,
org.apache.maven.plugin.MojoFailureException
org.apache.maven.plugin.MojoExecutionExceptionorg.apache.maven.plugin.MojoFailureExceptionprotected void validateInput()
throws org.apache.maven.plugin.MojoExecutionException
org.apache.maven.plugin.MojoExecutionException - thrown if any of input parameters is invalidprotected 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
artifact - The artifact.versionRange - The version range.allowingSnapshots - null for no override, otherwise the local override to apply.usePluginRepositories - Use plugin repositoriesnull if no matching version could be found.VersionRetrievalException - If the artifact metadata could not be found.org.apache.maven.plugin.MojoExecutionException - if something goes wrong.protected String getPropertyValue(StringBuilder pom, String property)
pom - The pom.property - The property.null if not defined.protected void process(File outFile) throws org.apache.maven.plugin.MojoExecutionException, org.apache.maven.plugin.MojoFailureException
outFile - The file to process.org.apache.maven.plugin.MojoExecutionException - If things go wrong.org.apache.maven.plugin.MojoFailureException - If things go wrong.protected final ModifiedPomXMLEventReader newModifiedPomXER(StringBuilder input, String path)
ModifiedPomXMLEventReader from a StringBuilder.input - The XML to read and modify.path - Path pointing to the source of the XMLModifiedPomXMLEventReader.protected final void writeFile(File outFile, StringBuilder input) throws IOException
outFile - The file to read.input - The contents of the file.IOException - when things go wrong.protected abstract void update(ModifiedPomXMLEventReader pom) throws org.apache.maven.plugin.MojoExecutionException, org.apache.maven.plugin.MojoFailureException, XMLStreamException, VersionRetrievalException
pom - The pom to update.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@Deprecated protected boolean shouldApplyUpdate(org.apache.maven.artifact.Artifact artifact, String currentVersion, org.apache.maven.artifact.versioning.ArtifactVersion updateVersion)
Returns true if the update should be applied.
artifact - The artifact.currentVersion - The current version of the artifact.updateVersion - The proposed new version of the artifact.true if the update should be applied.protected boolean shouldApplyUpdate(org.apache.maven.artifact.Artifact artifact,
String currentVersion,
org.apache.maven.artifact.versioning.ArtifactVersion updateVersion,
boolean forceUpdate)
true if the update should be applied.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 versiontrue if the update should be applied to the pom.protected org.apache.maven.artifact.versioning.ArtifactVersion updatePropertyToNewestVersion(ModifiedPomXMLEventReader 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
pom - pom to updateproperty - property to updateversion - PropertyVersions objectcurrentVersion - current versionallowDowngrade - if downgrades should be allowed if snapshots are not allowedunchangedSegment - most major segment not to be changednull if there was no updateXMLStreamException - thrown from ModifiedPomXMLEventReader if the update doesn't succeedorg.apache.maven.artifact.versioning.InvalidVersionSpecificationException - thrown if unchangedSegment doesn't match the versionInvalidSegmentException - thrown if unchangedSegment is invalidorg.apache.maven.plugin.MojoExecutionException - thrown if any other error occursprotected org.codehaus.mojo.versions.api.recording.ChangeRecorder getChangeRecorder() throws org.apache.maven.plugin.MojoExecutionException
org.apache.maven.plugin.MojoExecutionException - if something goes wrong.protected void saveChangeRecorderResults()
throws IOException,
org.apache.maven.plugin.MojoExecutionException
IOException - On I/O errorsorg.apache.maven.plugin.MojoExecutionException - if something goes wrong.Copyright © 2008–2022 MojoHaus. All rights reserved.