mirror of https://github.com/apache/maven.git
Fix: IT0469 - Rule: join configs of build/plugins/plugin and reporting/plugins/plugin.
git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@705167 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
7c54aada90
commit
bedc1d7a2b
|
@ -37,12 +37,13 @@ public final class ArtifactModelContainerFactory
|
|||
private static final Collection<String> uris = Collections.unmodifiableList( Arrays.asList(
|
||||
|
||||
ProjectUri.DependencyManagement.Dependencies.Dependency.xUri, ProjectUri.Dependencies.Dependency.xUri,
|
||||
|
||||
ProjectUri.Reporting.Plugins.Plugin.xUri,
|
||||
ProjectUri.Build.PluginManagement.Plugins.Plugin.xUri,
|
||||
ProjectUri.Build.PluginManagement.Plugins.Plugin.Dependencies.Dependency.xUri,
|
||||
|
||||
ProjectUri.Build.Plugins.Plugin.xUri, ProjectUri.Build.Plugins.Plugin.Dependencies.Dependency.xUri,
|
||||
ProjectUri.Build.Plugins.Plugin.Dependencies.Dependency.Exclusions.Exclusion.xUri ) );
|
||||
ProjectUri.Build.Plugins.Plugin.Dependencies.Dependency.Exclusions.Exclusion.xUri
|
||||
) );
|
||||
|
||||
public Collection<String> getUris()
|
||||
{
|
||||
|
@ -128,7 +129,7 @@ public final class ArtifactModelContainerFactory
|
|||
sb.append( mp ).append( "\r\n" );
|
||||
}
|
||||
throw new IllegalArgumentException( "Properties does not contain artifact id. Group ID = " + groupId +
|
||||
", Version = " + version + ":" + sb );
|
||||
", Version = " + version + ", Base = " + uri + ":\r\n" + sb );
|
||||
}
|
||||
|
||||
if ( type == null )
|
||||
|
|
|
@ -50,6 +50,8 @@ public final class PomClassicTransformer
|
|||
|
||||
ProjectUri.Build.Plugins.xUri,
|
||||
ProjectUri.Build.Plugins.Plugin.configuration,
|
||||
ProjectUri.Reporting.Plugins.xUri,
|
||||
ProjectUri.Reporting.Plugins.Plugin.configuration,
|
||||
ProjectUri.Build.Plugins.Plugin.Dependencies.xUri,
|
||||
ProjectUri.Build.Plugins.Plugin.Executions.xUri,
|
||||
ProjectUri.Build.Resources.xUri,
|
||||
|
@ -223,6 +225,7 @@ public final class PomClassicTransformer
|
|||
}
|
||||
}
|
||||
props.removeAll( removeProperties );
|
||||
|
||||
String xml = null;
|
||||
try
|
||||
{
|
||||
|
@ -477,6 +480,27 @@ public final class PomClassicTransformer
|
|||
modelProperties.removeAll( clearedProperties );
|
||||
}
|
||||
|
||||
//Rule: Build plugin config overrides reporting plugin config
|
||||
ModelDataSource source = new DefaultModelDataSource();
|
||||
source.init( modelProperties, Arrays.asList( new ArtifactModelContainerFactory(), new IdModelContainerFactory() ) );
|
||||
|
||||
List<ModelContainer> reportContainers = source.queryFor( ProjectUri.Reporting.Plugins.Plugin.xUri );
|
||||
for ( ModelContainer pluginContainer : source.queryFor( ProjectUri.Build.Plugins.Plugin.xUri ) )
|
||||
{
|
||||
ModelContainer transformedReportContainer = new ArtifactModelContainerFactory().create(
|
||||
transformPlugin( pluginContainer.getProperties() ) );
|
||||
|
||||
for(ModelContainer reportContainer : reportContainers) {
|
||||
ModelContainerAction action = transformedReportContainer.containerAction( reportContainer );
|
||||
if ( action.equals( ModelContainerAction.JOIN ) )
|
||||
{
|
||||
source.join( transformedReportContainer, reportContainer );
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
modelProperties = source.getModelProperties();
|
||||
return modelProperties;
|
||||
}
|
||||
|
||||
|
@ -749,7 +773,7 @@ public final class PomClassicTransformer
|
|||
return transformedProperties;
|
||||
}
|
||||
|
||||
public static List<ModelProperty> transformPluginManagement( List<ModelProperty> modelProperties )
|
||||
private static List<ModelProperty> transformPluginManagement( List<ModelProperty> modelProperties )
|
||||
{
|
||||
List<ModelProperty> transformedProperties = new ArrayList<ModelProperty>();
|
||||
for ( ModelProperty mp : modelProperties )
|
||||
|
@ -763,5 +787,27 @@ public final class PomClassicTransformer
|
|||
}
|
||||
return transformedProperties;
|
||||
}
|
||||
|
||||
private static List<ModelProperty> transformPlugin( List<ModelProperty> modelProperties )
|
||||
{
|
||||
List<ModelProperty> transformedProperties = new ArrayList<ModelProperty>();
|
||||
for ( ModelProperty mp : modelProperties )
|
||||
{
|
||||
if ( mp.getUri().startsWith( ProjectUri.Build.Plugins.xUri ) )
|
||||
{ if(mp.getUri().startsWith(ProjectUri.Build.Plugins.Plugin.configuration)
|
||||
|| mp.getUri().equals( ProjectUri.Build.Plugins.Plugin.groupId)
|
||||
|| mp.getUri().equals( ProjectUri.Build.Plugins.Plugin.artifactId)
|
||||
|| mp.getUri().equals( ProjectUri.Build.Plugins.Plugin.version)
|
||||
|| mp.getUri().equals( ProjectUri.Build.Plugins.Plugin.xUri ) )
|
||||
{
|
||||
transformedProperties.add( new ModelProperty(
|
||||
mp.getUri().replace( ProjectUri.Build.Plugins.xUri, ProjectUri.Reporting.Plugins.xUri ),
|
||||
mp.getResolvedValue() ) );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return transformedProperties;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1506,7 +1506,7 @@ public class ProjectUri
|
|||
"http://apache.org/maven/project/reporting/plugins#collection/plugin/inherited";
|
||||
|
||||
public static String configuration =
|
||||
"http://apache.org/maven/project/reporting/plugins#collection/plugin/configuration";
|
||||
"http://apache.org/maven/project/reporting/plugins#collection/plugin/configuration#set";
|
||||
|
||||
public static class ReportSets
|
||||
{
|
||||
|
|
|
@ -27,7 +27,6 @@ import java.util.List;
|
|||
*/
|
||||
public interface ModelDataSource
|
||||
{
|
||||
|
||||
/**
|
||||
* Join model properties of the specified container a with the specified container b. Any elements of model container
|
||||
* a must take precedence over model container b. All elements of model container A must exist in the data source;
|
||||
|
|
|
@ -124,6 +124,9 @@ public final class DefaultModelDataSource
|
|||
if(startIndex == -1)
|
||||
{
|
||||
startIndex = modelProperties.indexOf( a.getProperties().get( 0 ) );
|
||||
if(startIndex == -1) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
delete( a );
|
||||
delete( b );
|
||||
|
|
Loading…
Reference in New Issue