avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mcconn...@apache.org
Subject svn commit: rev 22550 - in avalon/trunk: . runtime tools tools/magic/src/main/org/apache/avalon/tools/model tools/magic/src/main/org/apache/avalon/tools/tasks
Date Sun, 04 Jul 2004 09:07:50 GMT
Author: mcconnell
Date: Sun Jul  4 02:07:49 2004
New Revision: 22550

Added:
   avalon/trunk/tools/common.xml
   avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/UnknownResourceException.java
Modified:
   avalon/trunk/build.xml
   avalon/trunk/runtime/index.xml
   avalon/trunk/tools/index.xml
   avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/Home.java
   avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/Resource.java
   avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/ArtifactTask.java
   avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/DeclareTask.java
   avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/GumpTask.java
   avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/JavadocTask.java
   avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/PropertyTask.java
Log:
Getting close to an automated gump.

Modified: avalon/trunk/build.xml
==============================================================================
--- avalon/trunk/build.xml	(original)
+++ avalon/trunk/build.xml	Sun Jul  4 02:07:49 2004
@@ -47,21 +47,12 @@
 
   <target name="gump">
     <x:home/>
-    <x:gump name="Magic" description="Magic Test Module" 
+    <x:gump description="Magic Test Module" 
          public="true" filename="gump.xml">
-      <x:url href="http://avalon.apache.org/magic"/>
+      <x:url href="http://avalon.apache.org/"/>
       <x:svn href="https://svn.apache.org/repos/asf/avalon/trunk"/>
       <x:license file="central/system/license/LICENSE.TXT"/>
     </x:gump>
-  </target>
-
-  <target name="execute">
-    <property name="gump.build-id" value="123456"/>
-    <property name="gump.target" value="runtime/composition/api"/>
-    <echo>BASDIR: ${basedir}</echo>
-    <echo>TARGET: ${gump.target}</echo>
-
-    <ant dir="." antfile="central/system/build/gump.xml" inheritrefs="false"/>
   </target>
 
 </project>

Modified: avalon/trunk/runtime/index.xml
==============================================================================
--- avalon/trunk/runtime/index.xml	(original)
+++ avalon/trunk/runtime/index.xml	Sun Jul  4 02:07:49 2004
@@ -2,8 +2,8 @@
 
 <index>
 
-  <import index="../tools/index.xml"
-     href="http://svn.apache.org/repos/asf/avalon/trunk/tools/index.xml"/>
+  <import index="../tools/common.xml"
+     href="http://svn.apache.org/repos/asf/avalon/trunk/tools/common.xml"/>
 
   <!--
   Declaration of the binary resources available through

Added: avalon/trunk/tools/common.xml
==============================================================================
--- (empty file)
+++ avalon/trunk/tools/common.xml	Sun Jul  4 02:07:49 2004
@@ -0,0 +1,60 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+
+<!-- index of resources shared between tools and runtime -->
+
+<index>
+
+  <resource>
+    <info>
+      <group>junit</group>
+      <name>junit</name>
+      <version>3.8.1</version>
+      <type>jar</type>
+    </info>
+  </resource>
+
+  <!--
+  Avalon Tools.
+  -->
+
+  <project basedir="magic">
+    <info>
+      <group>avalon/tools</group>
+      <name>avalon-tools-magic</name>
+      <type>jar</type>
+    </info>
+    <dependencies>
+      <include key="ant"/>
+      <include key="junit"/>
+      <include key="ant-junit"/>
+      <include key="ant-nodeps"/>
+    </dependencies>
+  </project>
+
+  <!--
+  Avalon eXternal Supplemental.
+  -->
+
+  <!--
+  <project basedir="supplemental">
+    <info>
+      <group>avalonx/supplemental</group>
+      <name>avalonx-supplemental</name>
+      <version>1.0</version>
+    </info>
+  </project>
+  -->
+
+  <resource>
+    <info>
+      <group>avalonx/supplemental</group>
+      <name>mailapi</name>
+      <version>1.3.1</version>
+      <type>jar</type>
+    </info>
+    <gump>
+      <alias>javamail</alias>
+    </gump>
+  </resource>
+
+</index>

Modified: avalon/trunk/tools/index.xml
==============================================================================
--- avalon/trunk/tools/index.xml	(original)
+++ avalon/trunk/tools/index.xml	Sun Jul  4 02:07:49 2004
@@ -2,6 +2,9 @@
 
 <index>
 
