svn commit: rev 22593 - in avalon/trunk: . tools tools/magic tools/magic/src/main/org/apache/avalon/tools/model tools/magic/src/main/org/apache/avalon/tools/tasks

[email protected]
Newsgroups gmane.comp.jakarta.avalon.cvs
Message-ID <[email protected]>
Author: mcconnell
Date: Mon Jul  5 07:07:08 2004
New Revision: 22593

Modified:
   avalon/trunk/build.xml
   avalon/trunk/tools/index.xml
   avalon/trunk/tools/magic/README.TXT
   avalon/trunk/tools/magic/bootstrap.xml
   avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/Gump.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/GumpTask.java
   avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/PluginTask.java
Log:


Modified: avalon/trunk/build.xml
==============================================================================
--- avalon/trunk/build.xml	(original)
+++ avalon/trunk/build.xml	Mon Jul  5 07:07:08 2004
@@ -50,7 +50,7 @@
     <x:gump description="Magic Test Module" 
          public="true" filename="gump.xml">
       <x:url href="http://avalon.apache.org/"/>
-      <x:svn href="https://svn.apache.org/repos/asf/avalon/trunk"/>
+      <x:svn repository="avalon-svn" dir="trunk"/>
       <x:license file="central/system/license/LICENSE.TXT"/>
     </x:gump>
   </target>

Modified: avalon/trunk/tools/index.xml
==============================================================================
--- avalon/trunk/tools/index.xml	(original)
+++ avalon/trunk/tools/index.xml	Mon Jul  5 07:07:08 2004
@@ -22,7 +22,8 @@
       <type>jar</type>
     </info>
     <gump>
-      <ignore/>
+      <!--<ignore/>-->
+      <classpath/>
       <alias>ant</alias>
       <id>nodeps</id>
     </gump>
@@ -36,7 +37,8 @@
       <type>jar</type>
     </info>
     <gump>
-      <ignore/>
+      <!--<ignore/>-->
+      <classpath/>
       <alias>ant</alias>
       <id>junit</id>
     </gump>

Modified: avalon/trunk/tools/magic/README.TXT
==============================================================================
--- avalon/trunk/tools/magic/README.TXT	(original)
+++ avalon/trunk/tools/magic/README.TXT	Mon Jul  5 07:07:08 2004
@@ -12,4 +12,8 @@
 
   $ ant clean install
 
+To simulate a gump build of magic by magic
+
+ $ ant -Dmagic.home=target/123 -Dgump.signature=123 -Dgump.resource.ant=lib/ant.jar -Dgump.resource.junit=lib/junit.jar -Dgump.resource.ant-junit=lib/ant-junit.jar -Dgump.resource.ant-nodeps=lib/ant-nodeps.jar
+
 

Modified: avalon/trunk/tools/magic/bootstrap.xml
==============================================================================
--- avalon/trunk/tools/magic/bootstrap.xml	(original)
+++ avalon/trunk/tools/magic/bootstrap.xml	Mon Jul  5 07:07:08 2004
@@ -83,4 +83,29 @@
     <delete dir="${target}"/> 
   </target>
 
+  <target name="signature-check" unless="gump.signature.declared">
+    <fail maessage="Required property 'gump.signature' is undefined."/>
+  </target>
+
+  <!--
+  Setup magic's home directory.  This task will be invoked by gump
+  following the bootstrap phase. The location of magic.home will be 
+  establised as target/target/${gump.signature}.
+  -->
+  <target name="home" depends="signature-check">
+    <property name="home" location="${basedir}/target/${gump.signature}"/>
+    <echo>Creating 'magic.home' in ${home}</echo>
+    <mkdir dir="${home}"/>
+    <mkdir dir="${home}/docs"/>
+    <mkdir dir="${home}/cache"/>
+    <mkdir dir="${home}/templates"/>
+    <mkdir dir="${home}/themes"/>
+    <copy todir="${home}/templates">
+      <fileset dir="target/deliverables/templates"/>
+    </copy>
+    <copy todir="${home}/themes">
+      <fileset dir="target/deliverables/themes"/>
+    </copy>
+  </target>
+
 </project>

