Enhance DefaultVersionInfo getNextVersion to increment version at specified
index
----------------------------------------------------------------------------------
Key: MRELEASE-596
URL: http://jira.codehaus.org/browse/MRELEASE-596
Project: Maven 2.x Release Plugin
Issue Type: New Feature
Reporter: Prashant Bhate
Attachments: DefaultVersionInfoTest.java
Current DefaultVersionInfo always increment either annotationRevision if
available or least version from digits. say if 1.2.3 would be incremented to
1.2.4 always.
I am currently implementing fix for
http://jira.codehaus.org/browse/MVERSIONS-124 which requires NextVersion with
version incremented at specified index.
Hence it would be good to include another method shown below that will
increment annotationRevision if parameter index is -ve. Otherwise it would
roll the digit at specified index and reset rest of the digits
{code}
/**
* Increment version at specified index. While incrementing digits set
* remaining segments to zero.
*
* @param index
* If -ve increment annotationRevision else increment digits
at
* index and reset remaining to 0.
* @return new instance of version info
*/
public VersionInfo getNextVersion(int index) {
DefaultVersionInfo version = null;
if (digits != null) {
List digits = new ArrayList(this.digits);
String annotationRevision = this.annotationRevision;
if (index < 0) {
if (StringUtils.isNumeric(annotationRevision)) {
annotationRevision =
incrementVersionString(annotationRevision);
}
} else if (index < digits.size()) {
int next = index;
digits.set(next,
incrementVersionString((String) digits
.get(next)));
for (int i = next + 1; i < digits.size(); i++) {
digits.set(i, "0");
}
}
version = new DefaultVersionInfo(digits, annotation,
annotationRevision, buildSpecifier,
annotationSeparator,
annotationRevSeparator, buildSeparator);
}
return version;
}
{code}
Request some one to validate this and schedule this for checkin if possible
Regards,
Prashant
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira