avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mcconn...@apache.org
Subject svn commit: rev 20800 - in avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools: home tasks
Date Fri, 04 Jun 2004 02:14:14 GMT
Author: mcconnell
Date: Thu Jun  3 19:14:13 2004
New Revision: 20800

Added:
   avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/tasks/ContextualTask.java
Modified:
   avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/home/Context.java
   avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/tasks/CleanTask.java
   avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/tasks/DeclareTask.java
   avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/tasks/InstallTask.java
   avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/tasks/JUnitTestTask.java
   avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/tasks/JarTask.java
   avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/tasks/JavacTask.java
   avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/tasks/PluginTask.java
   avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/tasks/PrepareTask.java
   avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/tasks/XdocTask.java
Log:
Factor out common context handling into an abstract task.

Modified: avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/home/Context.java
==============================================================================
--- avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/home/Context.java	(original)
+++ avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/home/Context.java	Thu
Jun  3 19:14:13 2004
@@ -57,6 +57,9 @@
     public static final String DELIVERABLES_KEY = "project.target.deliverables";
     private static final String DELIVERABLES_VALUE = "deliverables";
 
+    public static final String BUILD_KEY = "project.target.build";
+    private static final String BUILD_VALUE = "build";
+
     public static final String TEMP_KEY = "project.target.temp";
     private static final String TEMP_VALUE = "temp";
 
@@ -83,6 +86,7 @@
 
     private final File m_src;
     private final File m_target;
+    private final File m_build;
     private final File m_deliverables;
     private final File m_temp;
     private final File m_docs;
@@ -98,14 +102,16 @@
         project.setNewProperty( SRC_MAIN_KEY, SRC_MAIN_VALUE );
         project.setNewProperty( SRC_CONFIG_KEY, SRC_CONFIG_VALUE );
         project.setNewProperty( SRC_TEST_KEY, SRC_TEST_VALUE );
-        project.setNewProperty( DELIVERABLES_KEY, DELIVERABLES_VALUE );
         project.setNewProperty( TARGET_KEY, TARGET_VALUE );
+        project.setNewProperty( BUILD_KEY, BUILD_VALUE );
+        project.setNewProperty( DELIVERABLES_KEY, DELIVERABLES_VALUE );
         project.setNewProperty( DOCS_KEY, DOCS_VALUE );
         project.setNewProperty( TEMP_KEY, TEMP_VALUE );
 
         File basedir = project.getBaseDir();
         String src = project.getProperty( SRC_KEY );
         String target = project.getProperty( TARGET_KEY );
+        String build = project.getProperty( BUILD_KEY );
         String temp = project.getProperty( TEMP_KEY );
         String docs = project.getProperty( DOCS_KEY );
         String deliverables = project.getProperty( DELIVERABLES_KEY );
@@ -132,6 +138,8 @@
             m_home = home;
         }
 
+        m_build = 
+          setBuildPath( BUILD_KEY, build );
         m_deliverables = 
           setBuildPath( DELIVERABLES_KEY, deliverables );
         m_temp = 
@@ -153,6 +161,11 @@
     public File getTargetDirectory()
     {
         return m_target;
+    }
+
+    public File getBuildDirectory()
+    {
+        return m_build;
     }
 
     public File getDeliverablesDirectory()

