avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nic...@apache.org
Subject svn commit: rev 20235 - in avalon/trunk/tools/magic: . engine/src/java/org/apache/merlin/magic
Date Sun, 23 May 2004 05:50:48 GMT
Author: niclas
Date: Sat May 22 22:50:48 2004
New Revision: 20235

Removed:
   avalon/trunk/tools/magic/build.bsh
Modified:
   avalon/trunk/tools/magic/build.sequence
   avalon/trunk/tools/magic/engine/src/java/org/apache/merlin/magic/Builder.java
   avalon/trunk/tools/magic/engine/src/java/org/apache/merlin/magic/Main.java
Log:
Added build.sequence support in the engine. First argument the directory, followed by a space/comma
separated list of methods to invoke, or no methods for 'sequencing' in that directory. Sequencing
is started from command-line with 'magic' without parameters.

Modified: avalon/trunk/tools/magic/build.sequence
==============================================================================
--- avalon/trunk/tools/magic/build.sequence	(original)
+++ avalon/trunk/tools/magic/build.sequence	Sat May 22 22:50:48 2004
@@ -1,6 +1,7 @@
 
-prepare
-xdoc
-artifact
-java
-jar
+prepare plugin.install
+xdoc plugin.install
+clean plugin.install
+artifact plugin.install
+java plugin.install
+jar plugin.install

Modified: avalon/trunk/tools/magic/engine/src/java/org/apache/merlin/magic/Builder.java
==============================================================================
--- avalon/trunk/tools/magic/engine/src/java/org/apache/merlin/magic/Builder.java	(original)
+++ avalon/trunk/tools/magic/engine/src/java/org/apache/merlin/magic/Builder.java	Sat May
22 22:50:48 2004
@@ -84,7 +84,10 @@
                 // plugin method
                 pluginname = methodname.substring( 0, pos );
                 plugin = sm.lookupPlugin( pluginname );
-                methodname = methodname.substring( pos + 1 );
+                if( pos + 1 >= methodname.length() )
+                    methodname = pluginname;
+                else
+                    methodname = methodname.substring( pos + 1 );
             }
             if( plugin != null )
             {

Modified: avalon/trunk/tools/magic/engine/src/java/org/apache/merlin/magic/Main.java
==============================================================================
--- avalon/trunk/tools/magic/engine/src/java/org/apache/merlin/magic/Main.java	(original)
+++ avalon/trunk/tools/magic/engine/src/java/org/apache/merlin/magic/Main.java	Sat May 22
22:50:48 2004
@@ -1,6 +1,12 @@
 package org.apache.merlin.magic;
 
+import java.io.BufferedReader;
 import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+
+import java.util.ArrayList;
+import java.util.StringTokenizer;
 
 public class Main
 {
@@ -12,19 +18,95 @@
         long t0 = System.currentTimeMillis();
         try
         {
-            m_Application = new Builder( args, getProjectDir() );
-            m_Application.execute();
+            File projectDir = getProjectDir();
+            process( args, projectDir );
         } finally
         {
             long t1 = System.currentTimeMillis();
             System.out.println( "Build Time: " + (t1 - t0) + " ms." );
         }
     }
-
+    
     static private File getProjectDir()
     {
         String cwd = System.getProperty( "user.dir" );
         File f = new File( cwd );
         return f.getAbsoluteFile();
+    }
+    
+    static private void process( String[] args, File dir )
+        throws Exception
+    {
+        if( args.length == 0 )
+        {
+            String[] jobs = sequence( dir );
+            for( int i = 0 ; i < jobs.length ; i++ )
+            {
+                doJob( jobs[i], dir );
+            }
+        }
+        else
+        {   
+            m_Application = new Builder( args, dir );
+            m_Application.execute();
+        }
+    }
+
+    static String[] sequence( File projDir )
+        throws Exception
+    {
+        File sequenceFile = new File( projDir, "build.sequence" );
+        if( ! sequenceFile.exists() )
+            return new String[0];
+        FileReader reader = null;
+        BufferedReader br = null;
+        
+        ArrayList result = new ArrayList();
+        try
+        {        
+            reader = new FileReader( sequenceFile );
+            br = new BufferedReader( reader );
+            String line;
+            while( (line = br.readLine() ) != null )
+            {
+                result.add( line.trim() );
+            }
+            String[] retVal = new String[ result.size() ];
+            result.toArray( retVal );
+            return retVal;
+        } finally
+        {
+            if( reader != null )
+                reader.close();
+            if( br != null )
+                br.close();
+        }
+    }
+    
+    static private void doJob( String descriptor, File dir )
+        throws Exception
+    {
+        // Check for empty line.
+        if( "".equals( descriptor ) )
+            return;
+            
+        StringTokenizer st = new StringTokenizer( descriptor, " ,", true );
+        
+        String subdir = st.nextToken();
+        ArrayList methods = new ArrayList();
+        
+        while( st.hasMoreTokens() )
+        {
+            String method = st.nextToken().trim();
+            if( ! "".equals( method ) )
+                methods.add( method );
+        }
+        String[] result = new String[ methods.size() ];
+        methods.toArray( result );
+        
+        // recurse the methods into main() having user.dir set to the
+        // requested dir.
+        File newProjectDir = new File( dir, subdir );
+        process( result, newProjectDir );
     }
 } 

---------------------------------------------------------------------
To unsubscribe, e-mail: cvs-unsubscribe@avalon.apache.org
For additional commands, e-mail: cvs-help@avalon.apache.org


Mime
View raw message