avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: rev 36682 - in avalon/trunk/tools/magic/src/main/org/apache/avalon/tools: model tasks
Date Sun, 22 Aug 2004 01:44:26 GMT
Author: akarasulu
Date: Sat Aug 21 18:44:25 2004
New Revision: 36682

Modified:
   avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/MagicPath.java
   avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/BlockTask.java
   avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/GumpTask.java
Log:
NOTE: Checking in changes on behalf of Stephen McConnell

Commit changes:

 o Corrections to the x-path handling



Modified: avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/MagicPath.java
==============================================================================
--- avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/MagicPath.java	(original)
+++ avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/MagicPath.java	Sat Aug
21 18:44:25 2004
@@ -17,13 +17,19 @@
 
 package org.apache.avalon.tools.model;
 
+import java.io.File;
+
 import org.apache.tools.ant.BuildException;
 import org.apache.tools.ant.Project;
 import org.apache.tools.ant.types.Path;
 
 /**
  * An ant datatype that represent a typical ant path created using 
- * transitive magic dependencies.
+ * transitive magic dependencies.  If the path datatype declaration includes
+ * the 'key' attribute the result path will include the artifact identified
+ * by the key if the resource type is a jar together with all dependent 
+ * artifacts.  If the key attribute is not declared the path returned will 
+ * be composed of the dependent artifacts.
  *
  * @author <a href="mailto:dev@avalon.apache.org">Avalon Development Team</a>
  * @version $Revision: 1.2 $ $Date: 2004/03/17 10:30:09 $
@@ -34,27 +40,28 @@
     private Home m_home;
     private String m_key;
     private int m_mode = Policy.RUNTIME;
+    private boolean m_initialized = false;
 
    /**
     * Creation of a new path relative to a supplied project.
+    *
     * @param project the current ant project
     */ 
     public MagicPath( Project project )
     {
         super( project );
-        setup();
     }
 
    /**
     * Set the key identifying the magic resource that will be 
-    * used for path construction.  If not declared the kley defaults 
+    * used for path construction.  If not declared the key defaults 
     * to the key of the current project.
+    *
     * @param key the resource key
     */
     public void setKey( final String key )
     {
         m_key = key;
-        setup();
     }
 
    /**
@@ -65,6 +72,7 @@
     */
     public void setMode( final String mode )
     {
+        System.out.println( "#MODE:" + mode );
         if( "ANY".equalsIgnoreCase( mode ) )
         {
             m_mode = Policy.ANY;
@@ -88,36 +96,48 @@
               + "] - use ANY, BUILD, TEST or RUNTIME.";
             throw new BuildException( error );
         }
-        setup();
     }
 
     //------------------------------------------------------------
     // private
     //------------------------------------------------------------
 
+
+    public String[] list()
+    {
+        setup();
+        return super.list();
+    }
+
     private int getMode()
     {
         return m_mode;
     }
 
-    private Definition getReferenceDefinition()
+    private Resource getResource()
     {
         if( null != m_key )
         {
-            return getHome().getDefinition( m_key );
+            return getHome().getResource( m_key );
         }
         else
         {
-            return getHome().getDefinition( getKey() );
+            return getHome().getResource( getKey() );
         }
     }
 
     private void setup()
     {
+        if( m_initialized )
+        {
+            return;
+        }
+
         if( null == m_context )
         {
             m_context = Context.getContext( getProject() );
         }
+
         if( null == m_home ) 
         {
             Home home = (Home) getProject().getReference( Home.KEY );
@@ -133,9 +153,17 @@
             }
         }
 
-        Definition def = getReferenceDefinition();
+        Resource def = getResource();
         Path path = def.getPath( getProject(), getMode() );
+
+        if( null != m_key && "jar".equals( def.getInfo().getType() ) )
+        {
+            final File file = def.getArtifact( getProject() );
+            path.createPathElement().setLocation( file );
+        }
+
         super.add( path );
+        m_initialized = true;
     }
 
     private Context getContext()