Modified: avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/tasks/CleanTask.java
==============================================================================
--- avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/tasks/CleanTask.java
(original)
+++ avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/tasks/CleanTask.java
Thu Jun  3 19:14:13 2004
@@ -27,33 +27,24 @@
 import org.apache.avalon.tools.home.Context;
 
 /**
- * Load a goal. 
+ * Clean the project by removing the target directory.
  *
  * @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 CleanTask extends Task
+public class CleanTask extends ContextualTask
 {
-    private Context m_context;
-    private boolean m_init = false;
-
-    public void init() throws BuildException 
+    public void execute() throws BuildException 
     {
-        if( !m_init )
+        File target = getContext().getTargetDirectory();
+        if( target.exists() )
         {
+            log( "removing target directory" );
             Project project = getProject();
-            m_context = Context.getContext( project );
-            m_init = true;
+            Delete delete = (Delete) project.createTask( "delete" );
+            delete.setDir( target );
+            delete.init();
+            delete.execute();
         }
-    }
-
-    public void execute() throws BuildException 
-    {
-        File target = m_context.getTargetDirectory();
-        Project project = getProject();
-        Delete delete = (Delete) project.createTask( "delete" );
-        delete.setDir( target );
-        delete.init();
-        delete.execute();
     }
 }

Added: avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/tasks/ContextualTask.java
==============================================================================
--- (empty file)
+++ avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/tasks/ContextualTask.java
Thu Jun  3 19:14:13 2004
@@ -0,0 +1,82 @@
+/* 
+ * 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.tasks;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.apache.tools.ant.Task;
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.taskdefs.Copy;
+import org.apache.tools.ant.taskdefs.Javac;
+import org.apache.tools.ant.taskdefs.Mkdir;
+import org.apache.tools.ant.taskdefs.optional.junit.FormatterElement;
+import org.apache.tools.ant.taskdefs.optional.junit.JUnitTask;
+import org.apache.tools.ant.taskdefs.optional.junit.BatchTest;
+import org.apache.tools.ant.types.Environment;
+import org.apache.tools.ant.types.FileSet;
+import org.apache.tools.ant.types.Path;
+
+import org.apache.avalon.tools.home.Home;
+import org.apache.avalon.tools.project.Definition;
+import org.apache.avalon.tools.home.Context;
+
+/**
+ * Load a goal. 
+ *
+ * @author <a href="mailto:dev@avalon.apache.org">Avalon Development Team</a>
+ * @version $Revision: 1.2 $ $Date: 2004/03/17 10:30:09 $
+ */
+public abstract class ContextualTask extends Task
+{
+    private boolean m_init = false;
+    private Context m_context;
+
+    public void init() throws BuildException 
+    {
+        if( !isInitialized() )
+        {
+            Project project = getProject();
+            m_context = Context.getContext( project );
+            m_init = true;
+        }
+    }
+
+    public boolean isInitialized()
+    {
+        return m_init;
+    }
+
+    public Context getContext()
+    {
+        if( null == m_context )
+        {
+            throw new IllegalStateException( "context" );
+        }
+        return m_context;
+    }
+
+    public void mkDir( File dir )
+    {
+        Mkdir mkdir = (Mkdir) getProject().createTask( "mkdir" );
+        mkdir.setDir( dir );
+        mkdir.init();
+        mkdir.execute();
+    }
+}

Modified: avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/tasks/DeclareTask.java
==============================================================================
--- avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/tasks/DeclareTask.java
(original)
+++ avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/tasks/DeclareTask.java
Thu Jun  3 19:14:13 2004
@@ -45,12 +45,10 @@
  * @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 DeclareTask extends Task
