You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@avalon.apache.org by mc...@apache.org on 2004/06/26 06:03:23 UTC

svn commit: rev 22114 - in avalon/trunk: . central/system runtime/composition/impl/src/java/org/apache/avalon/composition/model/impl runtime/composition/impl/src/test/org/apache/avalon/composition/model/test runtime/merlin runtime/merlin/cli/src/test/org/apache/avalon/merlin/cli/test runtime/merlin/impl/etc/main runtime/merlin/impl/src/resources tools tools/magic tools/magic/etc/deliverables/properties tools/magic/src/main/org/apache/avalon/tools/model tools/magic/src/main/org/apache/avalon/tools/tasks

Author: mcconnell
Date: Fri Jun 25 21:03:22 2004
New Revision: 22114

Added:
   avalon/trunk/runtime/composition/impl/src/test/org/apache/avalon/composition/model/test/DynamicCreationTestCase.java
   avalon/trunk/runtime/merlin/build.properties   (contents, props changed)
   avalon/trunk/runtime/merlin/build.xml
   avalon/trunk/runtime/merlin/impl/etc/main/
      - copied from rev 22110, avalon/trunk/runtime/merlin/impl/src/resources/
Removed:
   avalon/trunk/runtime/merlin/impl/src/resources/
Modified:
   avalon/trunk/build.properties
   avalon/trunk/build.xml
   avalon/trunk/central/system/index.xml
   avalon/trunk/runtime/composition/impl/src/java/org/apache/avalon/composition/model/impl/DefaultComponentModel.java
   avalon/trunk/runtime/composition/impl/src/java/org/apache/avalon/composition/model/impl/DefaultContainmentModel.java
   avalon/trunk/runtime/composition/impl/src/java/org/apache/avalon/composition/model/impl/DefaultDeploymentModel.java
   avalon/trunk/runtime/composition/impl/src/test/org/apache/avalon/composition/model/test/DynamicsTestCase.java
   avalon/trunk/runtime/merlin/cli/src/test/org/apache/avalon/merlin/cli/test/MerlinCLITestCase.java
   avalon/trunk/tools/build.xml
   avalon/trunk/tools/magic/build.properties
   avalon/trunk/tools/magic/build.xml
   avalon/trunk/tools/magic/etc/deliverables/properties/magic.properties
   avalon/trunk/tools/magic/setup.xml
   avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/Definition.java
   avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/Home.java
   avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/Info.java
   avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/Magic.java
   avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/XMLDefinitionBuilder.java
   avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/ContextualTask.java
   avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/HomeTask.java
   avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/JavadocTask.java
Log:
1. Updates to magic - correcting a number of bugs that were the cause of the issues posted by Aaron and Tim.  In the process added support for magic.properties defintion of magic.cache and magic.docs so that we can easily map magic content generation into other repositories.  
2. Update to the composition impl to handle the making of a container as "dirty" if a component is added when the container is assembled - and from this, the ability to re-assemble the container without requireing dissassembly of existing models.  Updates include a testcase to validate the addition of a new component model (identified as an issue on users@avalon by Eike Stepper).
3. Fixed several bugs/issues in properties and layout - one in particular was the layout of the merlin-cli module which was causing a build failure due to incorect generation of artifact references.

Modified: avalon/trunk/build.properties
==============================================================================
--- avalon/trunk/build.properties	(original)
+++ avalon/trunk/build.properties	Fri Jun 25 21:03:22 2004
@@ -15,32 +15,14 @@
 #  named user.properties and adjust the values as needed
 #======================================================================
 
-
-# HTTP/FTP Proxy values
- 
-# magic.proxy.host = 127.0.0.l
-# magic.proxy.port = 80
-# magic.proxy.user = username
-# magic.proxy.password = password
-
-
 #======================================================================
-# Default System Settings
+# Default Module Settings
 # Settings below this line will generally not need to be edited
 #======================================================================
 
-
 # local index home
 project.home = central/system
 
-# Cache directory into which build artifacts are registered.
-# Value may be an absolute or relative filename. Relative 
-# filenames will be resolved relative to ${project.home}.
-
-#project.main.cache = .cache
-#project.docs.cache = .docs
-
-# A sequence of remote repositories used to resolve artifacts
-# requested as part of the build process.
-# project.hosts = ${dpml.net}/;${java.repo}/;${ibiblio.org}/maven/
-
+#
+# addition system wide setting are included in ${magic.home}/magic.properties
+#
\ No newline at end of file

Modified: avalon/trunk/build.xml
==============================================================================
--- avalon/trunk/build.xml	(original)
+++ avalon/trunk/build.xml	Fri Jun 25 21:03:22 2004
@@ -10,7 +10,7 @@
   <property file="${basedir}/build.properties"/>
 
   <property name="reactor.xml" 
-    value="${magic.dir}/etc/deliverables/templates/reactor.xml"/>
+    value="${project.home}/build/reactor.xml"/>
 
   <target name="setup">
     <ant dir="." antfile="${magic.dir}/setup.xml"/>
@@ -20,7 +20,9 @@
     <ant dir="." antfile="${reactor.xml}" target="clean"/>
   </target>
 
