continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From eveni...@apache.org
Subject svn commit: r584884 - in /maven/continuum/trunk/continuum-core/src: main/java/org/apache/maven/continuum/ main/java/org/apache/maven/continuum/execution/maven/m2/ main/java/org/apache/maven/continuum/utils/ test/java/org/apache/maven/continuum/utils/
Date Mon, 15 Oct 2007 20:06:17 GMT
Author: evenisse
Date: Mon Oct 15 13:06:16 2007
New Revision: 584884

URL: http://svn.apache.org/viewvc?rev=584884&view=rev
Log:
Add plugins, reports plugins and extensions as continuum dependencies to resolve correctly
the projects build order

Modified:
    maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
    maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m2/DefaultMavenBuilderHelper.java
    maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/utils/ProjectSorter.java
    maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/utils/ProjectSorterTest.java

Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java?rev=584884&r1=584883&r2=584884&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
(original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
Mon Oct 15 13:06:16 2007
@@ -1324,7 +1324,7 @@
             return new ArrayList<Project>();
         }
 
-        return ProjectSorter.getSortedProjects( projects );
+        return ProjectSorter.getSortedProjects( projects, getLogger() );
     }
 
     // ----------------------------------------------------------------------

Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m2/DefaultMavenBuilderHelper.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m2/DefaultMavenBuilderHelper.java?rev=584884&r1=584883&r2=584884&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m2/DefaultMavenBuilderHelper.java
(original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m2/DefaultMavenBuilderHelper.java
Mon Oct 15 13:06:16 2007
@@ -31,9 +31,12 @@
 import org.apache.maven.continuum.project.builder.ContinuumProjectBuildingResult;
 import org.apache.maven.model.Dependency;
 import org.apache.maven.model.Developer;
+import org.apache.maven.model.Extension;
 import org.apache.maven.model.Model;
 import org.apache.maven.model.Notifier;
+import org.apache.maven.model.Plugin;
 import org.apache.maven.model.Profile;
+import org.apache.maven.model.ReportPlugin;
 import org.apache.maven.model.Scm;
 import org.apache.maven.model.io.xpp3.MavenXpp3Writer;
 import org.apache.maven.profiles.DefaultProfileManager;
@@ -260,6 +263,51 @@
         for ( Iterator i = mavenProject.getDependencies().iterator(); i.hasNext(); )
         {
             Dependency dependency = (Dependency) i.next();
+
+            ProjectDependency cd = new ProjectDependency();
+
+            cd.setGroupId( dependency.getGroupId() );
+
+            cd.setArtifactId( dependency.getArtifactId() );
+
+            cd.setVersion( dependency.getVersion() );
+
+            dependencies.add( cd );
+        }
+
+        for ( Iterator i = mavenProject.getBuildPlugins().iterator(); i.hasNext(); )
+        {
+            Plugin dependency = (Plugin) i.next();
+
+            ProjectDependency cd = new ProjectDependency();
+
+            cd.setGroupId( dependency.getGroupId() );
+
+            cd.setArtifactId( dependency.getArtifactId() );
+
+            cd.setVersion( dependency.getVersion() );
+
+            dependencies.add( cd );
+        }
+
+        for ( Iterator i = mavenProject.getReportPlugins().iterator(); i.hasNext(); )
+        {
+            ReportPlugin dependency = (ReportPlugin) i.next();
+
+            ProjectDependency cd = new ProjectDependency();
+
+            cd.setGroupId( dependency.getGroupId() );
+
+            cd.setArtifactId( dependency.getArtifactId() );
+
+            cd.setVersion( dependency.getVersion() );
+
+            dependencies.add( cd );
+        }
+
+        for ( Iterator i = mavenProject.getBuildExtensions().iterator(); i.hasNext(); )
+        {
+            Extension dependency = (Extension) i.next();
 
             ProjectDependency cd = new ProjectDependency();
 

Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/utils/ProjectSorter.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/utils/ProjectSorter.java?rev=584884&r1=584883&r2=584884&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/utils/ProjectSorter.java
(original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/utils/ProjectSorter.java
Mon Oct 15 13:06:16 2007
@@ -21,6 +21,7 @@
 
 import org.apache.maven.continuum.model.project.Project;
 import org.apache.maven.continuum.model.project.ProjectDependency;
+import org.codehaus.plexus.logging.Logger;
 import org.codehaus.plexus.util.dag.CycleDetectedException;
 import org.codehaus.plexus.util.dag.DAG;
 import org.codehaus.plexus.util.dag.TopologicalSorter;
@@ -55,7 +56,7 @@
      * <li>do a topo sort on the graph that remains.</li>
      * </ul>
      */
-    public static List<Project> getSortedProjects( Collection<Project> projects
)
+    public static List<Project> getSortedProjects( Collection<Project> projects,
Logger logger )
         throws CycleDetectedException
     {
         DAG dag = new DAG();
@@ -66,6 +67,11 @@
         {
             String id = getProjectId( project );
 
+            if ( dag.getVertex( id ) != null )
+            {
+                logger.warn( "Project '" + id + "' is duplicated in the reactor" );
+            }
+
             dag.addVertex( id );
 
             projectMap.put( id, project );
@@ -75,12 +81,12 @@
         {
             String id = getProjectId( project );
 
-            // Parent
-            ProjectDependency parent = project.getParent();
-
-            if ( parent != null )
+            // Dependencies
+            for ( Object o : project.getDependencies() )
             {
-                String dependencyId = getDependencyId( parent );
+                ProjectDependency dependency = (ProjectDependency) o;
+
+                String dependencyId = getDependencyId( dependency );
 
                 if ( dag.getVertex( dependencyId ) != null )
                 {
@@ -88,16 +94,21 @@
                 }
             }
 
-            // Dependencies
-            for ( Object o : project.getDependencies() )
-            {
-                ProjectDependency dependency = (ProjectDependency) o;
+            // Parent
+            ProjectDependency parent = project.getParent();
 
-                String dependencyId = getDependencyId( dependency );
+            if ( parent != null )
+            {
+                String parentId = getDependencyId( parent );
 
-                if ( dag.getVertex( dependencyId ) != null )
+                if ( dag.getVertex( parentId ) != null )
                 {
-                    dag.addEdge( id, dependencyId );
+                    // Parent is added as an edge, but must not cause a cycle - so we remove
any other edges it has in conflict
+                    if ( dag.hasEdge( parentId, id ) )
+                    {
+                        dag.removeEdge( parentId, id );
+                    }
+                    dag.addEdge( id, parentId );
                 }
             }
         }

Modified: maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/utils/ProjectSorterTest.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/utils/ProjectSorterTest.java?rev=584884&r1=584883&r2=584884&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/utils/ProjectSorterTest.java
(original)
+++ maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/utils/ProjectSorterTest.java
Mon Oct 15 13:06:16 2007
@@ -57,7 +57,7 @@
         c2.setDependencies( Collections.singletonList( generateProjectDependency( c1 ) )
);
         list.add( c2 );
 
-        List sortedList = ProjectSorter.getSortedProjects( list );
+        List sortedList = ProjectSorter.getSortedProjects( list, null );
 
         assertNotNull( sortedList );
 
@@ -92,7 +92,7 @@
         c2.setDependencies( Collections.singletonList( generateProjectDependency( c1 ) )
);
         list.add( c2 );
 
-        List sortedList = ProjectSorter.getSortedProjects( list );
+        List sortedList = ProjectSorter.getSortedProjects( list, null );
 
         assertNotNull( sortedList );
 



Mime
View raw message