Uploaded image for project: 'Maven Release Plugin'
  1. Maven Release Plugin
  2. MRELEASE-596

Enhance DefaultVersionInfo getNextVersion to increment version at specified index

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Closed
    • Major
    • Resolution: Abandoned
    • None
    • None
    • None
    • None
    • Patch

    Description

      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

      	/**
      	 * 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;
      	}
      
      
      

      Request some one to validate this and schedule this for checkin if possible

      Regards,
      Prashant

      Attachments

        1. DefaultVersionInfo.java
          14 kB
          Prashant Bhate
        2. DefaultVersionInfoTest.java
          3 kB
          Prashant Bhate

        Issue Links

          Activity

            People

              Unassigned Unassigned
              prashant.bhate Prashant Bhate
              Votes:
              2 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: