avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nic...@apache.org
Subject svn commit: rev 20214 - in avalon/trunk/tools/magic: . artifact/src/dist engine/src/dist/plugins/plugin engine/src/java/org/apache/merlin/magic jar/src/dist java/src/dist prepare/src/dist xdoc/src/dist
Date Sat, 22 May 2004 15:14:11 GMT
Author: niclas
Date: Sat May 22 08:14:10 2004
New Revision: 20214

Added:
   avalon/trunk/tools/magic/build.sequence
Removed:
   avalon/trunk/tools/magic/build2.bsh
Modified:
   avalon/trunk/tools/magic/artifact/src/dist/build.bsh
   avalon/trunk/tools/magic/build.bsh
   avalon/trunk/tools/magic/engine/src/dist/plugins/plugin/build.bsh
   avalon/trunk/tools/magic/engine/src/java/org/apache/merlin/magic/Builder.java
   avalon/trunk/tools/magic/engine/src/java/org/apache/merlin/magic/PluginContext.java
   avalon/trunk/tools/magic/engine/src/java/org/apache/merlin/magic/PluginServiceManager.java
   avalon/trunk/tools/magic/jar/src/dist/build.bsh
   avalon/trunk/tools/magic/java/src/dist/build.bsh
   avalon/trunk/tools/magic/prepare/src/dist/build.bsh
   avalon/trunk/tools/magic/prepare/src/dist/build.properties
   avalon/trunk/tools/magic/xdoc/src/dist/build.bsh
Log:
A bunches of changes in the direction forward. Getting close to something really operational.

Modified: avalon/trunk/tools/magic/artifact/src/dist/build.bsh
==============================================================================
--- avalon/trunk/tools/magic/artifact/src/dist/build.bsh	(original)
+++ avalon/trunk/tools/magic/artifact/src/dist/build.bsh	Sat May 22 08:14:10 2004
@@ -4,47 +4,59 @@
 import java.io.File;
 import java.io.FileOutputStream;
 import java.io.InputStream;
+import java.io.IOException;
 
+import java.net.MalformedURLException;
 import java.net.URL;
+import java.net.URLClassLoader;
+import java.net.URLConnection;
 
 import java.util.ArrayList;
 import java.util.Iterator;
 
+import org.apache.merlin.magic.AbstractPlugin;
 import org.apache.merlin.magic.Artifact;
 import org.apache.merlin.magic.Plugin;
-import org.apache.merlin.magic.PluginContext;
-
-import org.apache.avalon.framework.context.Context;
-import org.apache.avalon.framework.context.Contextualizable;
-
-import org.apache.avalon.framework.logger.AbstractLogEnabled;
 
 import org.apache.tools.ant.Project;
 import org.apache.tools.ant.types.Path;
 
