continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jvan...@apache.org
Subject svn commit: r218962 - in /maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum: execution/maven/m2/DefaultMavenBuilderHelper.java store/ModelloJPoxContinuumStore.java utils/ProjectSorter.java
Date Thu, 14 Jul 2005 01:51:20 GMT
Author: jvanzyl
Date: Wed Jul 13 18:51:19 2005
New Revision: 218962

URL: http://svn.apache.org/viewcvs?rev=218962&view=rev
Log:
o latest build id 
o adding ProjectSorter

Added:
    maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/utils/ProjectSorter.java
Modified:
    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/store/ModelloJPoxContinuumStore.java

Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m2/DefaultMavenBuilderHelper.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m2/DefaultMavenBuilderHelper.java?rev=218962&r1=218961&r2=218962&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
Wed Jul 13 18:51:19 2005
@@ -27,6 +27,7 @@
 import org.apache.maven.model.Notifier;
 import org.apache.maven.model.Repository;
 import org.apache.maven.model.Scm;
+import org.apache.maven.model.Dependency;
 import org.apache.maven.project.MavenProject;
 import org.apache.maven.project.MavenProjectBuilder;
 import org.apache.maven.settings.MavenSettingsBuilder;
@@ -134,7 +135,7 @@
         continuumProject.setTestOutputDirectory( DEFAULT_TEST_OUTPUT_DIRECTORY );
 
         // ----------------------------------------------------------------------
-        //
+        // Developers
         // ----------------------------------------------------------------------
 
         if ( mavenProject.getDevelopers() != null )
@@ -157,6 +158,24 @@
             }
 
             continuumProject.setDevelopers( developers );
+        }
+
+        // ----------------------------------------------------------------------
+        // Dependencies
+        // ----------------------------------------------------------------------
+
+        if ( mavenProject.getDependencies() != null )
+        {
+            List dependencies = new ArrayList();
+
+            for ( Iterator i = mavenProject.getDependencies().iterator(); i.hasNext(); )
+            {
+                Dependency d = (Dependency) i.next();
+
+                dependencies.add( d.getGroupId() + ":" + d.getArtifactId() );
+            }
+
+            continuumProject.setDependencies( dependencies );
         }
 
         // ----------------------------------------------------------------------

Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/store/ModelloJPoxContinuumStore.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/store/ModelloJPoxContinuumStore.java?rev=218962&r1=218961&r2=218962&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/store/ModelloJPoxContinuumStore.java
(original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/store/ModelloJPoxContinuumStore.java
Wed Jul 13 18:51:19 2005
@@ -320,7 +320,7 @@
 
             Object id = store.addContinuumBuild( build );
 
-            project.setLastBuildId( build.getId() );
+            project.setLatestBuildId( build.getId() );
 
             project.setBuildNumber( project.getBuildNumber() + 1 );
 
@@ -373,14 +373,14 @@
 
             ContinuumProject p = store.getContinuumProject( projectId, false );
 
-            if ( p.getLastBuildId() == null )
+            if ( p.getLatestBuildId() == null )
             {
                 store.commit();
 
                 return null;
             }
 
-            ContinuumBuild b = store.getContinuumBuild( p.getLastBuildId(), false );
+            ContinuumBuild b = store.getContinuumBuild( p.getLatestBuildId(), false );
 
             b = (ContinuumBuild) store.getThreadState().getPersistenceManager().detachCopy(
b );
 

Added: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/utils/ProjectSorter.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/utils/ProjectSorter.java?rev=218962&view=auto
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/utils/ProjectSorter.java
(added)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/utils/ProjectSorter.java
Wed Jul 13 18:51:19 2005
@@ -0,0 +1,93 @@
+/*
+ * Copyright (c) 2005 Your Corporation. All Rights Reserved.
+ */
+package org.apache.maven.continuum.utils;
+
+import org.apache.maven.model.Dependency;
+import org.apache.maven.continuum.project.ContinuumProject;
+import org.codehaus.plexus.util.dag.CycleDetectedException;
+import org.codehaus.plexus.util.dag.DAG;
+import org.codehaus.plexus.util.dag.TopologicalSorter;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Sort projects by dependencies.
+ *
+ * @author <a href="mailto:brett@apache.org">Brett Porter</a>
+ * @version $Id: ProjectSorter.java 164217 2005-04-22 11:01:33Z brett $
+ */
+public class ProjectSorter
+{
+    private ProjectSorter()
+    {
+        // no touchy...
+    }
+
+    /**
+     * Sort a list of projects.
+     * <ul>
+     * <li>collect all the vertices for the projects that we want to build.</li>
+     * <li>iterate through the deps of each project and if that dep is within
+     * the set of projects we want to build then add an edge, otherwise throw
+     * the edge away because that dependency is not within the set of projects
+     * we are trying to build. we assume a closed set.</li>
+     * <li>do a topo sort on the graph that remains.</li>
+     * </ul>
+     */
+    public static List getSortedProjects( List projects )
+        throws CycleDetectedException
+    {
+        DAG dag = new DAG();
+
+        Map projectMap = new HashMap();
+
+        for ( Iterator i = projects.iterator(); i.hasNext(); )
+        {
+            ContinuumProject project = (ContinuumProject) i.next();
+
+            String id = getProjectId( project );
+
+            dag.addVertex( id );
+
+            projectMap.put( id, project );
+        }
+
+        for ( Iterator i = projects.iterator(); i.hasNext(); )
+        {
+            ContinuumProject project = (ContinuumProject) i.next();
+
+            String id = getProjectId( project );
+
+            for ( Iterator j = project.getDependencies().iterator(); j.hasNext(); )
+            {
+                String dependencyId = (String) i.next();
+
+                if ( dag.getVertex( dependencyId ) != null )
+                {
+                    dag.addEdge( id, dependencyId );
+                }
+            }
+        }
+
+        List sortedProjects = new ArrayList();
+
+        for ( Iterator i = TopologicalSorter.sort( dag ).iterator(); i.hasNext(); )
+        {
+            String id = (String) i.next();
+
+            sortedProjects.add( projectMap.get( id ) );
+        }
+
+        return sortedProjects;
+    }
+
+    private static String getProjectId( ContinuumProject project )
+    {
+        return project.getGroupId() + ":" + project.getArtifactId();
+    }
+}



Mime
View raw message