+  <import index="common.xml"
+     href="http://svn.apache.org/repos/asf/avalon/trunk/tools/common.xml"/>
+
   <resource>
     <info>
       <group>ant</group>
@@ -39,15 +42,6 @@
       <alias>ant</alias>
       <id>junit</id>
     </gump>
-  </resource>
-
-  <resource>
-    <info>
-      <group>junit</group>
-      <name>junit</name>
-      <version>3.8.1</version>
-      <type>jar</type>
-    </info>
   </resource>
 
   <!--

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 Jul  4 02:07:49
2004
@@ -158,9 +158,7 @@
         final Resource resource = (Resource) m_resources.get( key );
         if( null == resource )
         {
-            final String error = 
-              "Unknown resource [" + key + "]";
-            throw new BuildException( error );
+            throw new UnknownResourceException( key );
         }
         return resource;
     }

Modified: avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/Resource.java
==============================================================================
--- avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/Resource.java	(original)
+++ avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/Resource.java	Sun Jul
 4 02:07:49 2004
@@ -84,10 +84,11 @@
         return m_home;
     }
 
-    public ResourceRef[] getResourceRefs( final int mode, final int tag, final boolean flag
)
+    public ResourceRef[] getResourceRefs( 
+      final Project project, final int mode, final int tag, final boolean flag )
     {
         final ArrayList list = new ArrayList();
-        getResourceRefs( list, mode, tag, flag );
+        getResourceRefs( project, list, mode, tag, flag );
         return (ResourceRef[]) list.toArray( new ResourceRef[0] );
     }
 
@@ -96,7 +97,7 @@
     // optimization is need to eliminate duplicates
 
     protected void getResourceRefs( 
-      final List list, final int mode, final int tag, final boolean flag )
+      final Project project, final List list, final int mode, final int tag, final boolean
flag )
     {
         final ResourceRef[] refs = getResourceRefs();
         for( int i=0; i<refs.length; i++ )
@@ -110,8 +111,8 @@
                     list.add( ref );
                     if( flag )
                     {
-                        final Resource def = getHome().getResource( ref );
-                        def.getResourceRefs( list, mode, ResourceRef.ANY, flag );
+                        final Resource def = getResource( project, ref );
+                        def.getResourceRefs( project, list, mode, ResourceRef.ANY, flag );
                     }
                 }
             }
@@ -131,13 +132,13 @@
 
         final ArrayList visited = new ArrayList();
         final Path path = new Path( project );