-  <target name="install" depends="verify">
+  <target name="install" depends="default"/>
+
+  <target name="default" depends="verify">
     <ant dir="." antfile="${reactor.xml}" target="default"/>
   </target>
 

Modified: avalon/trunk/central/system/index.xml
==============================================================================
--- avalon/trunk/central/system/index.xml	(original)
+++ avalon/trunk/central/system/index.xml	Fri Jun 25 21:03:22 2004
@@ -107,10 +107,10 @@
       <name>avalon-tools-magic</name>
     </info>
     <dependencies>
-      <include key="ant" runtime="true" build="false" test="false"/>
-      <include key="junit" runtime="true" build="false" test="false"/>
-      <include key="ant-junit" runtime="true" build="false" test="false"/>
-      <include key="ant-nodeps" runtime="true" build="false" test="false"/>
+      <include key="ant" build="false" test="false" runtime="true"/>
+      <include key="junit" build="false" test="false" runtime="true"/>
+      <include key="ant-junit" build="false" test="false" runtime="true"/>
+      <include key="ant-nodeps" build="false" test="false" runtime="true"/>
     </dependencies>
   </project>
 
@@ -156,6 +156,7 @@
       <group>avalon/framework</group>
       <name>avalon-framework-api</name>
       <version>4.2.1</version>
+      <status>SNAPSHOT</status> <!-- impact on derived versions ? -->
     </info>
   </project>
 
@@ -540,6 +541,7 @@
       <include key="avalon-repository-impl" test="false"/>
       <include key="avalon-repository-main"/>
       <include key="avalon-framework-impl" test="true"/>
+      <include key="avalon-repository-cli" build="false" test="false"/>
     </dependencies>
   </project>
 
@@ -668,7 +670,7 @@
       <include key="avalon-repository-main"/>
       <include key="avalon-logging-impl"/>
       <include key="avalon-framework-impl"/>
-      <include key="avalon-repository-test" build="false" test="false" runtime="false"/>
+      <include key="avalon-repository-test" build="false" test="false"/>
     </dependencies>
   </project>
 
@@ -707,6 +709,7 @@
       <group>avalon/composition</group>
       <name>avalon-composition-impl</name>
       <version>2.0.1</version>
+      <status>SNAPSHOT</status>
     </info>
     <dependencies>
       <include key="avalon-composition-spi"/>
@@ -716,9 +719,9 @@
       <include key="avalon-util-extension-impl"/>
       <include key="avalon-util-lifecycle"/>
       <include key="avalon-logging-impl" build="false" test="true"/>
-      <include key="avalon-test-dynamics" build="false" test="true" runtime="false"/>
-      <include key="avalon-test-includes" build="false" test="true" runtime="false"/>
-      <include key="avalon-logging-test" build="false" test="false" runtime="false"/>
+      <include key="avalon-test-dynamics" build="false" test="false"/>
+      <include key="avalon-test-includes" build="false" test="true"/>
+      <include key="avalon-logging-test" build="false" test="false"/>
     </dependencies>
   </project>
 
@@ -750,11 +753,10 @@
       <include key="avalon-repository-spi"/>
       <include key="avalon-composition-spi"/>
       <include key="avalon-activation-api"/>
-      <include key="avalon-framework-impl" build="true" test="true" runtime="true"/>
-      <include key="avalon-composition-impl" 
-         build="false" test="true" runtime="false"/>
-      <include key="avalon-test-components" build="false" test="true" runtime="false"/>
-      <include key="avalon-test-playground" build="false" test="true" runtime="false"/>
+      <include key="avalon-framework-impl"/>
+      <include key="avalon-composition-impl" build="false" test="true"/>
+      <include key="avalon-test-components" build="false" test="true"/>
+      <include key="avalon-test-playground" build="false" test="true"/>
     </dependencies>
   </project>
 
@@ -777,7 +779,8 @@
     <info>
       <group>avalon/merlin</group>
       <name>avalon-merlin-impl</name>
-      <version>3.3.0</version>
+      <version>3.3.1</version>
+      <status>SNAPSHOT</status>
     </info>
     <dependencies>
       <include key="avalon-framework-api" tag="api"/>
@@ -788,11 +791,12 @@
       <include key="avalon-meta-spi" tag="spi"/>
       <include key="avalon-repository-spi" tag="spi"/>
       <include key="avalon-logging-spi" tag="spi"/>
+      <include key="avalon-logging-impl" tag="impl"/>
       <include key="avalon-composition-spi" tag="spi"/>
       <include key="avalon-composition-impl" tag="impl"/>
       <include key="avalon-util-configuration" tag="impl"/>
       <include key="avalon-repository-main" runtime="false"/>
-      <include key="avalon-activation-impl" build="false" test="false" runtime="false"/>
+      <include key="avalon-activation-impl" build="false" test="false"/>
     </dependencies>
   </project>
 
@@ -800,10 +804,11 @@
     <info>
       <group>avalon/merlin</group>
       <name>avalon-merlin-cli</name>
-      <version>3.3.0</version>
+      <version>3.3.1</version>
+      <status>SNAPSHOT</status>
     </info>
     <dependencies>