-public class ArtifactPlugin extends AbstractLogEnabled
-    implements Plugin, Contextualizable
+public class ArtifactPlugin extends AbstractPlugin
 {
-    private PluginContext m_PluginContext;
-    
-    private Project m_Project;
-    
-    private ArrayList m_CompileListeners;
-    
-    private boolean m_Compiled = false;
-        
-    public void contextualize( Context ctx )
-    {
-        m_PluginContext = (PluginContext) ctx;
-        m_Project = m_PluginContext.getAntProject();
-    }
-
-    public ClassLoader getClassloader( Artifact[] dependencies )
+    public ClassLoader getClassloader( Artifact[] artifacts )
+        throws IOException
     {
+        URL[] jars = new URL[ artifacts.length ];
+        for( int i=0 ; i < artifacts.length ; i++ )
+        {
+            File localFile = toLocalFile( artifacts[i] );
+            if( ! localFile.exists() )
+            {
+                localFile.getParentFile().mkdirs();
+                download( artifacts[i], localFile );
+            }
+            jars[i] = localFile.toURL();
+        }
+        URLClassLoader classloader = new URLClassLoader( jars );
+        return classloader;        
     }
     
-    public Path getClassPath( Artifact[] dependencies )
+    public Path getClassPath( Artifact[] artifacts )
+        throws IOException
     {
+        Path result = new Path( m_Project );
+        for( int i=0 ; i < artifacts.length ; i++ )
+        {
+            File localFile = toLocalFile( artifacts[i] );
+            if( ! localFile.exists() )
+            {
+                localFile.getParentFile().mkdirs();
+                download( artifacts[i], localFile );
+            }
+            Path.PathElement pe = result.createPathElement();
+            pe.setLocation( localFile );
+        }
+        return result;
     }
     
     public void upload( Artifact artifact )
@@ -56,15 +68,17 @@
     {
         FileOutputStream out = null;
         BufferedOutputStream bos = null;
+        InputStream in = null;
+        BufferedInputStream bis = null;
         try
         {
             out = new FileOutputStream( dest );
             bos = new BufferedOutputStream( out );
-            URL url = toRemoteFile( artifact );
-            Connection conn = url.openConnection();
+            URL url = toRemoteURL( artifact );
+            URLConnection conn = url.openConnection();
             conn.connect();
-            InputStream in = conn.getInputStream();
-            BufferedInputStream bis = new BufferedInputStream( in );
+            in = conn.getInputStream();
+            bis = new BufferedInputStream( in );
             int b;
             while( ( b = bis.read() ) != -1 )
             {
@@ -96,11 +110,12 @@
     
     private File toLocalFile( Artifact artifact )
     {
-        String href = m_PluginContext.getProperty( "artifact.local.repository.dir" ) + "/"
+ 
+        String href = m_Context.getProperty( "artifact.local.repository.dir" ) + "/" + 
                       artifact.getGroupId() + "/" +
                       artifact.getType() + "s/" +
                       artifact.getArtifactId() + "-" +
                       artifact.getVersion()  + ".jar" ;
-        return new URL( href );
+        return new File( href );
     }
-}   
+}
+   

Modified: avalon/trunk/tools/magic/build.bsh
==============================================================================
--- avalon/trunk/tools/magic/build.bsh	(original)
+++ avalon/trunk/tools/magic/build.bsh	Sat May 22 08:14:10 2004
@@ -1,4 +1,12 @@
 
+import java.io.File;
+import java.io.FileReader;
+import java.io.BufferedReader;
+import java.io.IOException;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+
 import org.apache.merlin.magic.Plugin;
 import org.apache.merlin.magic.Builder;
 import org.apache.merlin.magic.PluginContext;
@@ -18,38 +26,55 @@
         m_Context = (PluginContext) context;
     }
 
+    private Iterator readBuildSequence()
+        throws IOException
+    {
+        ArrayList result = new ArrayList();
+        FileReader reader = null;
+        BufferedReader br = null;
+        try
+        {
+            File projectDir = m_Context.getProjectDir();
+            File file = new File( projectDir, "build.sequence" );
+            reader = new FileReader( file );
+            br = new BufferedReader( reader );
+            String line;
+            while( (line = br.readLine() ) != null )
+            {
+                result.add( line );
+            }
+            System.out.println( "RETURNING!!!!" );
+        } finally
+        {
+            if( reader != null )
+                reader.close();
+            if( br != null )
+                br.close();
+        }
+        Iterator value = result.iterator();
+        return value;
+    }
+
     public void build()
+        throws IOException
     {
         String[] methods = new String[] { "plugin.install" };
         
         File projectDir = m_Context.getProjectDir();
-        File[] plugins = projectDir.listFiles();
-        for( int i=0 ; i < plugins.length ; i++ )
+        Iterator projects = readBuildSequence();
+        while( projects.hasNext() )
         {
-            if( ! plugins[i].isDirectory() )
-                continue;
-            /* skip engine itself */
-            if( plugins[i].getName().equals( "engine" ) )
-                continue;
-            
-            File f = new File( plugins[i], "build.properties" );
-            if( ! f.exists() )
-                continue;
-            
-            File f = new File( plugins[i], "src/dist/build.bsh" );
-            if( ! f.exists() )
-                continue;
-                
-            Builder builder = new Builder( methods, plugins[i].getAbsoluteFile() );
+            String project = (String) projects.next();
+            File dir = new File( projectDir, project );
+            Builder builder = new Builder( methods, dir.getAbsoluteFile() );
             try
             {
                 builder.execute();
             } catch( Exception e )
             {
-                getLogger().error( "Niclas!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
);
                 e.printStackTrace();
-                getLogger().error( "Hedhman!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
);
             }
         }
     }
-}
\ No newline at end of file
+    
+}