-        final ResourceRef[] refs = getResourceRefs( mode, ResourceRef.ANY, true );
+        final ResourceRef[] refs = getResourceRefs( project, mode, ResourceRef.ANY, true
);
         for( int i=0; i<refs.length; i++ )
         {
             final ResourceRef ref = refs[i];
             if( !visited.contains( ref ) )
             {
-                final Resource resource = getHome().getResource( ref );
+                final Resource resource = getResource( project, ref );
                 final File file = resource.getArtifact( project );
                 path.createPathElement().setLocation( file );
                 visited.add( ref );
@@ -147,11 +148,26 @@
         return path;
     }
 
-    public ResourceRef[] getQualifiedRefs( final List visited, final int category )
+    private Resource getResource( Project project, ResourceRef ref ) 
+    {
+        try
+        {
+            return getHome().getResource( ref );
+        }
+        catch( UnknownResourceException ure )
+        {
+            final String error = 
+              "Resource defintion " + this + " contains a unknown resource reference ["
+                 + ure.getKey() + "] referenced in the project [" + project.getName() + "].";
+            throw new BuildException( error );
+        }
+    }
+
+    public ResourceRef[] getQualifiedRefs( Project project, final List visited, final int
category )
     {
         final ArrayList list = new ArrayList();
         final ResourceRef[] refs =
-          getResourceRefs( Policy.RUNTIME, category, true );
+          getResourceRefs( project, Policy.RUNTIME, category, true );
         for( int i=0; i<refs.length; i++ )
         {
             final ResourceRef ref = refs[i];

Added: avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/UnknownResourceException.java
==============================================================================
--- (empty file)
+++ avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/UnknownResourceException.java
Sun Jul  4 02:07:49 2004
@@ -0,0 +1,45 @@
+/* 
+ * 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.tools.model;
+
+import org.apache.tools.ant.BuildException;
+
+/**
+ * Project info.
+ *
+ * @author <a href="mailto:dev@avalon.apache.org">Avalon Development Team</a>
+ * @version $Revision: 1.2 $ $Date: 2004/03/17 10:30:09 $
+ */
+public class UnknownResourceException extends BuildException 
+{
+    private final String m_key;
+
+    public UnknownResourceException( final String key )
+    {
+        super( "Requested key [" + key + "] is unknown." );
+        m_key = key;
+    }
+
+   /**
+    * Return the problem key.
+    */
+    public String getKey()
+    {
+        return m_key;
+    }
+}

Modified: avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/ArtifactTask.java
==============================================================================
--- avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/ArtifactTask.java	(original)
+++ avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/ArtifactTask.java	Sun
Jul  4 02:07:49 2004
@@ -197,7 +197,7 @@
         throws IOException
     {
         final ArrayList visited = new ArrayList();
-        final ResourceRef[] apis = def.getQualifiedRefs( visited, ResourceRef.API );
+        final ResourceRef[] apis = def.getQualifiedRefs( getProject(), visited, ResourceRef.API
);
         if( apis.length > 0 )
         {
             writer.write( "\n" );
@@ -207,7 +207,7 @@
             final String lead = "avalon.artifact.dependency.api";
             writeRefs( writer, apis, lead );
         }
-        final ResourceRef[] spis = def.getQualifiedRefs( visited, ResourceRef.SPI );
+        final ResourceRef[] spis = def.getQualifiedRefs( getProject(), visited, ResourceRef.SPI
);
         if( spis.length > 0 )
         {
             writer.write( "\n" );
@@ -218,7 +218,7 @@
             writeRefs( writer, spis, lead );
         }
 
-        final ResourceRef[] impl = def.getQualifiedRefs( visited, ResourceRef.IMPL );
+        final ResourceRef[] impl = def.getQualifiedRefs( getProject(), visited, ResourceRef.IMPL
);
         if( impl.length > 0 )
         {
             writer.write( "\n" );

Modified: avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/DeclareTask.java
==============================================================================
--- avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/DeclareTask.java	(original)
+++ avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/DeclareTask.java	Sun Jul
 4 02:07:49 2004
@@ -188,7 +188,7 @@
         writer.write( "\n" + padding + "<classpath>" );
         final String pad = padding + "  ";
         final ResourceRef[] resources =
-          def.getResourceRefs( Policy.RUNTIME, ResourceRef.ANY, true );
+          def.getResourceRefs( getProject(), Policy.RUNTIME, ResourceRef.ANY, true );
         writeResourceRefs( writer, pad, resources );
         if( flag )
         {

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	Sun Jul
 4 02:07:49 2004
@@ -27,6 +27,7 @@
 import org.apache.avalon.tools.model.Policy;
 import org.apache.avalon.tools.model.Home;
 import org.apache.avalon.tools.model.Context;
+import org.apache.avalon.tools.model.UnknownResourceException;
 
 import org.apache.tools.ant.BuildException;
 import org.apache.tools.ant.Project;
@@ -231,13 +232,15 @@
             final File file = getFile();
             file.getParentFile().mkdirs();
             file.createNewFile();
+            log( "output: " + file );
             final OutputStream output = new FileOutputStream( file );
             final Writer writer = new OutputStreamWriter( output );
 
             try
             {
                 writeHeader( writer );
-                writeModule( writer );
+                int count = writeModule( writer );
+                log( "project: " + count );
                 writer.flush();
             }
             finally
@@ -263,13 +266,14 @@
         }
     }
 
-    protected void writeModule( final Writer writer )
+    protected int writeModule( final Writer writer )
         throws IOException
     {
         Home home = getHome();
         Project project = getProject();
         String name = getName();
 
+        log( "module: " + name );
         writer.write( "\n\n<module name=\"" + name + "\">" );
         writer.write( "\n\n  <url href=\"" + m_url.getHref() + "\"/>" );
 
@@ -293,10 +297,21 @@
         for( int i=0; i<definitions.length; i++ )
         {
             Definition def = definitions[i];
-            writeProject( writer, def );
+            try
+            {
+                writeProject( writer, def );
+            }
+            catch( UnknownResourceException ure )
+            {
+                final String error = 
+                  "Project defintion [" + def + "] contains a unknown resource reference
["
+                  + ure.getKey() + "].";
+                throw new BuildException( error );
+            }
         }
 
         writer.write( "\n\n</module>\n" );
+        return definitions.length;
     }
 
    /**
@@ -340,7 +355,7 @@
     * @throws IOException if unable to write xml
     */
     private void writeProject( final Writer writer, Definition definition )
-        throws IOException
+        throws IOException, UnknownResourceException
     {
         String path = definition.getBaseDir().getCanonicalPath();
         int j = getProject().getBaseDir().toString().length();
@@ -357,7 +372,7 @@
         }
 
         final ResourceRef[] refs =
-          definition.getResourceRefs( Policy.ANY, ResourceRef.ANY, true );
+          definition.getResourceRefs( getProject(), Policy.ANY, ResourceRef.ANY, true );
 
         String template = m_template.getFile();
         String target = m_template.getTarget();
@@ -380,6 +395,8 @@
            "\n      <!-- for magic -->" );
         writer.write( 
            "\n      <property name=\"gump.signature\" value=\"@@DATE@@\"/>" );
+        writer.write( 
+           "\n      <property name=\"gump.scrdir\" reference=\"srcdir\"/>" );
 
         boolean flag = false;
         for( int i=0; i<refs.length; i++ )
@@ -394,30 +411,37 @@
                       "\n      <!-- external references -->" );
                 }
                 String key = resource.getKey();
+                String alias = getKeyForResource( resource );
+                writer.write( 
+                   "\n      <depend property=\"gump.resource." + key 
+                   + "\" project=\"" + alias + "\"" );
                 String id = resource.getGump().getId();
-                if( null == id )
-                {
-                    String alias = getKeyForResource( resource );
-                    writer.write( 
-                      "\n      <depend property=\"gump.resource." + key 
-                      + "\" project=\"" + alias 
-                      + "\"/>" );
-                }
-                else
+                if( null != id )
                 {
-                    String alias = getKeyForResource( resource );
-                    writer.write( 
-                      "\n      <depend property=\"gump.resource." + key 
-                      + "\" project=\"" + alias 
-                      + "\" id=\"" + id + "\"/>" );
+                    writer.write( " id=\"" + id + "\"" );
                 }
+                writer.write( ">" );
+                writer.write( "\n        <noclasspath/>" );
+                writer.write( "\n      </depend>" );
             }
         }
 
         writer.write( "\n      <!-- end for -->" );