-      <include key="avalon-merlin-impl" build="false" test="false" runtime="false"/>
+      <include key="avalon-merlin-impl" build="false" test="false"/>
       <include key="avalon-repository-main"/>
       <include key="commons-cli"/>
     </dependencies>
@@ -813,7 +818,8 @@
     <info>
       <group>avalon</group>
       <name>runtime</name>
-      <version>3.3.0</version>
+      <version>3.3.1</version>
+      <status>SNAPSHOT</status>
     </info>
     <dependencies>
       <include key="avalon-framework-api" tag="api"/>
@@ -828,7 +834,7 @@
       <include key="avalon-composition-impl" tag="impl"/>
       <include key="avalon-util-configuration" tag="impl"/>
       <include key="avalon-repository-main" runtime="false"/>
-      <include key="avalon-activation-impl" build="false" test="false" runtime="false"/>
+      <include key="avalon-activation-impl" build="false" test="false"/>
       <include key="avalon-merlin-api" tag="spi"/>
       <include key="avalon-merlin-impl"/>
       <include key="avalon-merlin-cli"/>
@@ -844,7 +850,7 @@
     </info>
     <dependencies>
       <include key="avalon-repository-main"/>
-      <include key="avalon-merlin-impl" build="false" test="false" runtime="false"/>
+      <include key="avalon-merlin-impl" build="false" test="false"/>
     </dependencies>
   </project>
 
@@ -856,7 +862,7 @@
     </info>
     <dependencies>
       <include key="avalon-repository-main"/>
-      <include key="avalon-merlin-impl" build="false" test="false" runtime="false"/>
+      <include key="avalon-merlin-impl" build="false" test="false"/>
     </dependencies>
   </project>
 

Modified: avalon/trunk/runtime/composition/impl/src/java/org/apache/avalon/composition/model/impl/DefaultComponentModel.java
==============================================================================
--- avalon/trunk/runtime/composition/impl/src/java/org/apache/avalon/composition/model/impl/DefaultComponentModel.java	(original)
+++ avalon/trunk/runtime/composition/impl/src/java/org/apache/avalon/composition/model/impl/DefaultComponentModel.java	Fri Jun 25 21:03:22 2004
@@ -247,11 +247,35 @@
                 return false;
             }
         }
-    }
+    }
 
-    //--------------------------------------------------------------
-    // Composite
-    //--------------------------------------------------------------
+    //--------------------------------------------------------------
+    // Commissionable
+    //--------------------------------------------------------------
+
+   /**
+    * Commission the model. 
+    *
+    * @exception Exception if a commissioning error occurs
+    */
+    public void commission() throws Exception
+    {
+        if( isAssembled() )
+        {
+            super.commission();
+        }
+        else
+        {
+            final String error = 
+              "Illegal attempt to commission a non-assembled component model: "
+              + this;
+            throw new ModelException( error );
+        }
+    }
+
+    //--------------------------------------------------------------
+    // Composite
+    //--------------------------------------------------------------
 
     /**
      * Returns the assembled state of the model.

Modified: avalon/trunk/runtime/composition/impl/src/java/org/apache/avalon/composition/model/impl/DefaultContainmentModel.java
==============================================================================
--- avalon/trunk/runtime/composition/impl/src/java/org/apache/avalon/composition/model/impl/DefaultContainmentModel.java	(original)
+++ avalon/trunk/runtime/composition/impl/src/java/org/apache/avalon/composition/model/impl/DefaultContainmentModel.java	Fri Jun 25 21:03:22 2004
@@ -134,6 +134,8 @@
 
     private final DefaultState m_commissioned = new DefaultState();
 
+    private final DefaultState m_dirty = new DefaultState();
+
     //--------------------------------------------------------------
     // state
     //--------------------------------------------------------------
@@ -202,7 +204,7 @@
     */
     public void commission() throws Exception
     {
-        if( !isAssembled() ) assemble();
+        assemble();
 
         synchronized( m_commissioned )
         {
@@ -395,7 +397,7 @@
         {
             if( isAssembled() )
             {
-                return;
+                if( !m_dirty.isEnabled() ) return;
             }
 
             getLogger().debug( "assembly phase" );
@@ -409,8 +411,8 @@
                 DeploymentModel model = models[i];
                 helper.assembleModel( model, subjects );
             }
-
-            m_assembly.setEnabled( true );
+            m_assembly.setEnabled( true );
+            m_dirty.setEnabled( false );
         }
     }
 
