Skip to content

Commit

Permalink
#544 improve validation of plugin parameters:
Browse files Browse the repository at this point in the history
- ensure either 'properties' or 'propertiesVersionFile' is provided
- fix validation of superfluous newVersion parameter
  • Loading branch information
stefanseifert committed Jan 26, 2022
1 parent c6a985c commit e5c2ae3
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/main/java/org/codehaus/mojo/versions/SetPropertyMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,14 @@ protected void update( ModifiedPomXMLEventReader pom )
}
propertiesConfig = reader.getPropertiesConfig();
properties = reader.getProperties();
} else {
} else if (!StringUtils.isEmpty(property)) {
getLog().debug( "Reading properties and versions to update from property and newVersion " );
Property propertyConfig = new Property(property);
propertyConfig.setVersion(newVersion);
propertiesConfig = new Property[] { propertyConfig };
properties = property;
} else {
throw new MojoExecutionException("Please provide either 'property' or 'propertiesVersionsFile' parameter.");
}
update(pom, propertiesConfig, properties);
}
Expand Down Expand Up @@ -134,7 +136,7 @@ private void logWrongConfigWarning() {
if (!StringUtils.isEmpty(property)) {
getLog().warn("-Dproperty provided but will be ignored as -DpropertiesVersionsFile is used");
}
if (!StringUtils.isEmpty(property)) {
if (!StringUtils.isEmpty(newVersion)) {
getLog().warn("-DnewVersion provided but will be ignored as -DpropertiesVersionsFile is used");
}
}
Expand Down

0 comments on commit e5c2ae3

Please sign in to comment.