You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@avalon.apache.org by ni...@apache.org on 2004/05/31 17:07:35 UTC

svn commit: rev 20689 - in avalon/trunk/tools/magic: prepare/src/dist xdoc/src/dist

Author: niclas
Date: Mon May 31 08:07:34 2004
New Revision: 20689

Modified:
   avalon/trunk/tools/magic/prepare/src/dist/magic.bsh
   avalon/trunk/tools/magic/xdoc/src/dist/magic.bsh
   avalon/trunk/tools/magic/xdoc/src/dist/magic.properties
Log:
Sharing the copy function in prepare plugin.

Modified: avalon/trunk/tools/magic/prepare/src/dist/magic.bsh
==============================================================================
--- avalon/trunk/tools/magic/prepare/src/dist/magic.bsh	(original)
+++ avalon/trunk/tools/magic/prepare/src/dist/magic.bsh	Mon May 31 08:07:34 2004
@@ -52,56 +52,55 @@
         m_Initialized = true;
     }
     
-    private void copySources()
+    public void copySources()
     {
         String destdirname = m_Context.getProperty( "prepare.build.src.dir" );
         File toDir = new File( destdirname ); 
         String srcdirname = m_Context.getProperty( "prepare.src.dir" );
         File fromDir = new File( srcdirname ); 
         toDir.mkdirs();  /* ensure that the directory exists. */
-        String textFiles = m_Context.getProperty( "prepare.filtered.files" );
         
-        copyWithFilter( fromDir, toDir, textFiles );
-        copyWithOutFilter( fromDir, toDir, textFiles );
+        String textFiles = m_Context.getProperty( "prepare.filtered.files" );
         
+        copy( fromDir, toDir, textFiles, "", true );
+        copy( fromDir, toDir, "**/*", textFiles, false );
     }
     
-    private void copyWithFilter( File fromDir, File toDir, String textFiles )
+    public void copy( File fromDir, File toDir, String includes, String excludes, boolean filtering )
     {
         FileSet from = new FileSet();
         from.setDir( fromDir );
-        from.setIncludes( textFiles );
-
-        /* Copy with filtering */    
+        from.setIncludes( includes );
+        from.setExcludes( excludes );
+        toDir.mkdirs();  /* ensure that the directory exists. */
+        
         Copy copy = (Copy) m_Project.createTask( "copy" );
-        FilterSet fs = copy.createFilterSet();
-        Iterator list = m_Context.getPropertyKeys();
-        while( list.hasNext() )
+        if( filtering )
         {
-            String key = (String) list.next();
-            String value = m_Context.getProperty( key );
-            fs.addFilter( key.toUpperCase(), value );
+            FilterSet fs = copy.createFilterSet();
+            configureFilterSet( fs );
+            copy.setFiltering( true );
+        }
+        else
+        {
+            copy.setFiltering( false );
         }
         copy.setTodir( toDir );
-        copy.setFiltering( true );
         copy.addFileset( from );
-        copy.init();
         copy.execute();
     }
-    
-    private void copyWithOutFilter( File fromDir, File toDir, String textFiles )
+
+    private void configureFilterSet( FilterSet fs )
     {
-        FileSet from = new FileSet();
-        from.setDir( fromDir );
-        from.setIncludes( "**/*" );
-        from.setExcludes( textFiles );
-        
-        /* Copy without filtering */    
-        Copy copy = (Copy) m_Project.createTask( "copy" );
-        copy.setTodir( toDir );
-        copy.addFileset( from );
-        copy.setFiltering( false );
-        copy.init();
-        copy.execute();
+        fs.setBeginToken( "@" );
+        fs.setEndToken( "@" );
+        Iterator list = m_Context.getPropertyKeys();
+        while( list.hasNext() )
+        {
+            String key = (String) list.next();
+            String value = m_Context.getProperty( key );
+            key = key.toUpperCase();
+            fs.addFilter( key, value );
+        }
     }
 }   

Modified: avalon/trunk/tools/magic/xdoc/src/dist/magic.bsh
==============================================================================
--- avalon/trunk/tools/magic/xdoc/src/dist/magic.bsh	(original)
+++ avalon/trunk/tools/magic/xdoc/src/dist/magic.bsh	Mon May 31 08:07:34 2004
@@ -19,6 +19,8 @@
 import java.io.File;
 import java.io.FileFilter;
 
+import java.util.Iterator;
+
 import javax.xml.parsers.SAXParser;
 import javax.xml.parsers.SAXParserFactory;
 import javax.xml.parsers.ParserConfigurationException;