@@ -832,15 +834,20 @@
       String name, DeploymentModel model )
     {
         if( model.equals( this ) ) 
-            return model;
-        ModelRepository repository = m_context.getModelRepository();
-        synchronized( repository )
-        {
-            repository.addModel( name, model );
-            m_context.getDependencyGraph().add( model );
-            CompositionEvent event = new CompositionEvent( this, model );
-            fireModelAddedEvent( event );
-            return model;
+            return model;
+
+        synchronized( m_commissioned )
+        {
+            m_dirty.setEnabled( true );
+            ModelRepository repository = m_context.getModelRepository();
+            synchronized( repository )
+            {
+                repository.addModel( name, model );
+                m_context.getDependencyGraph().add( model );
+                CompositionEvent event = new CompositionEvent( this, model );
+                fireModelAddedEvent( event );
+                return model;
+            }
         }
     }
 

Modified: avalon/trunk/runtime/composition/impl/src/java/org/apache/avalon/composition/model/impl/DefaultDeploymentModel.java
==============================================================================
--- avalon/trunk/runtime/composition/impl/src/java/org/apache/avalon/composition/model/impl/DefaultDeploymentModel.java	(original)
+++ avalon/trunk/runtime/composition/impl/src/java/org/apache/avalon/composition/model/impl/DefaultDeploymentModel.java	Fri Jun 25 21:03:22 2004
@@ -118,7 +118,7 @@
     * @exception Exception if a commissioning error occurs
     */
     public void commission() throws Exception
-    {
+    {
         m_context.getSystemContext().commission( this );
     }
 

Added: avalon/trunk/runtime/composition/impl/src/test/org/apache/avalon/composition/model/test/DynamicCreationTestCase.java
==============================================================================
--- (empty file)
+++ avalon/trunk/runtime/composition/impl/src/test/org/apache/avalon/composition/model/test/DynamicCreationTestCase.java	Fri Jun 25 21:03:22 2004
@@ -0,0 +1,166 @@
+/* 
+ * Copyright 2004 Apache Software Foundation
+ * Licensed  under the  Apache License,  Version 2.0  (the "License");
+ * you may not use  this file  except in  compliance with the License.
+ * You may obtain a copy of the License at 
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed  under the  License is distributed on an "AS IS" BASIS,
+ * WITHOUT  WARRANTIES OR CONDITIONS  OF ANY KIND, either  express  or
+ * implied.
+ * 
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.avalon.composition.model.test;
+
+import org.apache.avalon.composition.data.ComponentProfile;
+import org.apache.avalon.composition.data.ContainmentProfile;
+import org.apache.avalon.composition.data.DeploymentProfile;
+import org.apache.avalon.composition.model.ModelException;
+import org.apache.avalon.composition.model.DeploymentModel;
+import org.apache.avalon.composition.model.ClassLoaderModel;
+import org.apache.avalon.composition.model.TypeRepository;
+import org.apache.avalon.composition.model.ComponentModel;
+import org.apache.avalon.composition.model.ContainmentModel;
+import org.apache.avalon.composition.model.DependencyModel;
+
+import org.apache.avalon.meta.info.Type;
+import org.apache.avalon.meta.info.ReferenceDescriptor;
+
+import org.apache.avalon.util.exception.ExceptionHelper;
+
+
+public class DynamicCreationTestCase extends AbstractTestCase
+{      
+    private static final String WIDGET = 
+      "org.apache.avalon.test.dynamics.Widget";
+
+    private static final String WIDGET_CLASS = 
+      "org.apache.avalon.test.dynamics.DefaultWidget";
+
+    private static final String GIZMO = 
+      "org.apache.avalon.test.dynamics.Gizmo";
+
+    private static final ContainmentProfile PROFILE = 
+      new ContainmentProfile();
+
+    private ContainmentModel m_container;
+
+   //-------------------------------------------------------
+   // constructor
+   //-------------------------------------------------------
+
+    public DynamicCreationTestCase()
+    {
+        super();
+    }
+
+    public void setUp() throws Exception
+    {
+        m_model = super.setUp( "dynamics.xml" );
+        m_container = (ContainmentModel) m_model.addModel( PROFILE );
+    }
+
+   //-------------------------------------------------------
+   // tests
+   //-------------------------------------------------------
+
+   /**
+    * Validate resolution of a widget.
+    */
+    public void testDynamicCreation() throws Exception
+    {
+        try
+        {
+            //
+            // ensure the container is already assembled
+            //
+
+            m_model.assemble();
+
+            //
+            // create and add a component to the assembled container
+            // causing the container to flag itself as dirty
+            //
+
+            ComponentProfile profile = getProfile();
+            ComponentModel widget = (ComponentModel) m_model.addModel( profile );
+            assertFalse( widget.isAssembled() );
+
+            try
+            {
+                widget.commission();
+            }
+            catch( ModelException me )
+            {
+                System.out.println( me.getMessage() );
+                // expected
+            }
+
+            //
+            // reassemble the container to bring it back into a clean state
+            //
+
+            m_model.assemble();
+            validate( widget );
+        }
+        catch( Throwable e )
+        {
+            final String message = "Dynamic creation test failure";
+            final String error = ExceptionHelper.packException( message, e, false );
+            System.err.println( error );
+            fail( error );
+        }
+    }
+
+    private ComponentProfile getProfile() throws Exception
+    {
+        ClassLoaderModel clm = m_model.getClassLoaderModel();
+        TypeRepository repository = clm.getTypeRepository();
+        Type type = repository.getType( WIDGET_CLASS );
+        DeploymentProfile[] profiles = repository.getProfiles( type );
+        if( profiles.length > 0 )
+        {
+            return (ComponentProfile) profiles[0];
+        }
+        throw new IllegalStateException( "no profile" );
+    }
+
+
+   /**
+    * Validate a model.
+    */
+    private void validate( ComponentModel model ) throws Exception
+    {
+        try
+        {
+            if( !model.isAssembled() )
+            {
+                fail( "Non-assembled model: " + model );
+            }
+
+            DependencyModel[] dependencies = model.getDependencyModels();
+            for( int i=0; i<dependencies.length; i++ )
+            {
+                DependencyModel dependency = dependencies[i];
+                if( null == dependency.getProvider() )
+                {
+                    fail( 
+                      "Null provider located in an assembled model: " 
+                      + model );
+                }
+            }
+        }
+        catch( Throwable e )
+        {
+            final String message = "Dynamic assembly validation failure";
+            final String error = ExceptionHelper.packException( message, e, true );
+            System.err.println( error );
+            fail( error );
+        }
+    }
+}

Modified: avalon/trunk/runtime/composition/impl/src/test/org/apache/avalon/composition/model/test/DynamicsTestCase.java
==============================================================================
--- avalon/trunk/runtime/composition/impl/src/test/org/apache/avalon/composition/model/test/DynamicsTestCase.java	(original)
+++ avalon/trunk/runtime/composition/impl/src/test/org/apache/avalon/composition/model/test/DynamicsTestCase.java	Fri Jun 25 21:03:22 2004
@@ -29,11 +29,16 @@
 
 import org.apache.avalon.util.exception.ExceptionHelper;
 
-import org.apache.avalon.test.dynamics.Widget;
-import org.apache.avalon.test.dynamics.Gizmo;
 
 public class DynamicsTestCase extends AbstractTestCase
-{      
+{      
+    private static final String WIDGET = 
+      "org.apache.avalon.test.dynamics.Widget";
+
+    private static final String GIZMO = 
+      "org.apache.avalon.test.dynamics.Gizmo";
+
+
    //-------------------------------------------------------
    // constructor
    //-------------------------------------------------------
@@ -59,8 +64,7 @@
     {
         try
         {
-            String spec = Widget.class.getName();
-            ReferenceDescriptor ref = new ReferenceDescriptor( spec );
+            ReferenceDescriptor ref = new ReferenceDescriptor( WIDGET );
             ComponentModel widget = (ComponentModel) m_model.getModel( ref );
             validate( widget );
         }
@@ -81,8 +85,7 @@
         try
         {
             m_model.assemble();
-            String spec = Gizmo.class.getName();
-            ReferenceDescriptor ref = new ReferenceDescriptor( spec );
+            ReferenceDescriptor ref = new ReferenceDescriptor( GIZMO );
             ComponentModel gizmo = (ComponentModel) m_model.getModel( ref );
             validate( gizmo );
         }

Added: avalon/trunk/runtime/merlin/build.properties
==============================================================================
--- (empty file)
+++ avalon/trunk/runtime/merlin/build.properties	Fri Jun 25 21:03:22 2004
@@ -0,0 +1 @@
+project.home = ../../central/system

Added: avalon/trunk/runtime/merlin/build.xml
==============================================================================
--- (empty file)
+++ avalon/trunk/runtime/merlin/build.xml	Fri Jun 25 21:03:22 2004
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<project name="merlin" default="install" basedir=".">
+
+  <property file="build.properties"/>
+  <import file="${project.home}/build/reactor.xml"/>
+
+</project>

Modified: avalon/trunk/runtime/merlin/cli/src/test/org/apache/avalon/merlin/cli/test/MerlinCLITestCase.java
==============================================================================
--- avalon/trunk/runtime/merlin/cli/src/test/org/apache/avalon/merlin/cli/test/MerlinCLITestCase.java	(original)
+++ avalon/trunk/runtime/merlin/cli/src/test/org/apache/avalon/merlin/cli/test/MerlinCLITestCase.java	Fri Jun 25 21:03:22 2004
@@ -73,9 +73,8 @@
         }
         catch( Throwable e )
         {
-            final String error = ExceptionHelper.packException( e, true );
-            System.out.println( error );
-            throw new Exception( error );
+            final String error = ExceptionHelper.packException( e, false );
+            fail( error );
         }
     }
 

Modified: avalon/trunk/tools/build.xml
==============================================================================
--- avalon/trunk/tools/build.xml	(original)
+++ avalon/trunk/tools/build.xml	Fri Jun 25 21:03:22 2004
@@ -2,7 +2,7 @@
 
 <project name="tools" default="default" basedir="." xmlns:x="antlib:org.apache.avalon.tools">
 
-  <x:home index="../central/system"/>
-  <import file="${magic.templates}/reactor.xml"/>
+  <property file="build.properties"/>
+  <import file="${project.home}/build/reactor.xml"/>
 
 </project>

Modified: avalon/trunk/tools/magic/build.properties
==============================================================================
--- avalon/trunk/tools/magic/build.properties	(original)
+++ avalon/trunk/tools/magic/build.properties	Fri Jun 25 21:03:22 2004
@@ -1,3 +1,3 @@
 #project.name = avalon-tools-magic
-#project.home = ../../central/system
+project.home = ../../central/system
 

Modified: avalon/trunk/tools/magic/build.xml
==============================================================================
--- avalon/trunk/tools/magic/build.xml	(original)
+++ avalon/trunk/tools/magic/build.xml	Fri Jun 25 21:03:22 2004
@@ -3,9 +3,8 @@
 <project name="avalon-tools-magic" default="install" basedir="." 
     xmlns:x="antlib:org.apache.avalon.tools">
 
-  <x:home index="../../central/system"/>
-
-  <import file="${magic.templates}/standard.xml"/>
+  <property file="build.properties"/>
+  <import file="${project.home}/build/standard.xml"/>
 
   <target name="javadoc" depends="prepare">
     <x:javadoc title="Avalon Magic" id="avalon-tools-magic">
@@ -14,7 +13,6 @@
   </target>
 
   <target name="test" depends="standard.test">
-    <ant dir="target/test/temp/demo" target="install"/>
     <mkdir dir="${basedir}/target/deliverables/demos"/>
     <zip destfile="${basedir}/target/deliverables/demos/demo.zip"
       basedir="etc/test/demo"/>
@@ -34,7 +32,7 @@
     <echo>
 magic properties
 ----------------
-magic.system:    ${magic.home}
+magic.home:      ${magic.home}
 magic.cache:     ${magic.cache}
 magic.docs:      ${magic.docs}
 magic.templates: ${magic.templates}
@@ -47,6 +45,10 @@
 project.group:   ${project.group}
 project.name:    ${project.name}
     </echo>
+  </target>
+
+  <target name="validate" depends="standard.test">
+    <ant dir="target/test/temp/demo" target="install"/>
   </target>
 
 </project>

Modified: avalon/trunk/tools/magic/etc/deliverables/properties/magic.properties
==============================================================================
--- avalon/trunk/tools/magic/etc/deliverables/properties/magic.properties	(original)
+++ avalon/trunk/tools/magic/etc/deliverables/properties/magic.properties	Fri Jun 25 21:03:22 2004
@@ -18,4 +18,10 @@
 ibiblio.org = http://www.ibiblio.org/maven
 magic.hosts = ${dpml.net};${java.repo};${ibiblio.org}
 
-
+#------------------------------------------------------------------
+# Cache directories 
+# (filenames resoilved relative to ${magic.home}
+#------------------------------------------------------------------
+#
+# magic.cache = cache
+# magic.docs = docs

Modified: avalon/trunk/tools/magic/setup.xml
==============================================================================
--- avalon/trunk/tools/magic/setup.xml	(original)
+++ avalon/trunk/tools/magic/setup.xml	Fri Jun 25 21:03:22 2004
@@ -44,17 +44,20 @@
     <echo message="Using home directory: ${magic.home}"/>
     <mkdir dir="${magic.home}"/>
 
+    <property file="${magic.home}/magic.properties"/>
+    <property file="${magic.home}/user.properties"/>
+
     <!-- Create the artifact cache. -->
-    <property name="magic.home.main" value="${magic.home}/main"/>
-    <mkdir dir="${magic.home.main}"/>
+    <property name="magic.main" value="${magic.home}/main"/>
+    <mkdir dir="${magic.main}"/>
 
     <!-- Create the docs cache. -->
-    <property name="magic.home.docs" value="${magic.home}/docs"/>
-    <mkdir dir="${magic.home.docs}"/>
+    <property name="magic.docs" value="${magic.home}/docs"/>
+    <mkdir dir="${magic.docs}"/>
 
     <!-- Create the magic group cache dir. -->
     <property name="magic.bar.destination" 
-      value="${magic.home.main}/${magic.group}"/>
+      value="${magic.main}/${magic.group}"/>
     <mkdir dir="${magic.bar.destination}/bars"/>
 
     <!-- Pull down the latest version of magic. -->

Modified: avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/Definition.java
==============================================================================
--- avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/Definition.java	(original)
+++ avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/Definition.java	Fri Jun 25 21:03:22 2004
@@ -131,17 +131,8 @@
     public File getDocDirectory()
     {
         final File cache = getHome().getDocsRepository().getCacheDirectory();
-        final File root = new File( cache, getInfo().getGroup() );
-        final File artifact = new File( root, getInfo().getName() );
-        final String version = getInfo().getVersion();
-        if( null == version )
-        {
-            return artifact;
-        }
-        else
-        {
-            return new File( artifact, version );
-        }
+        final String spec = getInfo().getSpecification( "/", "/" );
+        return new File( cache, spec );
     }
 
     public String toString()

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	Fri Jun 25 21:03:22 2004
@@ -43,12 +43,7 @@
     public static final String KEY = "project.home";
     public static final String HOME_KEY = "project.home";
     public static final String INDEX_KEY = "project.index";
-    public static final String MAGIC_HOME_KEY = "magic.home";
-
     public static final String HOSTS_KEY = "project.hosts";
-    public static final String MAIN_CACHE_KEY = "magic.main.cache";
-    public static final String DOCS_CACHE_KEY = "magic.docs.cache";
-
 
     //-------------------------------------------------------------
     // immutable state

Modified: avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/Info.java
==============================================================================
--- avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/Info.java	(original)
+++ avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/Info.java	Fri Jun 25 21:03:22 2004
@@ -27,6 +27,8 @@
  */
 public class Info 
 {
+    public static final String SNAPSHOT = "SNAPSHOT";
+ 
     public static final String PROTOCOL = "artifact";
 
     public static Info create( final String id )
@@ -49,15 +51,25 @@
         final String group = getGroupFromId( id, n );
         final String name = getNameFromId( id, n );
         final String version = getVersionFromId( id );
-        return new Info( group, name, version, type );
+        if( SNAPSHOT.equalsIgnoreCase( version ) )
+        {
+            return new Info( group, name, version, type, true );
+        }
+        else
+        {
+            return new Info( group, name, version, type, false );
+        }
     }
 
     private String m_name;
     private String m_group;
     private String m_version;
     private String m_type;
+    private boolean m_snapshot;
 
-    public Info( final String group, final String name, final String version, final String type )
+    public Info( 
+      final String group, final String name, final String version, 
+      final String type, boolean snapshot )
     {
         assertNotNull( "group", group );
         assertNotNull( "name", name );
@@ -66,6 +78,7 @@
         m_name = name;
         m_version = version;
         m_type = type;
+        m_snapshot = snapshot;
     }
 
     public String getGroup()
@@ -78,11 +91,24 @@
         return m_name;
     }
 
+   /**
+    * Return the version identifier.
+    * @return a string identifying the build version.
+    */
     public String getVersion()
     {
         return m_version;
     }
 
+   /**
+    * Return the snampshot staus of this artifact.
+    * @return true if this artifact is marked as a snapshot
+    */
+    public boolean isaSnapshot()
+    {
+        return m_snapshot;
+    }
+
     public String getType()
     {
         if( null == m_type )
@@ -118,25 +144,24 @@
         buffer.append( ":" );
         buffer.append( getType() );
         buffer.append( ":" );
-        buffer.append( getGroup() );
-        buffer.append( "/" );
-        buffer.append( getName() );
-        if( null != getVersion() )
-        {
-            buffer.append( "#" );
-            buffer.append( getVersion() );
-        }
+        buffer.append( getSpec() );
         return buffer.toString();
     }
 
     public String getSpec()
     {
+        return getSpecification( "/", "#" );
+    }
+
+    public String getSpecification( 
+      String groupSeparator, String versionSeparator )
+    {
         final StringBuffer buffer = new StringBuffer( getGroup() );
-        buffer.append( "/" );
+        buffer.append( groupSeparator );
         buffer.append( getName() );
-        if( null != getVersion() )
+        if(( null != m_version ) && !"".equals( m_version ))
         {
-            buffer.append( "#" );
+            buffer.append( versionSeparator );
             buffer.append( getVersion() );
         }
         return buffer.toString();
@@ -152,16 +177,17 @@
         if( other instanceof Info )
         {
             final Info info = (Info) other;
+            if( isaSnapshot() != info.isaSnapshot() ) return false;
             if( !getName().equals( info.getName() ) ) return false;
             if( !getGroup().equals( info.getGroup() ) ) return false;
             if( !getType().equals( info.getType() ) ) return false;
-            if( null == m_version ) 
+            if( null == getVersion() ) 
             {
                 return ( null == info.getVersion() );
             }
             else
             {
-                return m_version.equals( info.getVersion() );
+                return getVersion().equals( info.getVersion() );
             }
         }
         else
@@ -221,5 +247,4 @@
             return id.substring( j+1 );
         }
     }