+        writer.write( "\n    </ant>" );       
+
+        //
+        // add the magic bootstrap dependency
+        //
+
+        writer.write( "\n    <!-- magic -->" );
+        writer.write( 
+          "\n    <depend project=\"avalon-tools-magic\" inherit=\"true\" runtime=\"true\"/>"
);
+
+        //
+        // add dependencies for gump to do its sequencing correctly
+        //
 
         flag = false;
-        writer.write( "\n    </ant>" );       
         for( int i=0; i<refs.length; i++ )
         {
             Resource resource = getHome().getResource( refs[i] );
@@ -430,7 +454,7 @@
                 }
                 String key = resource.getKey();
                 writer.write( 
-                  "\n    <depend project=\"" + key + "\"/>" );
+                  "\n    <depend project=\"" + key + "\"><noclasspath/></depend>"
);
             }
         }
 

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	Sun Jul
 4 02:07:49 2004
@@ -193,10 +193,11 @@
     }
 
     private void setup( 
-      final Definition def, final Path classpath, final int category, final File root, final
boolean flag )
+      final Definition def, final Path classpath, final int category, 
+      final File root, final boolean flag )
     {
         final ResourceRef[] refs =
-          def.getResourceRefs( Policy.RUNTIME, category, true );
+          def.getResourceRefs( getProject(), Policy.RUNTIME, category, true );
         if( flag || ( refs.length > 0 ))
         {
             generate( def, classpath, refs, category, root, flag );

Modified: avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/PropertyTask.java
==============================================================================
--- avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/PropertyTask.java	(original)
+++ avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/PropertyTask.java	Sun
Jul  4 02:07:49 2004
@@ -137,7 +137,7 @@
     {
         final StringBuffer buffer = new StringBuffer();
         final ResourceRef[] refs =
-          def.getResourceRefs( Policy.RUNTIME, ResourceRef.ANY, true );
+          def.getResourceRefs( getProject(), Policy.RUNTIME, ResourceRef.ANY, true );
         for( int i=0; i<refs.length; i++ )
         {
             if( i>0 )

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


Mime
View raw message