+public class DeclareTask extends ContextualTask
 {
     private static final String TYPE = "plugin";
 
-    private boolean m_init = false;
-    private Context m_context;
     private Home m_home;
 
    /**
@@ -78,16 +76,6 @@
         }
     }
 
-    public void init() throws BuildException 
-    {
-        if( !m_init )
-        {
-            Project project = getProject();
-            m_context = Context.getContext( project );
-            m_init = true;
-        }
-    }
-
     public void execute() throws BuildException 
     {
         if( null == m_home ) 
@@ -124,7 +112,7 @@
 
     private File getPluginFile()
     {
-        File dir = m_context.getDeliverablesDirectory();
+        File dir = getContext().getDeliverablesDirectory();
         File ants = new File( dir, TYPE + "s" );
         mkDir( ants );
 
@@ -285,13 +273,4 @@
             }
         }
     }
-
-    private void mkDir( File dir )
-    {
-        Mkdir mkdir = (Mkdir) getProject().createTask( "mkdir" );
-        mkdir.setDir( dir );
-        mkdir.init();
-        mkdir.execute();
-    }
-
 }

Modified: avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/tasks/InstallTask.java
==============================================================================
--- avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/tasks/InstallTask.java
(original)
+++ avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/tasks/InstallTask.java
Thu Jun  3 19:14:13 2004
@@ -38,10 +38,8 @@
  * @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 InstallTask extends Task
+public class InstallTask extends ContextualTask
 {
-    private boolean m_init = false;
-    private Context m_context;
     private Home m_home;
 
    /**
@@ -69,19 +67,9 @@
         }
     }
 
-    public void init() throws BuildException 
-    {
-        if( !m_init )
-        {
-            Project project = getProject();
-            m_context = Context.getContext( project );
-            m_init = true;
-        }
-    }
-
     public void execute() throws BuildException 
     {
-        File deliverables = m_context.getDeliverablesDirectory();
+        File deliverables = getContext().getDeliverablesDirectory();
         if( deliverables.exists() )
         {
             install( deliverables );

Modified: avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/tasks/JUnitTestTask.java
==============================================================================
--- avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/tasks/JUnitTestTask.java
(original)
+++ avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/tasks/JUnitTestTask.java
Thu Jun  3 19:14:13 2004
@@ -43,7 +43,7 @@
  * @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 JUnitTestTask extends Task
+public class JUnitTestTask extends ContextualTask
 {
     public static final String TEST_KEY = "project.test";
     public static final String TEST_VALUE = "test";
@@ -63,10 +63,7 @@
     public static final String FORK_KEY = "test.compile.fork";
     public static final boolean FORK_VALUE = false;
 
-    private boolean m_init = false;
-    private Context m_context;
     private File m_test;
-
     private Home m_home;
 
    /**
@@ -96,18 +93,17 @@
 
     public void init() throws BuildException 
     {
-        if( !m_init )
+        if( !isInitialized() )
         {
+            super.init();
             Project project = getProject();
-            m_context = Context.getContext( project );
             project.setNewProperty( DEBUG_KEY, "" + DEBUG_VALUE );
             project.setNewProperty( FORK_KEY, "" + FORK_VALUE );
             project.setNewProperty( TEST_SRC_KEY, "" + TEST_SRC_VALUE );
             project.setNewProperty( TEST_ENV_KEY, "" + TEST_ENV_VALUE );
             project.setNewProperty( TEST_TMP_KEY, "" + TEST_TMP_VALUE );
-            m_context.setBuildPath( TEST_KEY, TEST_VALUE );
-            m_test = m_context.getBuildPath( TEST_KEY );
-            m_init = true;
+            getContext().setBuildPath( TEST_KEY, TEST_VALUE );
+            m_test = getContext().getBuildPath( TEST_KEY );
         }
     }
 
@@ -122,7 +118,8 @@
         }
 
         Project project = getProject();
-        File build = m_context.getBuildPath( PrepareTask.BUILD_SRC_KEY );
+        File build = getContext().getBuildDirectory();
+
         String testPath = project.getProperty( TEST_SRC_KEY );
         File src = new File( build, testPath );
 
@@ -140,7 +137,7 @@
             // target/test-classes directory
             //
 
-            File jar = m_context.getBuildPath( "jar" );
+            File jar = getContext().getBuildPath( "jar" );
             classpath.createPathElement().setLocation( jar );
             compile( src, classes, classpath );
             classpath.createPathElement().setLocation( classes );
@@ -221,14 +218,6 @@
 
         junit.init();
         junit.execute();
-    }
-
-    private void mkDir( File dir )
-    {
-        Mkdir mkdir = (Mkdir) getProject().createTask( "mkdir" );
-        mkdir.setDir( dir );
-        mkdir.init();
-        mkdir.execute();
     }
 
     private boolean getDebugProperty()

Modified: avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/tasks/JarTask.java
==============================================================================
--- avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/tasks/JarTask.java	(original)
+++ avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/tasks/JarTask.java	Thu
Jun  3 19:14:13 2004
@@ -42,15 +42,13 @@
  * @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 JarTask extends Task
+public class JarTask extends ContextualTask
 {
     public static final String MD5_EXT = "md5";
     public static final String JAR_EXT = "jar";
     public static final String ASC_EXT = "asc";
     public static final String GPG_EXE_KEY = "project.gpg.exe";
     
-    private boolean m_init = false;
-    private Context m_context;
     private Home m_home;
 
    /**
@@ -78,16 +76,6 @@
         }
     }
 
-    public void init() throws BuildException 
-    {
-        if( !m_init )
-        {
-            Project project = getProject();
-            m_context = Context.getContext( project );
-            m_init = true;
-        }
-    }
-
     public void execute() throws BuildException 
     {
         if( null == m_home ) 
@@ -99,9 +87,9 @@
         }
 
         File classes = 
-          m_context.getBuildPath( JavacTask.BUILD_CLASSES_KEY );
+          getContext().getBuildPath( JavacTask.BUILD_CLASSES_KEY );
         File deliverables = 
-          m_context.getDeliverablesDirectory();
+          getContext().getDeliverablesDirectory();
 
         File jarFile = getJarFile( deliverables );
         if( classes.exists() )
@@ -117,7 +105,7 @@
                 throw new BuildException( ioe );
             }
         }
-        m_context.setBuildPath( "jar", jarFile.toString() );
+        getContext().setBuildPath( "jar", jarFile.toString() );
     }
 
     public File getJarFile( File deliverables )
@@ -146,11 +134,7 @@
     private boolean jar( File classes, File jarFile )
     {
         File dir = jarFile.getParentFile();
-
-        Mkdir mkdir = (Mkdir) getProject().createTask( "mkdir" );
-        mkdir.setDir( dir );
-        mkdir.init();
-        mkdir.execute();
+        mkDir( dir );
 
         long modified = -1;
         if( jarFile.exists() )

Modified: avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/tasks/JavacTask.java
==============================================================================
--- avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/tasks/JavacTask.java
(original)
+++ avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/tasks/JavacTask.java
Thu Jun  3 19:14:13 2004
@@ -39,7 +39,7 @@
  * @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 JavacTask extends Task
+public class JavacTask extends ContextualTask
 {
     public static final String BUILD_CLASSES_KEY = "classes";
     public static final String BUILD_CLASSES_PATH = "classes";
@@ -50,10 +50,6 @@
     public static final String FORK_KEY = "java.compile.fork";
     public static final boolean FORK_VALUE = false;
 
-    private boolean m_init = false;
-
-    private Context m_context;
-
     private Home m_home;
 
    /**
@@ -83,16 +79,15 @@
 
     public void init() throws BuildException 
     {
-        if( !m_init )
+        if( !isInitialized() )
         {
+            super.init();
             Project project = getProject();
-            m_context = Context.getContext( project );
             project.setNewProperty( DEBUG_KEY, "" + DEBUG_VALUE );
             project.setNewProperty( FORK_KEY, "" + FORK_VALUE );
-            m_context.setBuildPath( 
+            getContext().setBuildPath( 
               BUILD_CLASSES_KEY, 
               BUILD_CLASSES_PATH );
-            m_init = true;
         }
     }
 
@@ -106,17 +101,14 @@
         }
 
         Project project = getProject();
-        File build = m_context.getBuildPath( PrepareTask.BUILD_SRC_KEY, false );
+        File build = getContext().getBuildDirectory();
         String mainPath = project.getProperty( Context.SRC_MAIN_KEY );
         File main = new File( build, mainPath );
 
         if( main.exists() )
         {
-            File classes = m_context.getBuildPath( BUILD_CLASSES_KEY );
-            Mkdir mkdir = (Mkdir) getProject().createTask( "mkdir" );
-            mkdir.setDir( classes );
-            mkdir.init();
-            mkdir.execute();
+            File classes = getContext().getBuildPath( BUILD_CLASSES_KEY );
+            mkDir( classes );
 
             Path classpath = 
               m_home.getRepository().createPath( 

Modified: avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/tasks/PluginTask.java
==============================================================================
--- avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/tasks/PluginTask.java
(original)
+++ avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/tasks/PluginTask.java
Thu Jun  3 19:14:13 2004
@@ -48,13 +48,10 @@
  * @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 PluginTask extends Task
+public class PluginTask extends ContextualTask
 {
     private String m_id;
     private String m_uri;
-
-    private boolean m_init = false;
-    private Context m_context;
     private Home m_home;
 
    /**
@@ -86,16 +83,6 @@
     public void setArtifact( String id )
     {
         m_id = id;
-    }
-
-    public void init() throws BuildException 
-    {
-        if( !m_init )
-        {
-            Project project = getProject();
-            m_context = Context.getContext( project );
-            m_init = true;
-        }
     }
 
     private String getArtifactSpec()

Modified: avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/tasks/PrepareTask.java
==============================================================================
--- avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/tasks/PrepareTask.java
(original)
+++ avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/tasks/PrepareTask.java
Thu Jun  3 19:14:13 2004
@@ -38,19 +38,13 @@
  * @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 PrepareTask extends Task
+public class PrepareTask extends ContextualTask
 {
-
-    public static final String BUILD_SRC_KEY = "src";
-    private static final String BUILD_SRC_PATH = "src";
-
     private static final String SRC_FILTERED_INCLUDES_KEY = 
       "project.prepare.src.filtered.includes";
     private static final String SRC_FILTERED_INCLUDES_VALUE = 
       "**/*.java,**/*.x*,**/*.properties";
 
-    private Context m_context;
-    private boolean m_init = false;
     private File m_home;
 
    /**
@@ -63,34 +57,34 @@
 
     public void init() throws BuildException 
     {
-        if( !m_init )
+        if( !isInitialized() )
         {
+            super.init();
             Project project = getProject();
-            m_context = Context.getContext( project, m_home );
             project.setNewProperty(
               SRC_FILTERED_INCLUDES_KEY, SRC_FILTERED_INCLUDES_VALUE );
-            m_context.setBuildPath( BUILD_SRC_KEY, BUILD_SRC_PATH );
-            m_init = true;
         }
     }
 
     public void execute() throws BuildException 
     {
         Project project = getProject();
-        File target = m_context.getTargetDirectory();
+        File target = getContext().getTargetDirectory();
         if( !target.exists() )
         {
             log( "creating target directory" );
-            Mkdir mkdir = (Mkdir) getProject().createTask( "mkdir" );
-            mkdir.setDir( target );
-            mkdir.init();
-            mkdir.execute();
+            mkDir( target );
+        }
+        File src = getContext().getSrcDirectory();
+        File build = getContext().getBuildDirectory();
+        if( !build.exists() )
+        {
+            log( "creating build directory" );
+            mkDir( build );
         }
-        File src = m_context.getSrcDirectory();
         if( src.exists() )
         {
             String filters = project.getProperty( SRC_FILTERED_INCLUDES_KEY );
-            File build = m_context.getBuildPath( "src" );
             copy( src, build, true, filters, "" );
             copy( src, build, false, "**/*.*", filters );
         }

