avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mcconn...@apache.org
Subject svn commit: rev 22206 - in avalon/trunk/tools/magic/src/main/org/apache/avalon/tools: model tasks
Date Mon, 28 Jun 2004 01:29:00 GMT
Author: mcconnell
Date: Sun Jun 27 18:28:59 2004
New Revision: 22206

Modified:
   avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/Home.java
   avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/Magic.java
   avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/HomeTask.java
Log:
Tweaking of the href based remote index loading functionality including addition of a trap
to ensure we don't get into a recursive import.

Modified: avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/Home.java
==============================================================================
--- avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/Home.java	(original)
+++ avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/Home.java	Sun Jun 27 18:28:59
2004
@@ -19,6 +19,7 @@
 
 import org.apache.tools.ant.BuildException;
 import org.apache.tools.ant.BuildListener;
+import org.apache.tools.ant.Task;
 import org.apache.tools.ant.Project;
 import org.apache.tools.ant.taskdefs.Get;
 import org.apache.tools.ant.taskdefs.Property;
@@ -30,6 +31,7 @@
 import java.net.URL;
 import java.util.ArrayList;
 import java.util.Hashtable;
+import java.util.Date;
 
 /**
  *
@@ -42,6 +44,9 @@
     // static
     //-------------------------------------------------------------
 
+    public static final String BANNER = 
+      "------------------------------------------------------------------------";
+
     public static final String KEY = "project.home";
     public static final String HOME_KEY = "project.home";
     public static final String INDEX_KEY = "project.index";
@@ -53,17 +58,19 @@
 
     private final File m_index;
     private final Hashtable m_resources = new Hashtable();
+    private final ArrayList m_includes = new ArrayList();
     private final Magic m_system;
 
     //-------------------------------------------------------------
     // constructor
     //-------------------------------------------------------------
 
-    protected Home( final Project project, Magic system, File index )
+    protected Home( Project project, Magic system, File index )
     {
+        setProject( project );
+        project.log( "index: " + index );
         m_index = index;
         m_system = system;
-        setProject( project );
         buildList( index, false );
     }
 
@@ -218,17 +225,33 @@
                 final String path = element.getAttribute( "href" );
                 if(( null != path ) && ( !"".equals( path ) ))
                 {
-                    File index = createTempFile();
-                    index.deleteOnExit(); // safety harness in case we abort
-                    final URL url = createURL( path );
-                    final Get get = (Get) project.createTask( "get" );
-                    get.setSrc( url );
-                    get.setDest( index );
-                    get.setIgnoreErrors( false );
-                    get.setUseTimestamp( true );
-                    get.setVerbose( false );
-                    get.execute();
-                    buildList( index, true );
+                    if( !m_includes.contains( path ) )
+                    {
+                        File index = createTempFile();
+                        final URL url = createURL( path );
+                        final Get get = (Get) project.createTask( "get" );
+                        get.setSrc( url );
+                        get.setDest( index );
+                        get.setIgnoreErrors( false );
+                        get.setUseTimestamp( false );
+                        get.setVerbose( false );
+                        get.execute();
+
+                        m_includes.add( path );
+
+                        try
+                        {
+                            buildList( index, true );
+                        }
+                        catch( BuildException be )
+                        {
+                            final String error = 
+                              "Model error occured while processing import."
+                              + "\n" + path;
+                            getProject().log( error );
+                            throw be;
+                        }
+                    }
                 }
                 else
                 {
@@ -236,7 +259,11 @@
                     if(( null != filename ) && ( !"".equals( filename ) ))
                     {
                         final File index = Context.getFile( system, path );
-                        buildList( index, true );
+                        if( !m_includes.contains( index.toString() ) )
+                        {
+                            m_includes.add( index );
+                            buildList( index, true );
+                        }
                     }
                     else
                     {

Modified: avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/Magic.java
==============================================================================
--- avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/Magic.java	(original)
+++ avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/Magic.java	Sun Jun 27
18:28:59 2004
@@ -19,6 +19,7 @@
 
 import org.apache.tools.ant.BuildException;
 import org.apache.tools.ant.BuildListener;
+import org.apache.tools.ant.Task;
 import org.apache.tools.ant.Project;
 import org.apache.tools.ant.taskdefs.Property;
 import org.apache.tools.ant.taskdefs.optional.net.SetProxy;
@@ -142,11 +143,9 @@
             project.log( "  host: " + hosts[i], Project.MSG_VERBOSE ); 
         }
         project.log( 
-          "main cache: " + m_main.getCacheDirectory(), 
-          Project.MSG_VERBOSE );
+          "cache: " + m_main.getCacheDirectory(), Project.MSG_VERBOSE );
         project.log( 
-          "docs cache: " + m_docs.getCacheDirectory(), 
-          Project.MSG_VERBOSE );
+          "docs: " + m_docs.getCacheDirectory(), Project.MSG_VERBOSE );
     }
 
     //-------------------------------------------------------------

Modified: avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/HomeTask.java
==============================================================================
--- avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/HomeTask.java	(original)
+++ avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/HomeTask.java	Sun Jun
27 18:28:59 2004
@@ -51,7 +51,7 @@
 
         if( null != getProject().getReference( Home.KEY ) ) return;
 
-        Magic system = Magic.getSystem( project );
+        Magic system = Magic.getSystem( project );        
         Home home = system.getHome( project, m_path );
         File root = getHomeDirectory( home );
 

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


Mime
View raw message