@@ -50,18 +52,23 @@
 public class XDocPlugin extends AbstractPlugin
     implements Serviceable
 {
+    private Object m_PreparePlugin;
+    
     private File m_BaseToDir;    
     private File m_BaseSrcDir;    
     
     public void service( ServiceManager man )
         throws ServiceException
     {
-        Object preparePlugin = man.lookup( "prepare" );
+        m_PreparePlugin = man.lookup( "prepare" );
     }
     
     public void generate()
         throws BuildException
     {
+        PreparePlugin prepare = (PreparePlugin) m_PreparePlugin;
+        prepare.init();
+        
         getLogger().info( "Start XDoc generation." );
         
         File srcDir = new File( m_Context.getProperty( "xdoc.src.dir" ) );
@@ -85,7 +92,6 @@
         
         try
         {
-            copySources();
             transformNavigation( themeDir );
             transformXdocs( themeDir );
             
@@ -114,15 +120,6 @@
         transformTrax( fromDir, toDir, xslFile, "^.*" + sep + "navigation.xml$", "", ".xml", "xml" );
     }
     
-    private void copySources()
-    {
-        File toDir = new File( m_Context.getProperty( "xdoc.build.src.dir" ) );
-        toDir.mkdirs();
-        String srcDir = m_Context.getProperty( "xdoc.src.dir" );
-        File fromDir = new File( srcDir );
-        copy( fromDir, toDir, "**/*", "**/navigation.xml" );
-    }
-    
     private void transformXdocs( File themeDir )
         throws BuildException
     {
@@ -139,21 +136,9 @@
     private void copyResources( File fromDir )
     {
         File destDir = new File( m_Context.getProperty( "xdoc.dest.dir" ) );
-        copy( fromDir, destDir, "**/*", "" );
-    }
-    
-    private void copy( File fromDir, File toDir, String includes, String excludes )
-    {
-        FileSet from = new FileSet();
-        from.setDir( fromDir );
-        from.setIncludes( includes );
-        from.setExcludes( excludes );
-        toDir.mkdirs();  /* ensure that the directory exists. */
+        PreparePlugin prepare = (PreparePlugin) m_PreparePlugin;
         
-        Copy copy = (Copy) m_Project.createTask( "copy" );
-        copy.setTodir( toDir );
-        copy.addFileset( from );
-        copy.execute();
+        prepare.copy( fromDir, destDir, "**/*", "", false );
     }
     
     private void transformTrax( File srcDir, File toDir, File xslFile, 
@@ -199,8 +184,8 @@
             }
             if( content[i].isFile() )
             {
-                String svnRoot = m_Context.getProperty( "xdoc.svn.root.xdocs" );
-                String svnSource = svnRoot + getRelSrcPath( srcDir ) + "/" + base;
+                String publicRoot = m_Context.getProperty( "xdoc.public.root.xdocs" );
+                String publicSource = publicRoot + getRelSrcPath( srcDir ) + "/" + base;
                 
                 int pos = base.lastIndexOf( '.' );
                 if( pos > 0 )
@@ -216,8 +201,9 @@
                 transformer.setParameter( "directory", getRelToPath( toDir ) );
                 transformer.setParameter( "fullpath", getRelToPath( newDest ) );
                 transformer.setParameter( "file", base );
-                transformer.setParameter( "svn-location", svnSource );
-                transformer.setParameter( "copyright", m_Context.getProperty( "xdoc.footer.copyright" ).trim() );
+                transformer.setParameter( "public-location", publicSource );
+                transformer.setParameter( "copyright", m_Context.getProperty( "xdoc.footer.copyright.text" ).trim() );
+                transformer.setParameter( "copyright_url", m_Context.getProperty( "xdoc.footer.copyright.url" ).trim() );
                 transformer.setParameter( "logoright_file", m_Context.getProperty( "xdoc.logo.right.file" ).trim() );
                 transformer.setParameter( "logoright_url", m_Context.getProperty( "xdoc.logo.right.url" ).trim() );
                 transformer.setParameter( "logoleft_file", m_Context.getProperty( "xdoc.logo.left.file" ).trim() );
@@ -255,4 +241,5 @@
         String curdir = dir.getAbsolutePath();
         return curdir.substring( basedir.length() );
     }
+    
 } 

Modified: avalon/trunk/tools/magic/xdoc/src/dist/magic.properties
==============================================================================
--- avalon/trunk/tools/magic/xdoc/src/dist/magic.properties	(original)
+++ avalon/trunk/tools/magic/xdoc/src/dist/magic.properties	Mon May 31 08:07:34 2004
@@ -1,11 +1,11 @@
        
-xdoc.src.dir = src/xdocs
+xdoc.src.dir = ${prepare.src.dir}/xdocs
 
-xdoc.build.src.dir = target/src/xdocs
+xdoc.build.src.dir = ${prepare.build.src.dir}/xdocs
 
-xdoc.dest.dir = target/docs
+xdoc.dest.dir = ${prepare.dest.dir}/docs
 
-xdoc.resources.dir = src/resources/
+xdoc.resources.dir = ${prepare.src.dir}/resources/
 
 xdoc.theme.name = avalon2
  
@@ -17,7 +17,8 @@
 
 xdoc.svn.root.xdocs = https://svn.apache.org/repos/asf/avalon/trunk/central/site/src/xdocs
 
-xdoc.footer.copyright = Copyright ${magic.year}, The Apache Software Foundation. All rights reserved.
+xdoc.footer.copyright.text = Copyright ${magic.year}, The Apache Software Foundation. All rights reserved.
+xdoc.footer.copyright.url = http://www.apache.org/
 
 xdoc.logo.left.file = images/feather.jpg
 xdoc.logo.left.url = 
@@ -28,4 +29,4 @@
 xdoc.logo.middle.file = 
 xdoc.logo.middle.url = 
 
-xdoc.brand.name = Apache Avalon 
\ No newline at end of file
+xdoc.brand.name = Apache Avalon 

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