use of org.apache.maven.artifact.versioning.OverConstrainedVersionException in project sling by apache.
the class BundleDeployMojo method fixBundleVersion.
@Override
protected File fixBundleVersion(File jarFile) throws MojoExecutionException {
// by the maven deploy plugin
if (this.project.getVersion().indexOf("SNAPSHOT") > 0) {
// create new version string by replacing all '-' with '.'
String newVersion = this.project.getArtifact().getVersion();
int firstPos = newVersion.indexOf('-') + 1;
int pos = 0;
while (pos != -1) {
pos = newVersion.indexOf('-');
if (pos != -1) {
newVersion = newVersion.substring(0, pos) + '.' + newVersion.substring(pos + 1);
}
}
// now remove all dots after the third one
pos = newVersion.indexOf('.', firstPos);
while (pos != -1) {
newVersion = newVersion.substring(0, pos) + newVersion.substring(pos + 1);
pos = newVersion.indexOf('.', pos + 1);
}
return changeVersion(jarFile, project.getVersion(), newVersion);
}
// if this is a final release append "final"
try {
final ArtifactVersion v = this.project.getArtifact().getSelectedVersion();
if (v.getBuildNumber() == 0 && v.getQualifier() == null) {
final String newVersion = this.project.getArtifact().getVersion() + ".FINAL";
return changeVersion(jarFile, project.getVersion(), newVersion);
}
} catch (OverConstrainedVersionException ocve) {
// we ignore this and don't append "final"!
}
// just return the file in case of some issues
return jarFile;
}
Aggregations