Modified: avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/Gump.java
==============================================================================
--- avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/Gump.java	(original)
+++ avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/model/Gump.java	Mon Jul  5 07:07:08 2004
@@ -27,15 +27,19 @@
  */
 public class Gump 
 {
-    public static final Gump NULL_GUMP = new Gump( null, null );
+    public static final Gump NULL_GUMP = new Gump( null, null, false, false );
 
     private String m_alias;
     private String m_id;
+    private boolean m_ignore;
+    private boolean m_classpath;
 
-    public Gump( final String alias, final String id )
+    public Gump( final String alias, final String id, boolean classpath, boolean ignore )
     {
         m_alias = alias;
         m_id = id;
+        m_ignore = ignore;
+        m_classpath = classpath;
     }
 
    /**
@@ -52,5 +56,23 @@
     public String getId()
     {
         return m_id;
+    }
+
+   /**
+    * Return true if this defintion can be ignored when 
+    * building a gump project dependency.
+    */
+    public boolean isIgnorable()
+    {
+        return m_ignore;
+    }
+
+   /**
+    * Return true if this defintion is required as part of the 
+    * classpath established by gump.
+    */
+    public boolean isClasspathEntry()
+    {
+        return m_classpath;
     }
 }

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	Mon Jul  5 07:07:08 2004
@@ -247,9 +247,31 @@
         try
         {
             final Element root = ElementHelper.getRootElement( source );
-            final Element[] elements = ElementHelper.getChildren( root );
-            final File anchor = source.getParentFile();
-            buildLocalList( anchor, elements );
+            final String rootElementName = root.getTagName();
+            if( "index".equals( rootElementName ) )
+            {
+                //
+                // its a native magic index
+                //
+
+                final Element[] elements = ElementHelper.getChildren( root );
+                final File anchor = source.getParentFile();
+                buildLocalList( anchor, elements );
+            }
+            else if( "project".equals( rootElementName ) )
+            {
+                //
+                // its probably a maven project definition
+                //
+
+                buildFromMavenProject( source, root );
+            }
+            else
+            {
+                final String error = 
+                  "Unrecognized rooot element [" + rootElementName + "].";
+                throw new BuildException( error );
+            }
         }
         catch( Throwable e )
         {
@@ -451,6 +473,23 @@
           "resource".equals( tag ) 
           || "project".equals( tag )
           || "plugin".equals( tag ) );