Modified: avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/tasks/XdocTask.java
==============================================================================
--- avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/tasks/XdocTask.java	(original)
+++ avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/tasks/XdocTask.java	Thu
Jun  3 19:14:13 2004
@@ -28,10 +28,10 @@
 import org.apache.avalon.tools.home.Context;
 import org.apache.avalon.tools.home.Home;
 
-public class XdocTask extends Task
+public class XdocTask extends ContextualTask
 {
-    //public static final String BUILD_DOCS_KEY = "project.target.docs.name";
-    //public static final String BUILD_DOCS_VALUE = "docs";
+    public static final String ORG_NAME_KEY = "project.organization.name";
+    public static final String ORG_NAME_VALUE = "The Apache Software Foundation";
 
     public static final String XDOC_TEMP_KEY = "project.target.temp.xdocs";
     public static final String XDOC_TEMP_VALUE = "xdocs";
@@ -48,9 +48,6 @@
     public static final String XDOC_FORMAT_KEY = "project.xdoc.output.format";
     public static final String XDOC_FORMAT_VALUE = "html";
 
-    public static final String ORG_NAME_KEY = "project.organization.name";
-    public static final String ORG_NAME_VALUE = "The Apache Software Foundation";
-
     public static final String XDOC_LOGO_RIGHT_FILE_KEY = "project.xdoc.logo.right.file";
     public static final String XDOC_LOGO_RIGHT_FILE_VALUE = "";
 
@@ -74,9 +71,6 @@
 
     public static final String XDOC_ANCHOR_URL_KEY = "project.xdoc.anchor.url";
 
-
-    private boolean m_init = false;
-    private Context m_context;
     private Home m_home;
     private String m_theme;
 
@@ -115,10 +109,10 @@
 
     public void init() throws BuildException 
     {
-        if( !m_init )
+        if( !isInitialized() )
         {
+            super.init();
             Project project = getProject();
-            m_context = Context.getContext( project );
             project.setNewProperty( ORG_NAME_KEY, ORG_NAME_VALUE );
             project.setNewProperty( XDOC_SRC_KEY, XDOC_SRC_VALUE );
             project.setNewProperty( XDOC_RESOURCES_KEY, XDOC_RESOURCES_VALUE );
@@ -132,8 +126,6 @@
             project.setNewProperty( XDOC_LOGO_MIDDLE_FILE_KEY, XDOC_LOGO_MIDDLE_FILE_VALUE
);
             project.setNewProperty( XDOC_LOGO_MIDDLE_URL_KEY, XDOC_LOGO_MIDDLE_URL_VALUE
);
             project.setNewProperty( XDOC_BRAND_NAME_KEY, XDOC_BRAND_NAME_VALUE );
-
-            m_init = true;
         }
     }
 
@@ -156,8 +148,6 @@
 
     public void execute()
     {        
-        log( "Executing" );
-
         if( null == m_home ) 
         {
             final String error = 
@@ -167,30 +157,19 @@
         }
 
         Project project = getProject();
-        File docs = m_context.getDocsDirectory();
-        log( "Docs:" + docs );
+        File docs = getContext().getDocsDirectory();
 
         //
         // get the directory containing the filtered xdocs source files 
         // (normally target/src/xdocs)
         //
 
-        File build = m_context.getBuildPath( PrepareTask.BUILD_SRC_KEY, false );
-
-        if( null == build )
-        {
-            final String message =
-              "Src directory does not exist: "
-              + build;
-            log( message );
-            return;
-        }
-
+        File build = getContext().getBuildDirectory();
         String xdocsPath = project.getProperty( XDOC_SRC_KEY );
         if( null == xdocsPath )
         {
             final String message =
-              "Cannot processed as xdoc src directory not defined.";
+              "Cannot continue as xdoc src directory not defined.";
             log( message );
             return;
         }
@@ -204,7 +183,7 @@
         // navigation structure (normally target/temp/xdocs)
         //
 
-        File temp = m_context.getTempDirectory();
+        File temp = getContext().getTempDirectory();
         String tempPath = project.getProperty( XDOC_TEMP_KEY );
         File destDir = new File( temp, tempPath );
         mkDir( destDir );
@@ -454,12 +433,4 @@
             return ! m.matches() ;
         }
     } 
-
-    private void mkDir( File dir )
-    {
-        Mkdir mkdir = (Mkdir) getProject().createTask( "mkdir" );
-        mkdir.setDir( dir );
-        mkdir.init();
-        mkdir.execute();
-    }
 }

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


Mime
View raw message