-
 }

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	Fri Jun 25 21:03:22 2004
@@ -47,8 +47,8 @@
     public static final String KEY = "magic.home";
 
     public static final String HOSTS_KEY = "magic.hosts";
-    public static final String MAIN_CACHE_KEY = "magic.cache";
-    public static final String DOCS_CACHE_KEY = "magic.docs";
+    public static final String CACHE_KEY = "magic.cache";
+    public static final String DOCS_KEY = "magic.docs";
     public static final String TEMPLATES_KEY = "magic.templates";
 
     public static final String PROXY_HOST_KEY = "magic.proxy.host";
@@ -73,11 +73,11 @@
 
         File main = SYSTEM.getRepository().getCacheDirectory();
         project.setProperty( 
-          MAIN_CACHE_KEY, Context.getCanonicalPath( main ) );
+          CACHE_KEY, Context.getCanonicalPath( main ) );
 
-        File docs = SYSTEM.getRepository().getCacheDirectory();
+        File docs = SYSTEM.getDocsRepository().getCacheDirectory();
         project.setProperty( 
-          DOCS_CACHE_KEY, Context.getCanonicalPath( docs ) );
+          DOCS_KEY, Context.getCanonicalPath( docs ) );
 
         project.setProperty( 
           TEMPLATES_KEY, getTemplatePath( system ) );