Modified: avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/BlockTask.java
==============================================================================
--- avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/BlockTask.java	(original)
+++ avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/BlockTask.java	Sat Aug
21 18:44:25 2004
@@ -59,8 +59,10 @@
         private String m_classname;
         private String m_profile;
         private boolean m_context = false;
+        private boolean m_configured = false;
         private boolean m_parameters = false;
         private boolean m_dependencies = false;
+        private boolean m_activation = true;
         private ArrayList m_children = new ArrayList();
 
         public void setClass( final String classname )
@@ -68,11 +70,21 @@
             m_classname = classname;
         }
 
+        public void setActivation( final boolean flag )
+        {
+            m_activation = flag ;
+        }
+
         public void setProfile( final String profile )
         {
             m_profile = profile;
         }
 
+        public boolean getActivation()
+        {
+            return m_activation;
+        }
+
         public String getClassname()
         {
             return m_classname;
@@ -100,6 +112,23 @@
             }
         }
 
+        public Configuration createConfiguration()
+        {
+            if( !m_configured )
+            {
+                Configuration config = new Configuration();
+                m_children.add( config );
+                m_configured = true;
+                return config;
+            }
+            else
+            {
+                final String error = 
+                  "Configuration entry already set!";
+                throw new BuildException( error );
+            }
+        }
+
         public Parameters createParameters()
         {
             if( !m_parameters )
@@ -346,6 +375,21 @@
         }
     }
 
+    public static class Configuration
+    {
+        private File m_file;
+
+        public void setFile( final File file )
+        {
+            m_file = file;
+        }
+
+        public File getFile()
+        {
+            return m_file;
+        }
+    }
+
     private String m_target;
     private String m_container;
     private List m_content = new ArrayList();
@@ -527,6 +571,11 @@
             writer.write( " profile=\"" + component.getProfile() + "\"" );
         }
 
+        if( !component.getActivation() )
+        {
+            writer.write( " activation=\"false\" " );
+        }
+
         Object[] children = component.getChildren();
         if( children.length == 0 )
         {
@@ -550,10 +599,51 @@
                 {
                     writeParameters( pad + "  ", writer, (Parameters) child );
                 }
+                else if( child instanceof Configuration )
+                {
+                    writeConfiguration( pad + "  ", writer, (Configuration) child );
+                }
+                else
+                {
+                    final String error = 
+                      "Component declaration contains an unrecognized class: "
+                      + child.getClass().getName();
+                    throw new IllegalStateException( error );
+                }
             }
             writer.write( "\n" + pad + "</component>" );
         }
     }
+
+    private void writeConfiguration( final String pad, final Writer writer, final Configuration
config )
+        throws IOException
+    {
+        File file = config.getFile();
+        if( null == file )
+        {
+            final String error = 
+              "Missing file attribute in configuration declaration.";
+            throw new BuildException( error );
+        }
+        if( !file.exists() )
+        {
+            final String error = 
+              "Missing configuration file [" 
+              + file
+              + "] does not exist.";
+            throw new BuildException( error );
+        }
+        if( file.isDirectory() )
+        {
+            final String error = 
+              "Configuration file [" 
+              + file
+              + "] referes to a directory.";
+            throw new BuildException( error );
+        }
+        writer.write( "\n" + pad + "<configuration/>" ); 
+    }
+
 
     private void writeContext( final String pad, final Writer writer, final Context context
)
         throws IOException

Modified: avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/GumpTask.java
==============================================================================
--- avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/GumpTask.java	(original)
+++ avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/GumpTask.java	Sat Aug
21 18:44:25 2004
@@ -496,9 +496,12 @@
         writer.write( 
            "\n      <!-- for magic -->" );
         writer.write( 
+           "\n      <property name=\"build.sysclasspath\" value=\"last\"/> " );
+        writer.write( 
            "\n      <property name=\"magic.home\" reference=\"home\" project=\"magic\"/>"
);
         writer.write( 
            "\n      <property name=\"gump.signature\" value=\"@@DATE@@\"/>" );
+
 
         final Resource[] resources = getContributingResources( definition );
 

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


Mime
View raw message