+    }
+
+   /**
+    * Create a magic index from a maven project file.
+    * @param root the root DOM element of the maven project file
+    */
+    private void buildFromMavenProject( File file, Element root )
+    {
+        //
+        // maven uses the notion of project inheritance which is 
+        // functionally equivalent to magic's index inclusion
+        // .. so the first step is to resolve the any project
+        // that the target project extends
+        //
+        
+        throw new UnsupportedOperationException();
+
     }
 
     /*

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	Mon Jul  5 07:07:08 2004
@@ -60,15 +60,15 @@
       final Home home, final String group, final String name, final String version, 
       final String type, boolean snapshot )
     {
-        //if( home.isGump() ) 
-        //{
-        //    final String sig = home.getGumpSignature();
-        //    return new Info( group, name, sig, type, snapshot );
-        //}
-        //else
-        //{
+        if( home.isGump() )
+        {
+            final String signature = home.getGumpSignature();
+            return new Info( group, name, signature, type, false );
+        }
+        else
+        {
             return new Info( group, name, version, type, snapshot );
-        //}
+        }
     }
 
     private String m_name;

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	Mon Jul  5 07:07:08 2004
@@ -117,14 +117,10 @@
         setProject( project );
 
         m_signature = project.getProperty( GUMP_SIGNATURE_KEY );
-
         m_system = getSystemDirectory( project );
-
         project.setProperty( KEY, Context.getCanonicalPath( m_system ) );
-
         File user = new File( m_system, "user.properties" );
         loadProperties( project, user );
-
         File properties = new File( m_system, "magic.properties" );
         loadProperties( project, properties );
 
@@ -316,6 +312,13 @@
 
     private File getSystemDirectory( final Project project )
     {
+        final String path = project.getProperty( "magic.home" );
+        if( null != path )
+        {
+            File system = new File( path );
+            return Context.getCanonicalFile( system );
+        }
+
         final Property property = (Property) project.createTask( "property" );
         property.setEnvironment( "env" );
         property.init();

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	Mon Jul  5 07:07:08 2004
@@ -173,12 +173,12 @@
         final String name =
           ElementHelper.getValue( 
             ElementHelper.getChild( info, "name" ) );
-        final String version =
-          ElementHelper.getValue( 
-            ElementHelper.getChild( info, "version" ) );
         final String type =
           ElementHelper.getValue( 
             ElementHelper.getChild( info, "type" ) );
+        final String version =
+          ElementHelper.getValue( 
+            ElementHelper.getChild( info, "version" ) );
         final boolean status = createSnapshotPolicy( info );
         return Info.create( home, group, name, version, type, status );
     }
@@ -199,7 +199,9 @@
         final String id =
           ElementHelper.getValue( 
             ElementHelper.getChild( info, "id" ) );
-        return new Gump( alias, id );
+        final boolean classpath = (null != ElementHelper.getChild( info, "classpath" ));
+        final boolean ignore = (null != ElementHelper.getChild( info, "ignore" ));
+        return new Gump( alias, id, classpath, ignore );
     }
 
     private static ResourceRef[] createResourceRefs( final Element element )

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	Mon Jul  5 07:07:08 2004
@@ -102,11 +102,44 @@
     {
     }
 
-    public static class Cvs extends Href
+    public static class Repository extends Href
+    {
+        private String m_repository;
+        private String m_dir;
+
+        public void setRepository( String repository )
+        {
+            m_repository = repository;
+        }
+
+        public void setDir( String dir )
+        {
+            if( dir.endsWith( "/" ) )
+            {
+                m_dir = dir;
+            }
+            else
+            {
+                m_dir = dir + "/";
+            }
+        }
+
+        public String getRepository()
+        {
+            return m_repository;
+        }
+
+        public String getDir()
+        {
+            return m_dir;
+        }
+    }
+
+    public static class Cvs extends Repository
     {
     }
 
-    public static class Svn extends Href
+    public static class Svn extends Repository
     {
     }
 
@@ -286,11 +319,27 @@
 
         if( null != m_svn )
         {
-            writer.write( "\n  <svn href=\"" + m_svn.getHref() + "\"/>" );
+            if( null != m_svn.getHref() )
+            {
+                writer.write( "\n  <svn href=\"" + m_svn.getHref() + "\"/>" );
+            }
+            else
+            {
+                writer.write( "\n  <svn repository=\"" + m_svn.getRepository() 
+                  + "\" dir=\"" + m_svn.getDir() + "\"/>" );
+            }
         }
-        else if( null != m_svn )
+        else if( null != m_cvs )
         {
-            writer.write( "\n  <cvs href=\"" + m_cvs.getHref() + "\"/>" );
+            if( null != m_cvs.getHref() )
+            {
+                writer.write( "\n  <cvs href=\"" + m_cvs.getHref() + "\"/>" );
+            }
+            else
+            {
+                writer.write( "\n  <cvs repository=\"" + m_cvs.getRepository() 
+                  + "\" dir=\"" + m_cvs.getDir() + "\"/>" );
+            }
         }
 
         Definition[] definitions = home.getDefinitions();
@@ -399,13 +448,18 @@
         writer.write( 
            "\n      <!-- for magic -->" );
         writer.write( 
+           "\n      <depend name=\"magic.home\" resource=\"home\"" );
+        writer.write( 
+           "\n          project=\"avalon-tools-magic-home\" inherit=\"runtime\" />" );
+        writer.write( 
            "\n      <property name=\"gump.signature\" value=\"@@DATE@@\"/>" );
 
         boolean flag = false;
         for( int i=0; i<refs.length; i++ )
         {
             Resource resource = getHome().getResource( refs[i] );
-            if( !(resource instanceof Definition) )
+            boolean ignorable = resource.getGump().isIgnorable();
+            if( !(resource instanceof Definition) && !ignorable )
             {
                 if( !flag )
                 {
@@ -423,9 +477,17 @@
                 {
                     writer.write( " id=\"" + id + "\"" );
                 }
-                writer.write( ">" );
-                writer.write( "\n        <noclasspath/>" );
-                writer.write( "\n      </depend>" );
+
+                if( resource.getGump().isClasspathEntry() )
+                {
+                    writer.write( "/>" );
+                }
+                else
+                {
+                    writer.write( ">" );
+                    writer.write( "\n        <noclasspath/>" );
+                    writer.write( "\n      </depend>" );
+                }
             }
         }
 
@@ -433,14 +495,6 @@
         writer.write( "\n    </ant>" );       
 
         //
-        // add the magic bootstrap dependency
-        //
-
-        writer.write( "\n    <!-- magic -->" );
-        writer.write( 
-          "\n    <depend project=\"avalon-tools-magic-bootstrap\" inherit=\"true\" runtime=\"true\"/>" );
-
-        //
         // add dependencies for gump to do its sequencing correctly
         //
 
@@ -448,7 +502,8 @@
         for( int i=0; i<refs.length; i++ )
         {
             Resource resource = getHome().getResource( refs[i] );
-            if( resource instanceof Definition )
+            boolean ignorable = resource.getGump().isIgnorable();
+            if( ( resource instanceof Definition ) && !ignorable )
             {
                 if( !flag )
                 {
@@ -456,8 +511,20 @@
                     writer.write( "\n    <!-- for gump -->" );
                 }
                 String key = resource.getKey();
+
                 writer.write( 
-                  "\n    <depend project=\"" + key + "\"><noclasspath/></depend>" );
+                  "\n    <depend project=\"" + key + "\"" );
+
+                if( resource.getGump().isClasspathEntry() )
+                {
+                    writer.write( "/>" );
+                }
+                else
+                {
+                    writer.write( ">" );
+                    writer.write( "\n      <noclasspath/>" );
+                    writer.write( "\n    </depend>" );
+                }
             }
         }
 
@@ -478,18 +545,18 @@
         {
             writer.write( 
               "\n    <jar name=\"" + type + "s/" 
-              + filename + "\"/>" );
+              + name + "-@@DATE@@." + type  + "\"/>" );
         }
         if( "plugin".equals( type ) )
         {
             writer.write( 
               "\n    <jar name=\"jars/" 
-              + filename + "\"/>" );
+              + name + "-@@DATE@@." + type  + "\"/>" );
         }
         else if( "doc".equals( type ) )
         {
             writer.write( 
-              "\n    <!-- doc output is relative to the module root -->" );
+              "\n    <!-- doc output is relative merlin home docs cache -->" );
         }
 
         writer.write( "\n    <nag to=\"[email protected]\"" ); 

Modified: avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/PluginTask.java
==============================================================================
--- avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/PluginTask.java	(original)
+++ avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/PluginTask.java	Mon Jul  5 07:07:08 2004
@@ -74,7 +74,6 @@
             // get the xml definition of the plugin
             //
 
-
             final String id = getArtifactSpec();
             final Info info = Info.create( getHome(), id );
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.