Added: avalon/trunk/tools/magic/build.sequence
==============================================================================
--- (empty file)
+++ avalon/trunk/tools/magic/build.sequence	Sat May 22 08:14:10 2004
@@ -0,0 +1,6 @@
+
+prepare
+xdoc
+artifact
+java
+jar

Modified: avalon/trunk/tools/magic/engine/src/dist/plugins/plugin/build.bsh
==============================================================================
--- avalon/trunk/tools/magic/engine/src/dist/plugins/plugin/build.bsh	(original)
+++ avalon/trunk/tools/magic/engine/src/dist/plugins/plugin/build.bsh	Sat May 22 08:14:10
2004
@@ -32,27 +32,6 @@
         m_ServiceManager = (PluginServiceManager) man;
     }
     
-    public void install()
-    {
-        validate();
-        notifyPreMethod( "install" );
-        
-        getLogger().info( "Installing plugin: " + m_Context.getProjectName() );
-
-        String projectName = m_Context.getProjectName();
-        File systemDir = m_Context.getSystemDir();
-        File localpluginrepo = new File( systemDir, "plugins/" + projectName );
-        File srcDir = new File( m_Context.getProjectDir(), "src/dist" );
-        FileSet src = new FileSet();
-        src.setDir( srcDir );
-        Copy copy = m_Project.createTask( "copy" );
-        copy.setVerbose( true );
-        copy.setTodir( localpluginrepo );
-        copy.addFileset( src );
-        copy.execute();        
-        notifyPostMethod( "install" );
-    }
-
     public void loadAll()
         throws ServiceException
     {
@@ -126,4 +105,25 @@
         notifyPostMethod( "validate" );
     }
     
+    public void install()
+    {
+        validate();
+        notifyPreMethod( "install" );
+        
+        getLogger().info( "Installing plugin: " + m_Context.getProjectName() );
+
+        String projectName = m_Context.getProjectName();
+        File systemDir = m_Context.getSystemDir();
+        File localpluginrepo = new File( systemDir, "plugins/" + projectName );
+        File srcDir = new File( m_Context.getProjectDir(), "src/dist" );
+        FileSet src = new FileSet();
+        src.setDir( srcDir );
+        Copy copy = m_Project.createTask( "copy" );
+        copy.setVerbose( true );
+        copy.setTodir( localpluginrepo );
+        copy.addFileset( src );
+        copy.execute();        
+        notifyPostMethod( "install" );
+    }
+
 }

Modified: avalon/trunk/tools/magic/engine/src/java/org/apache/merlin/magic/Builder.java
==============================================================================
--- avalon/trunk/tools/magic/engine/src/java/org/apache/merlin/magic/Builder.java	(original)
+++ avalon/trunk/tools/magic/engine/src/java/org/apache/merlin/magic/Builder.java	Sat May
22 08:14:10 2004
@@ -11,6 +11,8 @@
 import org.apache.avalon.framework.logger.Logger;
 import org.apache.avalon.framework.service.ServiceException;
 
+import org.apache.tools.ant.Project;
+
 public class Builder
 {
     private Logger   m_Logger;
@@ -20,6 +22,7 @@
     private File     m_ProjectDir;
     private File     m_PluginsDir;
     private File     m_TempDir;
+    private Project  m_AntProject;
     
     public Builder( String[] methods, File projectDir )
     {
@@ -56,11 +59,13 @@
         loadUserSystemProperties( props );
         loadUserHomeProperties( props );
         
+        m_AntProject = initializeAntProject( props );
+        
         FacadeFactory factory = new FacadeFactory();
         if( factory instanceof LogEnabled )
             ((LogEnabled) factory).enableLogging( m_Logger );
             
-        PluginServiceManager sm = new PluginServiceManager( factory, props );
+        PluginServiceManager sm = new PluginServiceManager( factory, props, m_AntProject
);
         sm.enableLogging( m_Logger );
         
         for( int i=0 ; i < m_CallMethods.length ; i++ )
@@ -205,5 +210,16 @@
         File systemDir = new File( system );
         return systemDir;
     }
+
+    private Project initializeAntProject( PluginProperties props )
+    {
+        Project antProject = new Project();
+        antProject.setBaseDir( m_ProjectDir );
+        antProject.setCoreLoader( this.getClass().getClassLoader() );
+        antProject.setName( props.getProperty( "project.name" ) );
+        antProject.init();
+        return antProject;
+    }
+        
 } 
  

