maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bentm...@apache.org
Subject svn commit: r719921 - /maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/builder/PomClassicTransformer.java
Date Sat, 22 Nov 2008 21:18:23 GMT
Author: bentmann
Date: Sat Nov 22 13:18:23 2008
New Revision: 719921

URL: http://svn.apache.org/viewvc?rev=719921&view=rev
Log:
[MNG-3843] Main/test resources are not properly inherited

Modified:
    maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/builder/PomClassicTransformer.java

Modified: maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/builder/PomClassicTransformer.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/builder/PomClassicTransformer.java?rev=719921&r1=719920&r2=719921&view=diff
==============================================================================
--- maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/builder/PomClassicTransformer.java
(original)
+++ maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/builder/PomClassicTransformer.java
Sat Nov 22 13:18:23 2008
@@ -203,9 +203,17 @@
         boolean containsBuildResources = false;
         boolean containsTestResources = false;
         boolean containsPluginRepositories = false;
+        boolean containsLicenses = false;
+        boolean containsDevelopers = false;
+        boolean containsContributors = false;
+        boolean containsMailingLists = false;
+
+        int domainModelIndex = -1;
 
         for ( DomainModel domainModel : domainModels )
         {
+            domainModelIndex++;
+
             if ( !( domainModel instanceof PomClassicDomainModel ) )
             {
                 throw new IllegalArgumentException( "domainModels: Invalid domain model"
);
@@ -235,7 +243,7 @@
             }
 
             //Modules Not Inherited Rule
-            if ( domainModels.indexOf( domainModel ) != 0 )
+            if ( domainModelIndex > 0 )
             {
                 ModelProperty modulesProperty = getPropertyFor( ProjectUri.Modules.xUri,
tmp );
                 if ( modulesProperty != null )
@@ -257,7 +265,7 @@
             }
 
             //Not inherited plugin execution rule
-            if ( domainModels.indexOf( domainModel ) > 0 )
+            if ( domainModelIndex > 0 )
             {
                 List<ModelProperty> removeProperties = new ArrayList<ModelProperty>();
                 ModelDataSource source = new DefaultModelDataSource();
@@ -287,7 +295,7 @@
                 tmp.removeAll( removeProperties );
             }
             //Not inherited plugin rule
-            if ( domainModels.indexOf( domainModel ) > 0 )
+            if ( domainModelIndex > 0 )
             {
                 List<ModelProperty> removeProperties = new ArrayList<ModelProperty>();
                 ModelDataSource source = new DefaultModelDataSource();
@@ -327,63 +335,56 @@
             // SCM Developer Rule
             adjustUrl( scmDeveloperUrl, tmp, ProjectUri.Scm.developerConnection, projectNames
);
 
-            //Project Name Inheritance Rule
-            //Packaging Inheritance Rule
-            //Profiles not inherited rule
-            //parent.relativePath not inherited rule
-            for ( ModelProperty mp : tmp )
+            // Project Name Rule: not inherited
+            // Packaging Rule: not inherited
+            // Profiles Rule: not inherited
+            // Parent.relativePath Rule: not inherited
+            // Prerequisites Rule: not inherited
+            // DistributionManagent.Relocation Rule: not inherited
+            if ( domainModelIndex > 0 )
             {
-                String uri = mp.getUri();
-                if ( domainModels.indexOf( domainModel ) > 0 && ( uri.equals(
ProjectUri.name ) ||
-                    uri.equals( ProjectUri.packaging ) || uri.startsWith( ProjectUri.Profiles.xUri
) )
-                        || uri.startsWith( ProjectUri.Parent.relativePath ))
+                for ( ModelProperty mp : tmp )
                 {
-                    clearedProperties.add( mp );
+                    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
-            //Build Resources Inheritence Rule
-            //Build Test Resources Inheritance Rule
-            //Only inherit IF: the above is contained in super pom (domainModels.size() -1)
&& the child doesn't has it's own respective field
-            if ( domainModels.indexOf( domainModel ) == 0 )
-            {
-                containsBuildResources = hasProjectUri( ProjectUri.Build.Resources.xUri,
tmp );
-                containsTestResources = hasProjectUri( ProjectUri.Build.TestResources.xUri,
tmp );
-                containsPluginRepositories = hasProjectUri( ProjectUri.PluginRepositories.xUri,
tmp );
-            }
+            // 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 )
             {
-                if ( domainModels.indexOf( domainModel ) > 0 )
+                String uri = mp.getUri();
+                if ( ( containsBuildResources && uri.startsWith( ProjectUri.Build.Resources.xUri
) )
+                    || ( containsTestResources && uri.startsWith( ProjectUri.Build.TestResources.xUri
) )
+                    || ( 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
) ) )
                 {
-                    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 );
-                        }
-                    }
+                    clearedProperties.add( mp );
                 }
             }
+            containsBuildResources |= hasProjectUri( ProjectUri.Build.Resources.xUri, tmp
);
+            containsTestResources |= hasProjectUri( ProjectUri.Build.TestResources.xUri,
tmp );
+            containsPluginRepositories |= hasProjectUri( ProjectUri.PluginRepositories.xUri,
tmp );
+            containsLicenses |= hasProjectUri( ProjectUri.Licenses.xUri, tmp );
+            containsDevelopers |= hasProjectUri( ProjectUri.Developers.xUri, tmp );
+            containsContributors |= hasProjectUri( ProjectUri.Contributors.xUri, tmp );
+            containsMailingLists |= hasProjectUri( ProjectUri.MailingLists.xUri, tmp );
 
             ModelProperty artifactId = getPropertyFor( ProjectUri.artifactId, tmp );
             if ( artifactId != null )



Mime
View raw message