public void execute() throws MojoExecutionException, MojoFailureException {
getLog().debug("Looking for previous release of " + project.getGroupId() + ":" + project.getArtifactId() + ":"
+ project.getVersion());
Artifact projectArtifact = artifactFactory
.createProjectArtifact(project.getGroupId(), project.getArtifactId(), project.getVersion());
ArtifactVersion projectVersion = new DefaultArtifactVersion(project.getVersion());
ArtifactVersion latest = null;
try {
List<ArtifactVersion> artifactVersions = artifactMetadataSource
.retrieveAvailableVersions(projectArtifact, localRepository,
project.getRemoteArtifactRepositories());
for (ArtifactVersion version : artifactVersions) {
if (SNAPSHOT_PATTERN.matcher(version.toString()).find() || projectVersion.compareTo(version) <= 0) {
continue;
}
if (latest == null || latest.compareTo(version) < 0) {
latest = version;
}