@@ -116,13 +116,21 @@
         File properties = new File( m_system, "magic.properties" );
         loadProperties( project, properties );
 
+        //
+        // setup the main and docs cache
+        //
+
         final String hostsPath = project.getProperty( HOSTS_KEY );
         final String[] hosts = getHostsSequence( hostsPath );
 
-        final File main = new File( m_system, "main" );
+        project.setNewProperty( CACHE_KEY, "main" );
+        final String cachePath = project.getProperty( CACHE_KEY );
+        final File main = Context.getFile( m_system, cachePath );
         m_main = new Repository( project, main, hosts );
 
-        final File docs = new File( m_system, "docs" );
+        project.setNewProperty( DOCS_KEY, "docs" );
+        final String docsPath = project.getProperty( DOCS_KEY );
+        final File docs = Context.getFile( m_system, docsPath );
         m_docs = new Repository( project, docs, hosts );
 
         setupProxy( project );
@@ -133,7 +141,7 @@
             project.log( "  host: " + hosts[i], Project.MSG_VERBOSE ); 
         }
         project.log( 
-          "artifact cache: " + m_main.getCacheDirectory(), 
+          "main cache: " + m_main.getCacheDirectory(), 
           Project.MSG_VERBOSE );
         project.log( 
           "docs cache: " + m_docs.getCacheDirectory(), 

Modified: avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/XMLDefinitionBuilder.java
==============================================================================
--- avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/XMLDefinitionBuilder.java	(original)
+++ avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/XMLDefinitionBuilder.java	Fri Jun 25 21:03:22 2004
@@ -209,8 +209,18 @@
         final String type =
           ElementHelper.getValue( 
             ElementHelper.getChild( info, "type" ) );
+        final String status =
+          ElementHelper.getValue( 
+            ElementHelper.getChild( info, "status" ) );
 
-        return new Info( group, name, version, type );
+        if( Info.SNAPSHOT.equalsIgnoreCase( status ) )
+        {
+            return new Info( group, name, version, type, true );
+        }
+        else
+        {
+            return new Info( group, name, version, type, false );
+        }
     }
 
     private static ResourceRef[] createResourceRefs( final Element element )
