[MNG-3843] Main/test resources are not properly inherited

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@719921 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Benjamin Bentmann 2008-11-22 21:18:23 +00:00
parent 0ffab5354e
commit 83440b7c01
1 changed files with 54 additions and 53 deletions

View File

@ -203,9 +203,17 @@ public final class PomClassicTransformer
boolean containsBuildResources = false; boolean containsBuildResources = false;
boolean containsTestResources = false; boolean containsTestResources = false;
boolean containsPluginRepositories = false; boolean containsPluginRepositories = false;
boolean containsLicenses = false;
boolean containsDevelopers = false;
boolean containsContributors = false;
boolean containsMailingLists = false;
int domainModelIndex = -1;
for ( DomainModel domainModel : domainModels ) for ( DomainModel domainModel : domainModels )
{ {
domainModelIndex++;
if ( !( domainModel instanceof PomClassicDomainModel ) ) if ( !( domainModel instanceof PomClassicDomainModel ) )
{ {
throw new IllegalArgumentException( "domainModels: Invalid domain model" ); throw new IllegalArgumentException( "domainModels: Invalid domain model" );
@ -235,7 +243,7 @@ public final class PomClassicTransformer
} }
//Modules Not Inherited Rule //Modules Not Inherited Rule
if ( domainModels.indexOf( domainModel ) != 0 ) if ( domainModelIndex > 0 )
{ {
ModelProperty modulesProperty = getPropertyFor( ProjectUri.Modules.xUri, tmp ); ModelProperty modulesProperty = getPropertyFor( ProjectUri.Modules.xUri, tmp );
if ( modulesProperty != null ) if ( modulesProperty != null )
@ -257,7 +265,7 @@ public final class PomClassicTransformer
} }
//Not inherited plugin execution rule //Not inherited plugin execution rule
if ( domainModels.indexOf( domainModel ) > 0 ) if ( domainModelIndex > 0 )
{ {
List<ModelProperty> removeProperties = new ArrayList<ModelProperty>(); List<ModelProperty> removeProperties = new ArrayList<ModelProperty>();
ModelDataSource source = new DefaultModelDataSource(); ModelDataSource source = new DefaultModelDataSource();
@ -287,7 +295,7 @@ public final class PomClassicTransformer
tmp.removeAll( removeProperties ); tmp.removeAll( removeProperties );
} }
//Not inherited plugin rule //Not inherited plugin rule
if ( domainModels.indexOf( domainModel ) > 0 ) if ( domainModelIndex > 0 )
{ {
List<ModelProperty> removeProperties = new ArrayList<ModelProperty>(); List<ModelProperty> removeProperties = new ArrayList<ModelProperty>();
ModelDataSource source = new DefaultModelDataSource(); ModelDataSource source = new DefaultModelDataSource();
@ -327,63 +335,56 @@ public final class PomClassicTransformer
// SCM Developer Rule // SCM Developer Rule
adjustUrl( scmDeveloperUrl, tmp, ProjectUri.Scm.developerConnection, projectNames ); adjustUrl( scmDeveloperUrl, tmp, ProjectUri.Scm.developerConnection, projectNames );
//Project Name Inheritance Rule // Project Name Rule: not inherited
//Packaging Inheritance Rule // Packaging Rule: not inherited
//Profiles not inherited rule // Profiles Rule: not inherited
//parent.relativePath not inherited rule // Parent.relativePath Rule: not inherited
// Prerequisites Rule: not inherited
// DistributionManagent.Relocation Rule: not inherited
if ( domainModelIndex > 0 )
{
for ( ModelProperty mp : tmp )
{
String uri = mp.getUri();
if ( uri.equals( ProjectUri.name ) || uri.equals( ProjectUri.packaging )
|| uri.startsWith( ProjectUri.Profiles.xUri )
|| uri.startsWith( ProjectUri.Parent.relativePath )
|| uri.startsWith( ProjectUri.Prerequisites.xUri )
|| uri.startsWith( ProjectUri.DistributionManagement.Relocation.xUri ) )
{
clearedProperties.add( mp );
}
}
}
// Remove Plugin Repository Inheritance Rule
// License Rule: only inherited if not specified in child
// Developers Rule: only inherited if not specified in child
// Contributors Rule: only inherited if not specified in child
// Mailing Lists Rule: only inherited if not specified in child
// Build Resources Rule: only inherited if not specified in child
// Build Test Resources Rule: only inherited if not specified in child
for ( ModelProperty mp : tmp ) for ( ModelProperty mp : tmp )
{ {
String uri = mp.getUri(); String uri = mp.getUri();
if ( domainModels.indexOf( domainModel ) > 0 && ( uri.equals( ProjectUri.name ) || if ( ( containsBuildResources && uri.startsWith( ProjectUri.Build.Resources.xUri ) )
uri.equals( ProjectUri.packaging ) || uri.startsWith( ProjectUri.Profiles.xUri ) ) || ( containsTestResources && uri.startsWith( ProjectUri.Build.TestResources.xUri ) )
|| uri.startsWith( ProjectUri.Parent.relativePath )) || ( containsPluginRepositories && uri.startsWith( ProjectUri.PluginRepositories.xUri ) )
|| ( containsLicenses && uri.startsWith( ProjectUri.Licenses.xUri ) )
|| ( containsDevelopers && uri.startsWith( ProjectUri.Developers.xUri ) )
|| ( containsContributors && uri.startsWith( ProjectUri.Contributors.xUri ) )
|| ( containsMailingLists && uri.startsWith( ProjectUri.MailingLists.xUri ) ) )
{ {
clearedProperties.add( mp ); clearedProperties.add( mp );
} }
} }
containsBuildResources |= hasProjectUri( ProjectUri.Build.Resources.xUri, tmp );
//Remove Plugin Repository Inheritance Rule containsTestResources |= hasProjectUri( ProjectUri.Build.TestResources.xUri, tmp );
//Build Resources Inheritence Rule containsPluginRepositories |= hasProjectUri( ProjectUri.PluginRepositories.xUri, tmp );
//Build Test Resources Inheritance Rule containsLicenses |= hasProjectUri( ProjectUri.Licenses.xUri, tmp );
//Only inherit IF: the above is contained in super pom (domainModels.size() -1) && the child doesn't has it's own respective field containsDevelopers |= hasProjectUri( ProjectUri.Developers.xUri, tmp );
if ( domainModels.indexOf( domainModel ) == 0 ) containsContributors |= hasProjectUri( ProjectUri.Contributors.xUri, tmp );
{ containsMailingLists |= hasProjectUri( ProjectUri.MailingLists.xUri, tmp );
containsBuildResources = hasProjectUri( ProjectUri.Build.Resources.xUri, tmp );
containsTestResources = hasProjectUri( ProjectUri.Build.TestResources.xUri, tmp );
containsPluginRepositories = hasProjectUri( ProjectUri.PluginRepositories.xUri, tmp );
}
for ( ModelProperty mp : tmp )
{
if ( domainModels.indexOf( domainModel ) > 0 )
{
String uri = mp.getUri();
boolean isNotSuperPom = domainModels.indexOf( domainModel ) != ( domainModels.size() - 1 );
if ( isNotSuperPom )
{
if ( uri.startsWith( ProjectUri.Build.Resources.xUri ) ||
uri.startsWith( ProjectUri.Build.TestResources.xUri ) ||
uri.startsWith( ProjectUri.PluginRepositories.xUri ) )
{
clearedProperties.add( mp );
}
}
else
{
if ( containsBuildResources && uri.startsWith( ProjectUri.Build.Resources.xUri ) )
{
clearedProperties.add( mp );
}
else if ( containsTestResources && uri.startsWith( ProjectUri.Build.TestResources.xUri ) )
{
clearedProperties.add( mp );
}
else if ( containsPluginRepositories && uri.startsWith( ProjectUri.PluginRepositories.xUri ) )
{
clearedProperties.add( mp );
}
}
}
}
ModelProperty artifactId = getPropertyFor( ProjectUri.artifactId, tmp ); ModelProperty artifactId = getPropertyFor( ProjectUri.artifactId, tmp );
if ( artifactId != null ) if ( artifactId != null )