Modified: avalon/trunk/tools/magic/engine/src/java/org/apache/merlin/magic/PluginContext.java
==============================================================================
--- avalon/trunk/tools/magic/engine/src/java/org/apache/merlin/magic/PluginContext.java	(original)
+++ avalon/trunk/tools/magic/engine/src/java/org/apache/merlin/magic/PluginContext.java	Sat
May 22 08:14:10 2004
@@ -1,6 +1,7 @@
 package org.apache.merlin.magic;
 
 import java.io.File;
+import java.util.Iterator;
 import java.util.Stack;
 import java.util.StringTokenizer;
 
@@ -29,33 +30,42 @@
     PluginContext( File scriptDir )
     {
         this( "virtual", new File( "." ), new PluginProperties(), "virtual plugin", 
-              scriptDir, new File( "." ), new File( "." ) );
+              scriptDir, new File( "." ), new File( "." ), new Project() );
     }
     
-    PluginContext( String projectname, File projectDir, PluginProperties projectProps,
-                   String pluginname, File pluginDir, File systemDir, File tempDir )
-    {
-        m_ProjectName = projectname.trim();
+    PluginContext( String projectName, File projectDir, PluginProperties projectProps,
+                   String pluginName, File pluginDir, File systemDir, File tempDir,
+                   Project ant )
+    {
+        if( projectName == null )
+            throw new IllegalArgumentException( "Null argument: projectName" );
+        if( projectDir == null )
+            throw new IllegalArgumentException( "Null argument: projectDir" );
+        if( projectProps == null )
+            throw new IllegalArgumentException( "Null argument: projectProps" );
+        if( pluginName == null )
+            throw new IllegalArgumentException( "Null argument: pluginName" );
+        if( pluginDir == null )
+            throw new IllegalArgumentException( "Null argument: pluginDir" );
+        if( systemDir == null )
+            throw new IllegalArgumentException( "Null argument: systemDir" );
+        if( tempDir == null )
+            throw new IllegalArgumentException( "Null argument: tempDir" );
+        if( ant == null )
+            throw new IllegalArgumentException( "Null argument: ant" );
+            
+        m_ProjectName = projectName.trim();
         m_ProjectDir = projectDir;
         m_ProjectProperties = projectProps;
         
         m_PluginDir = pluginDir;
-        m_PluginName = pluginname.trim();
+        m_PluginName = pluginName.trim();
         
         m_SystemDir = systemDir;
         m_TempDir = tempDir;
-        initializeAntProject();
+        m_AntProject = ant;
     }
 
-    private void initializeAntProject()
-    {
-        m_AntProject = new Project();
-        m_AntProject.setBaseDir( m_ProjectDir );
-        m_AntProject.setCoreLoader( this.getClass().getClassLoader() );
-        m_AntProject.setName( m_ProjectName );
-        m_AntProject.init();
-    }
-        
     public Object get( Object entry )
     {
         if( !( entry instanceof String ))
@@ -128,6 +138,11 @@
     {
         String value = m_ProjectProperties.getProperty( name );
         return value;
+    }
+    
+    public Iterator getPropertyKeys()
+    {
+        return m_ProjectProperties.keySet().iterator();
     }
     
     public Project getAntProject()

Modified: avalon/trunk/tools/magic/engine/src/java/org/apache/merlin/magic/PluginServiceManager.java
==============================================================================
--- avalon/trunk/tools/magic/engine/src/java/org/apache/merlin/magic/PluginServiceManager.java
(original)
+++ avalon/trunk/tools/magic/engine/src/java/org/apache/merlin/magic/PluginServiceManager.java
Sat May 22 08:14:10 2004
@@ -14,6 +14,8 @@
 import org.apache.avalon.framework.service.ServiceManager;
 import org.apache.avalon.framework.service.Serviceable;
 
+import org.apache.tools.ant.Project;
+
 public class PluginServiceManager extends AbstractLogEnabled
     implements ServiceManager
 {
@@ -29,18 +31,27 @@
 
     private PluginProperties m_GlobalProperties;
     private FacadeFactory m_FacadeFactory;
-
-    PluginServiceManager( FacadeFactory factory, PluginProperties globalprops )
+    private Project m_AntProject;
+    
+    PluginServiceManager( FacadeFactory factory, PluginProperties globalProps, Project ant
)
     {
+        if( factory == null )
+            throw new IllegalArgumentException( "Null argument: factory" );
+        if( globalProps == null )
+            throw new IllegalArgumentException( "Null argument: globalProps" );
+        if( ant == null )
+            throw new IllegalArgumentException( "Null argument: ant" );
+            
         DUMMY = new Object();
         m_FacadeFactory = factory;
         
         m_PluginsByKey = new HashMap();
         m_PluginsByValue = new HashMap();
-        m_SystemDir = new File( globalprops.getProperty( "magic.home.dir" ) );
-        m_LocalPlugins = new File( globalprops.getProperty( "magic.plugins.dir" ) );;
-        m_ProjectDir = new File( globalprops.getProperty( "magic.project.dir" ) );;
-        m_TempDir = new File( globalprops.getProperty( "magic.temp.dir" ) );;
+        m_SystemDir = new File( globalProps.getProperty( "magic.home.dir" ) );
+        m_LocalPlugins = new File( globalProps.getProperty( "magic.plugins.dir" ) );;
+        m_ProjectDir = new File( globalProps.getProperty( "magic.project.dir" ) );;
+        m_TempDir = new File( globalProps.getProperty( "magic.temp.dir" ) );;
+        m_AntProject = ant;
     }
         
     public Object lookup( String service )
@@ -160,7 +171,7 @@
         String projectName = props.getProperty( "project.name" );
         
         PluginContext ctx = new PluginContext( projectName, m_ProjectDir, 
-            props, service, pluginDir, m_SystemDir, m_TempDir );
+            props, service, pluginDir, m_SystemDir, m_TempDir, m_AntProject );
         
         try
         {

Modified: avalon/trunk/tools/magic/jar/src/dist/build.bsh
==============================================================================
--- avalon/trunk/tools/magic/jar/src/dist/build.bsh	(original)
+++ avalon/trunk/tools/magic/jar/src/dist/build.bsh	Sat May 22 08:14:10 2004
@@ -22,12 +22,14 @@
     implements Serviceable
 {
     private Object m_JavaPlugin;
+    private Object m_PreparePlugin;
     private boolean m_Jarred = false;
         
     public void service( ServiceManager man )
         throws ServiceException
     {
         m_JavaPlugin = man.lookup( "java" );
+        m_PreparePlugin = man.lookup( "prepare" );
     }
     
     public void jar()

Modified: avalon/trunk/tools/magic/java/src/dist/build.bsh
==============================================================================
--- avalon/trunk/tools/magic/java/src/dist/build.bsh	(original)
+++ avalon/trunk/tools/magic/java/src/dist/build.bsh	Sat May 22 08:14:10 2004
@@ -8,11 +8,12 @@
 import org.apache.merlin.magic.Plugin;
 import org.apache.merlin.magic.PluginContext;
 
-import org.apache.avalon.framework.context.Context;
-import org.apache.avalon.framework.context.Contextualizable;
-
 import org.apache.avalon.framework.logger.AbstractLogEnabled;
 
+import org.apache.avalon.framework.service.Serviceable;
+import org.apache.avalon.framework.service.ServiceException;
+import org.apache.avalon.framework.service.ServiceManager;
+
 import org.apache.tools.ant.Project;
 import org.apache.tools.ant.types.FileSet;
 import org.apache.tools.ant.types.Path;
@@ -20,16 +21,23 @@
 import org.apache.tools.ant.taskdefs.Javac;
 
 public class JavacPlugin extends AbstractPlugin
-    implements Plugin, Contextualizable
+    implements Serviceable
 {
-    private Project m_Project;
-    
+    private Object m_PreparePlugin;
     private boolean m_Compiled = false;
         
+    public void service( ServiceManager man )
+        throws ServiceException
+    {
+        m_PreparePlugin = man.lookup( "prepare" );
+    }
+    
     public void compile()
     {   
         if( m_Compiled )
             return;
+        PreparePlugin prepare = (PreparePlugin) m_PreparePlugin;
+        prepare.init();
         notifyPreMethod( "compile" );
         copySources();
         notifyStep( "compile", "sources-copied" );

Modified: avalon/trunk/tools/magic/prepare/src/dist/build.bsh
==============================================================================
--- avalon/trunk/tools/magic/prepare/src/dist/build.bsh	(original)
+++ avalon/trunk/tools/magic/prepare/src/dist/build.bsh	Sat May 22 08:14:10 2004
@@ -15,12 +15,12 @@
 
 import org.apache.tools.ant.Project;
 import org.apache.tools.ant.types.FileSet;
+import org.apache.tools.ant.types.FilterSet;
 import org.apache.tools.ant.types.Path;
 import org.apache.tools.ant.taskdefs.Copy;
 import org.apache.tools.ant.taskdefs.Javac;
 
-public class JavacPlugin extends AbstractPlugin
-    implements Plugin, Contextualizable
+public class PreparePlugin extends AbstractPlugin
 {
     private Project m_Project;
     
@@ -43,35 +43,48 @@
         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 );
+        copyWithFilter( fromDir, toDir, textFiles );
+        copyWithOutFilter( fromDir, toDir, textFiles );
         
     }
     
-    private void copyWithFilter( File fromDir, File toDir )
+    private void copyWithFilter( File fromDir, File toDir, String textFiles )
     {
         FileSet from = new FileSet();
         from.setDir( fromDir );
-        from.setIncludes( "**/*" );
+        from.setIncludes( textFiles );
 
         /* Copy with filtering */    
         Copy copy = (Copy) m_Project.createTask( "copy" );
+        FilterSet fs = copy.createFilterSet();
+        Iterator list = m_Context.getPropertyKeys();
+        while( list.hasNext() )
+        {
+            String key = (String) list.next();
+            String value = m_Context.getProperty( key );
+            fs.addFilter( key.toUpperCase(), value );
+        }
         copy.setTodir( toDir );
+        copy.setFiltering( true );
         copy.addFileset( from );
         copy.init();
         copy.execute();
     }
     
-    private void copyWithOutFilter( File fromDir, File toDir )
+    private void copyWithOutFilter( File fromDir, File toDir, String textFiles )
     {
         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();
     }

Modified: avalon/trunk/tools/magic/prepare/src/dist/build.properties
==============================================================================
--- avalon/trunk/tools/magic/prepare/src/dist/build.properties	(original)
+++ avalon/trunk/tools/magic/prepare/src/dist/build.properties	Sat May 22 08:14:10 2004
@@ -4,3 +4,5 @@
 prepare.dest.dir = target/
 
 prepare.build.src.dir = ${prepare.dest.dir}/src/
+
+prepare.filtered.files= **/*.xml, **/*.java, **/*.html, **/*.sh, **/*.bat, **/*.prop*
\ No newline at end of file

Modified: avalon/trunk/tools/magic/xdoc/src/dist/build.bsh
==============================================================================
--- avalon/trunk/tools/magic/xdoc/src/dist/build.bsh	(original)
+++ avalon/trunk/tools/magic/xdoc/src/dist/build.bsh	Sat May 22 08:14:10 2004
@@ -1,10 +1,7 @@
-import java.io.File;
-
-import org.apache.avalon.framework.context.Context;
-import org.apache.avalon.framework.context.Contextualizable;
 
-import org.apache.avalon.framework.logger.AbstractLogEnabled;
+import java.io.File;
 
+import org.apache.merlin.magic.AbstractPlugin;
 import org.apache.merlin.magic.Plugin;
 import org.apache.merlin.magic.PluginContext;
 
@@ -13,34 +10,24 @@
 import org.apache.tools.ant.taskdefs.Copy;
 import org.apache.tools.ant.taskdefs.XSLTProcess;
 
-public class XDocPlugin extends AbstractLogEnabled
-    implements Contextualizable, Plugin
+public class XDocPlugin extends AbstractPlugin
 {
-    private PluginContext m_PluginContext;
-    
-    private Project m_Project;
-        
-    public void contextualize( Context ctx )
-    {
-        m_PluginContext = (PluginContext) ctx;
-        m_Project = m_PluginContext.getAntProject();
-    }
     
     public void generate()
     {
         getLogger().info( "Start XDoc generation." );
         
-        File srcDir = new File( m_PluginContext.getProperty( "xdoc.src.dir" ) );
+        File srcDir = new File( m_Context.getProperty( "xdoc.src.dir" ) );
         if( ! srcDir.exists() )
         {
             getLogger().warn( "Xdocs source directory does not exist:" + srcDir );
             return;
         }
-        File destDir = new File( m_PluginContext.getProperty( "xdoc.build.src.dir" ) );
+        File destDir = new File( m_Context.getProperty( "xdoc.build.src.dir" ) );
 
-        String theme = m_PluginContext.getProperty( "xdoc.theme.name" );
-        String output = m_PluginContext.getProperty( "xdoc.output.format" );
-        File themeDir = new File( m_PluginContext.getPluginDir(), "themes/" + theme + "/"
+ output );
+        String theme = m_Context.getProperty( "xdoc.theme.name" );
+        String output = m_Context.getProperty( "xdoc.output.format" );
+        File themeDir = new File( m_Context.getPluginDir(), "themes/" + theme + "/" + output
);
         
         getLogger().info( "   Source: " + srcDir.getAbsolutePath() );
         getLogger().info( "     Dest: " + destDir.getAbsolutePath() );
@@ -63,16 +50,16 @@
     private void transformNavigation( File themeDir )
     {
         File xslFile = new File( themeDir,  "nav-aggregate.xsl" );
-        String srcDir = m_PluginContext.getProperty( "xdoc.src.dir" );
+        String srcDir = m_Context.getProperty( "xdoc.src.dir" );
         File fromDir = new File( srcDir );
-        File toDir = new File( m_PluginContext.getProperty( "xdoc.build.src.dir" ) );
+        File toDir = new File( m_Context.getProperty( "xdoc.build.src.dir" ) );
         transform( fromDir, toDir, xslFile, "**/navigation.xml", "", ".xml", "xml" );
     }
     
     private void copySources()
     {
-        File toDir = new File( m_PluginContext.getProperty( "xdoc.build.src.dir" ) );
-        String srcDir = m_PluginContext.getProperty( "xdoc.src.dir" );
+        File toDir = new File( m_Context.getProperty( "xdoc.build.src.dir" ) );
+        String srcDir = m_Context.getProperty( "xdoc.src.dir" );
         File fromDir = new File( srcDir );
         copy( fromDir, toDir, "**/*", "**/navigation.xml" );
     }
@@ -80,16 +67,16 @@
     private void transformXdocs( File themeDir )
     {
         File xslFile = new File( themeDir,  "transform.xsl" );
-        String srcDir = m_PluginContext.getProperty( "xdoc.build.src.dir" );
+        String srcDir = m_Context.getProperty( "xdoc.build.src.dir" );
         File fromDir = new File( srcDir );
-        File toDir = new File( m_PluginContext.getProperty( "xdoc.dest.dir" ) );
-        String output = m_PluginContext.getProperty( "xdoc.output.format" );
+        File toDir = new File( m_Context.getProperty( "xdoc.dest.dir" ) );
+        String output = m_Context.getProperty( "xdoc.output.format" );
         transform( fromDir, toDir, xslFile, "**/*.xml", "**/navigation.xml", "." + output,
"html" );
     }
     
     private void copyResources( File themeDir )
     {
-        File destDir = new File( m_PluginContext.getProperty( "xdoc.dest.dir" ) );
+        File destDir = new File( m_Context.getProperty( "xdoc.dest.dir" ) );
         File toDir = new File( destDir, "resources" );
         File fromDir = new File( themeDir, "resources" );
         copy( fromDir, toDir, "**/*", "" );

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


Mime
View raw message