Skip to content

Commit

Permalink
Fixed #168
Browse files Browse the repository at this point in the history
 o Added allowMajorUpdates, allowMinorUpdates, allowIncrementalUpdates
   to resolve-ranges and display-property-updates goal.
  • Loading branch information
khmarbaise committed Jun 15, 2017
1 parent 0c8916f commit b2d6b1c
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,30 @@ public class DisplayPropertyUpdatesMojo
@Parameter( property = "autoLinkItems", defaultValue = "true" )
private boolean autoLinkItems;

/**
* Whether to allow the major version number to be changed.
*
* @since 2.5
*/
@Parameter( property = "allowMajorUpdates", defaultValue = "true" )
private boolean allowMajorUpdates;

/**
* Whether to allow the minor version number to be changed.
*
* @since 2.5
*/
@Parameter( property = "allowMinorUpdates", defaultValue = "true" )
private boolean allowMinorUpdates;

/**
* Whether to allow the incremental version number to be changed.
*
* @since 2.5
*/
@Parameter( property = "allowIncrementalUpdates", defaultValue = "true" )
private boolean allowIncrementalUpdates;

// -------------------------- STATIC METHODS --------------------------

// -------------------------- OTHER METHODS --------------------------
Expand All @@ -112,9 +136,9 @@ public void execute()
continue;
}

// FIXME: Check the parameters -1 ? correct?
int segment = determineUnchangedSegment( allowMajorUpdates, allowMinorUpdates, allowIncrementalUpdates );
ArtifactVersion winner = version.getNewestVersion( currentVersion, property, this.allowSnapshots,
this.reactorProjects, this.getHelper(), false, -1 );
this.reactorProjects, this.getHelper(), false, segment );

if ( winner != null && !currentVersion.equals( winner.toString() ) )
{
Expand Down
29 changes: 28 additions & 1 deletion src/main/java/org/codehaus/mojo/versions/ResolveRangesMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,30 @@ public class ResolveRangesMojo
@Parameter( property = "excludeProperties" )
private String excludeProperties = null;

/**
* Whether to allow the major version number to be changed.
*
* @since 2.5
*/
@Parameter( property = "allowMajorUpdates", defaultValue = "true" )
private boolean allowMajorUpdates;

/**
* Whether to allow the minor version number to be changed.
*
* @since 2.5
*/
@Parameter( property = "allowMinorUpdates", defaultValue = "true" )
private boolean allowMinorUpdates;

/**
* Whether to allow the incremental version number to be changed.
*
* @since 2.5
*/
@Parameter( property = "allowIncrementalUpdates", defaultValue = "true" )
private boolean allowIncrementalUpdates;

// ------------------------------ FIELDS ------------------------------

/**
Expand Down Expand Up @@ -253,7 +277,10 @@ private void resolvePropertyRanges( ModifiedPomXMLEventReader pom )
}

property.setVersion( currentVersion );
updatePropertyToNewestVersion( pom, property, version, currentVersion );

int segment = determineUnchangedSegment( allowMajorUpdates, allowMinorUpdates, allowIncrementalUpdates );
// TODO: Check if we could add allowDowngrade ?
updatePropertyToNewestVersion( pom, property, version, currentVersion, false, segment );

}
}
Expand Down

0 comments on commit b2d6b1c

Please sign in to comment.