[MNG-7570] Plugin descriptor can carry the required Maven version (#832)

Its value takes precedence over POMs Maven prerequisite
This commit is contained in:
Konrad Windszus 2022-10-19 08:15:28 +02:00 committed by GitHub
parent d857c3a915
commit daa8e16902
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 1 deletions

View File

@ -201,7 +201,11 @@ public class DefaultMavenPluginManager
pluginDescriptor = extractPluginDescriptor( pluginArtifact, plugin );
pluginDescriptor.setRequiredMavenVersion( artifact.getProperty( "requiredMavenVersion", null ) );
if ( StringUtils.isBlank( pluginDescriptor.getRequiredMavenVersion() ) )
{
// only take value from underlying POM if plugin descriptor has no explicit Maven requirement
pluginDescriptor.setRequiredMavenVersion( artifact.getProperty( "requiredMavenVersion", null ) );
}
pluginDescriptorCache.put( cacheKey, pluginDescriptor );
}

View File

@ -67,6 +67,7 @@ public class PluginDescriptorBuilder
pluginDescriptor.setIsolatedRealm( extractIsolatedRealm( c ) );
pluginDescriptor.setInheritedByDefault( extractInheritedByDefault( c ) );
pluginDescriptor.setRequiredJavaVersion( extractRequiredJavaVersion( c ).orElse( null ) );
pluginDescriptor.setRequiredMavenVersion( extractRequiredMavenVersion( c ).orElse( null ) );
pluginDescriptor.addMojos( extractMojos( c, pluginDescriptor ) );
@ -147,6 +148,11 @@ public class PluginDescriptorBuilder
return Optional.ofNullable( c.getChild( "requiredJavaVersion" ) ).map( PlexusConfiguration::getValue );
}
private Optional<String> extractRequiredMavenVersion( PlexusConfiguration c )
{
return Optional.ofNullable( c.getChild( "requiredMavenVersion" ) ).map( PlexusConfiguration::getValue );
}
private List<ComponentDependency> extractComponentDependencies( PlexusConfiguration c )
{

View File

@ -99,6 +99,12 @@ under the License.
<description>A version range which specifies the supported Java versions. The same values as for POM profile activation element 'jdk' are allowed, i.e. version ranges, version prefixes and negated version prefixes (starting with '!').</description>
<type>String</type>
</field>
<field>
<name>requiredMavenVersion</name>
<version>1.1.0+</version>
<description>A version range which specifies the supported Maven versions. A version range can either use the usual mathematical syntax "[2.0.10,2.1.0),[3.0,)" or use a single version "2.2.1". The latter is a short form for "[2.2.1,)", i.e. denotes the minimum version required. This value takes precedence over the POMs Maven prerequisite.</description>
<type>String</type>
</field>
<field xdoc.separator="blank">
<name>mojos</name>
<version>1.0.0+</version>