@@ -258,7 +268,7 @@
         final boolean test =
           ElementHelper.getBooleanAttribute( element, "test", defTest );
         final boolean runtime =
-          ElementHelper.getBooleanAttribute( element, "runtime", defRuntime );
+          ElementHelper.getBooleanAttribute( element, "runtime", build );
         return new Policy( build, test, runtime );
     }
 }

Modified: avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/ContextualTask.java
==============================================================================
--- avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/ContextualTask.java	(original)
+++ avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/ContextualTask.java	Fri Jun 25 21:03:22 2004
@@ -34,8 +34,8 @@
  */
 public abstract class ContextualTask extends Task
 {
-    private static final String USER_PROPERTIES = "user.properties";
-    private static final String PROJECT_PROPERTIES = "project.properties";
+    public static final String USER_PROPERTIES = "user.properties";
+    public static final String MODULE_PROPERTIES = "module.properties";
 
     private boolean m_init = false;
 
@@ -84,19 +84,10 @@
 
     protected void setupProperties( final Project project, final File dir )
     {
-        setupUserProperties( project, dir );
-        setupBuildProperties( project, dir );
-    }
-
-    private void setupUserProperties( final Project project, final File dir )
-    {
         final File user = Context.getFile( dir, USER_PROPERTIES );
         loadProperties( project, user );
-    }
 
-    private void setupBuildProperties( final Project project, final File dir )
-    {
-        final File build = Context.getFile( dir, PROJECT_PROPERTIES );
+        final File build = Context.getFile( dir, MODULE_PROPERTIES );
         loadProperties( project, build );
     }
 

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	Fri Jun 25 21:03:22 2004
@@ -36,6 +36,8 @@
  */
 public class HomeTask extends ContextualTask
 {
+    private static final String INDEX_PROPERTIES = "index.properties";
+
     private String m_path;
 
     public void setIndex( final String path )
@@ -51,8 +53,17 @@
 
         Magic system = Magic.getSystem( project );
         Home home = system.getHome( project, m_path );
+        File root = getHomeDirectory( home );
+
         project.setProperty( Home.HOME_KEY, getHomePath( home ) );
         project.setProperty( Home.INDEX_KEY, getIndexPath( home ) );
+
+        File homeProperties = new File( root, INDEX_PROPERTIES );
+        loadProperties( project, homeProperties );
+
+        File userHomeProperties = new File( root, USER_PROPERTIES );
+        loadProperties( project, userHomeProperties );
+
         project.addReference( Home.KEY, home );
 
         final String key = getKey();
@@ -69,7 +80,16 @@
             {
                 project.setProperty( "project.version", version );
             }
+            else
+            {
+                project.setProperty( "project.version", "" );
+            }
         }
+    }
+
+    private File getHomeDirectory( Home home )
+    {
+        return home.getIndex().getParentFile();
     }
 
     private String getHomePath( Home home )

Modified: avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/JavadocTask.java
==============================================================================
--- avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/JavadocTask.java	(original)
+++ avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/JavadocTask.java	Fri Jun 25 21:03:22 2004
@@ -101,19 +101,10 @@
             {
                 final Resource resource = home.getResource( m_key );
                 final File cache = home.getDocsRepository().getCacheDirectory();
-                final File group = new File( cache, resource.getInfo().getGroup() );
-                final File docs = new File( group, resource.getInfo().getName() );
                 final String category = ResourceRef.getCategoryName( m_tag );
-                final String version = resource.getInfo().getVersion();
-                if(( null == version ) || "".equals( version ))
-                {
-                    return new File( docs, category );
-                }
-                else
-                {
-                    final File vDir = new File( docs, version );
-                    return new File( vDir, category );
-                }
+                final String spec = 
+                  resource.getInfo().getSpecification( "/", "/" );
+                return new File( cache, spec + "/" + category );
             }
         }
 

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