portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject svn commit: r776725 - /portals/jetspeed-2/portal/trunk/maven/jetspeed-mvn-maven-plugin/src/main/java/org/apache/jetspeed/maven/plugins/MvnMojo.java
Date Wed, 20 May 2009 15:07:30 GMT
Author: ate
Date: Wed May 20 15:07:29 2009
New Revision: 776725

URL: http://svn.apache.org/viewvc?rev=776725&view=rev
Log:
JS2-877: Document new maven-2 build system
Providing runtime display of available targets for jetspeed:mvn by adding an additional parameter:
-Dlist
The presented list is ordered on dependency, e.g. depended targets are listed first, and then
on number of dependencies.
Example output from running mvn jetspeed:mvn -Dlist on root Jetspeed pom.xml:

Available jetspeed:mvn targets:
  testdb             [testdb]
  test               [test]
  proddb             [proddb]
  demo-install       [demo-install]
  demo-seed          [demo-seed]
  min-seed           [min-seed]
  demo-deploy        [demo-deploy]
  demo-deploy-min    [demo-deploy-min]
  demo-deploy-dbpsml [demo-deploy-dbpsml]
  test-install       [testdb, test-install]
  demo-seed-dbpsml   [proddb, demo-seed, demo-db, demo-seed-dbpsml]
  min-seed-dbpsml    [proddb, demo-seed, demo-db, min-seed-dbpsml]
  demo-db            [proddb, demo-seed, demo-db]
  min-db             [proddb, min-seed, min-db]
  demo-db-psml       [proddb, demo-seed, demo-db, demo-seed-dbpsml, demo-db-psml]
  demo               [demo-install, proddb, demo-seed, demo-db, demo-deploy, demo]
  min                [demo-install, proddb, demo-seed, demo-db, demo-deploy-min, min]
  min-dbpsml         [demo-install, proddb, demo-seed, demo-db, demo-deploy-min, demo-deploy-dbpsml,
min-seed-dbpsml, min-dbpsml]
  demo-dbpsml        [proddb, demo-seed, demo-db, demo-seed-dbpsml, demo-db-psml, demo-deploy,
demo-deploy-dbpsml, demo-dbpsml]

Modified:
    portals/jetspeed-2/portal/trunk/maven/jetspeed-mvn-maven-plugin/src/main/java/org/apache/jetspeed/maven/plugins/MvnMojo.java

Modified: portals/jetspeed-2/portal/trunk/maven/jetspeed-mvn-maven-plugin/src/main/java/org/apache/jetspeed/maven/plugins/MvnMojo.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/maven/jetspeed-mvn-maven-plugin/src/main/java/org/apache/jetspeed/maven/plugins/MvnMojo.java?rev=776725&r1=776724&r2=776725&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/maven/jetspeed-mvn-maven-plugin/src/main/java/org/apache/jetspeed/maven/plugins/MvnMojo.java
(original)
+++ portals/jetspeed-2/portal/trunk/maven/jetspeed-mvn-maven-plugin/src/main/java/org/apache/jetspeed/maven/plugins/MvnMojo.java
Wed May 20 15:07:29 2009
@@ -23,6 +23,8 @@
 import java.io.Writer;
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Collections;
+import java.util.Comparator;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
@@ -62,6 +64,42 @@
  */
 public class MvnMojo extends AbstractMojo
 {
+    private static final Comparator<List<Target>> targetListComparator = new
Comparator<List<Target>>()
+    {
+        public int compare(List<Target> o1, List<Target> o2)
+        {
+            for (Target t1 : o1)
+            {
+                for (Target t2 : o2)
+                {
+                    if (t1.id == t2.id)
+                    {
+                        return -1;
+                    }
+                }
+            }
+            for (Target t2 : o2)
+            {
+                for (Target t1 : o1)
+                {
+                    if (t1.id == t2.id)
+                    {
+                        return 1;
+                    }
+                }
+            }
+            if (o1.size() == o2.size())
+            {
+                return 0;
+            }
+            else if (o1.size() < o2.size())
+            {
+                return -1;
+            }
+            return 1;
+        }
+    };
+    
     public static class Target
     {
         public Target()
@@ -119,6 +157,11 @@
     protected String target;
     
     /**
+     * @parameter expression="${list}"
+     */
+    protected String list;
+    
+    /**
      * @parameter
      */
     protected Target[] targets;
@@ -197,7 +240,6 @@
             
             for (Target t : targets)
             {
-                System.out.println("Processing target: "+t);
                 t.init();
                 if (t.id == null)
                 {
@@ -223,6 +265,51 @@
                 i++;
             }
         }
+        
+        if (list != null)
+        {
+            ArrayList<List<Target>> lists = new ArrayList<List<Target>>();
+            int maxLength = 0;
+            for (Target t : targets)
+            {
+                if (t.id.length() > maxLength)
+                {
+                    maxLength = t.id.length();
+                }
+                lists.add(resolveTargets(targetsMap, null, t.id));
+            }
+            Collections.sort(lists, targetListComparator);
+            
+            Target t;
+            StringBuffer buffer = new StringBuffer();
+            
+            System.out.println();
+            System.out.println("Available jetspeed:mvn targets:");
+            for (List<Target> targetsList : lists)
+            {
+                t = targetsList.get(targetsList.size()-1);
+                buffer.setLength(0);                
+                buffer.append("  "+t.id);
+                for (int i = t.id.length(); i < maxLength; i++)
+                {
+                    buffer.append(" ");
+                }
+                buffer.append(" [");
+                for (int i = 0, size = targetsList.size(); i < size; i++)
+                {
+                    buffer.append(targetsList.get(i).id);
+                    if (i <size-1)
+                    {
+                        buffer.append(", ");
+                    }
+                }
+                buffer.append("]");
+                System.out.println(buffer.toString());
+            }
+            System.out.println();
+            return;
+        }
+        
         String targetId = target;
         if (StringUtils.isEmpty(targetId) || targetId.equals("true"))
         {



---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org


Mime
View raw message