avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mcconn...@apache.org
Subject svn commit: rev 20660 - in avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools: . home tasks
Date Sun, 30 May 2004 20:33:14 GMT
Author: mcconnell
Date: Sun May 30 13:33:12 2004
New Revision: 20660

Added:
   avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/tasks/CleanTask.java
Modified:
   avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/antlib.xml
   avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/home/Home.java
   avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/tasks/HomeTask.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/JavacTask.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:
Add a clean tasks and some improvements to copy procedures.

Modified: avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/antlib.xml
==============================================================================
--- avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/antlib.xml	(original)
+++ avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/antlib.xml	Sun May 30
13:33:12 2004
@@ -3,6 +3,7 @@
   <taskdef name="project" classname="org.apache.avalon.tools.project.ProjectTask"/>

   <typedef name="home" classname="org.apache.avalon.tools.home.Home"/> 
   <taskdef name="prepare" classname="org.apache.avalon.tools.tasks.PrepareTask"/> 
+  <taskdef name="clean" classname="org.apache.avalon.tools.tasks.CleanTask"/> 
   <taskdef name="javac" classname="org.apache.avalon.tools.tasks.JavacTask"/> 
   <taskdef name="jar" classname="org.apache.avalon.tools.tasks.JarTask"/> 
   <taskdef name="test" classname="org.apache.avalon.tools.tasks.TestTask"/> 

Modified: avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/home/Home.java
==============================================================================
--- avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/home/Home.java	(original)
+++ avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/home/Home.java	Sun May
30 13:33:12 2004
@@ -306,4 +306,5 @@
         }
         return repository;
     }
+
 }

Added: avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/tasks/CleanTask.java
==============================================================================
--- (empty file)
+++ avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/tasks/CleanTask.java
Sun May 30 13:33:12 2004
@@ -0,0 +1,43 @@
+/* 
+ * 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 org.apache.tools.ant.Project;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.taskdefs.Delete;
+
+/**
+ * Cleanup 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 PrepareTask
+{
+    public void execute() throws BuildException 
+    {
+        Project project = getProject();
+        File target = PrepareTask.getTargetDirectory( project );
+        Delete delete = (Delete) project.createTask( "delete" );
+        delete.setDir( target );
+        delete.init();
+        delete.execute();
+    }
+}

Modified: avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/tasks/HomeTask.java
==============================================================================
--- avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/tasks/HomeTask.java	(original)
+++ avalon/trunk/tools/project/core/src/main/org/apache/avalon/tools/tasks/HomeTask.java	Sun
May 30 13:33:12 2004
@@ -19,6 +19,7 @@
 
 import java.io.File;
 import java.io.IOException;
+import java.util.Calendar;
 
 import org.apache.tools.ant.Task;
 import org.apache.tools.ant.BuildException;
@@ -44,9 +45,11 @@
 
     public void init() throws BuildException 
     {
+        super.init();
         m_home = Home.getHome( getProject() );
         String key = getProject().getProperty( "avalon.project.key" );
         m_definition = m_home.getDefinition( key );
+        populateDateTimes();
     }
 
     protected Home getHome()
@@ -78,5 +81,17 @@
         mkdir.setDir( dir );
         mkdir.init();
         mkdir.execute();
+    }
+
+    private void populateDateTimes()
+    {
+        Calendar cal = Calendar.getInstance();
+        
+        setProjectProperty( "magic.year", "" + cal.get( Calendar.YEAR ) );
+        setProjectProperty( "magic.month", "" + cal.get( Calendar.MONTH ) );
+        setProjectProperty( "magic.date", "" + cal.get( Calendar.DATE ) );
+        setProjectProperty( "magic.hour", "" + cal.get( Calendar.HOUR_OF_DAY ) );
+        setProjectProperty( "magic.minute", "" + cal.get( Calendar.MINUTE ) );
+        setProjectProperty( "magic.second", "" + cal.get( Calendar.SECOND ) );
     }
 }

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
Sun May 30 13:33:12 2004
@@ -58,6 +58,7 @@
         File target = new File( cache, group );
 
         Copy copy = (Copy) getProject().createTask( "copy" );
+        copy.setPreserveLastModified( true );
         copy.setTodir( target );
         copy.addFileset( fileset );
         copy.init();

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
Sun May 30 13:33:12 2004
@@ -111,6 +111,7 @@
     private void copy( File sources, File classes )
     {        
         Copy copy = (Copy) getProject().createTask( "copy" );
+        copy.setPreserveLastModified( true );
         copy.setTodir( classes );
 
         FileSet fileset = new FileSet();

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
Sun May 30 13:33:12 2004
@@ -44,12 +44,14 @@
     public static String TARGET_SRC = TARGET + "/src";
     public static String TARGET_SRC_MAIN = TARGET_SRC + "/main";
     public static String TARGET_SRC_TEST = TARGET_SRC + "/test";
+    public static String TARGET_SRC_RES = TARGET_SRC + "/resources";
 
     public static final String SRC_KEY = "avalon.src";
     public static final String TARGET_KEY = "avalon.target";
     public static final String TARGET_SRC_KEY = "avalon.target.src";
     public static final String TARGET_SRC_MAIN_KEY = "avalon.target.src.main";
     public static final String TARGET_SRC_TEST_KEY = "avalon.target.src.test";
+    public static final String TARGET_SRC_RES_KEY = "avalon.target.src.resources";
 
     public static File getTargetDirectory( Project project )
     {
@@ -57,6 +59,12 @@
         return new File( project.getBaseDir(), target );
     }
 
+    public static File getTargetSrcResourcesDirectory( Project project )
+    {
+        String res = project.getProperty( TARGET_SRC_RES_KEY );
+        return new File( project.getBaseDir(), res );
+    }
+
     public void init() throws BuildException 
     {
         setProjectProperty( SRC_KEY, SRC );
@@ -64,6 +72,7 @@
         setProjectProperty( TARGET_SRC_KEY, TARGET_SRC );
         setProjectProperty( TARGET_SRC_MAIN_KEY, TARGET_SRC_MAIN );
         setProjectProperty( TARGET_SRC_TEST_KEY, TARGET_SRC_TEST );
+        setProjectProperty( TARGET_SRC_RES_KEY, TARGET_SRC_RES );
     }
 
     public void execute() throws BuildException 
@@ -111,6 +120,7 @@
         copy.setTodir( targetSrc );
         copy.setFiltering( filtering );
         copy.setOverwrite( false );
+        copy.setPreserveLastModified( true );
 
         FileSet fileset = new FileSet();
         fileset.setDir( getSrcDirectory() );
@@ -121,5 +131,4 @@
         copy.init();
         copy.execute();
     }
-
 }

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	Sun
May 30 13:33:12 2004
@@ -56,6 +56,14 @@
         setProjectProperty( XDOC_TARGET_DOCS_KEY, XDOC_TARGET_DOCS_VALUE );
         setProjectProperty( XDOC_THEME_KEY, XDOC_THEME_VALUE );
         setProjectProperty( XDOC_OUTPUT_FORMAT_KEY, XDOC_OUTPUT_FORMAT_VALUE );
+        setProjectProperty( "xdoc.organization", "" );
+        setProjectProperty( "xdoc.logo.right.file", "" );
+        setProjectProperty( "xdoc.logo.right.url", "" );
+        setProjectProperty( "xdoc.logo.left.file", "" );
+        setProjectProperty( "xdoc.logo.left.url", "" );
+        setProjectProperty( "xdoc.logo.middle.file", "" );
+        setProjectProperty( "xdoc.logo.middle.url", "" );
+        setProjectProperty( "xdoc.brand.name", "" );
     }
 
     private File getThemesDirectory()
@@ -94,6 +102,7 @@
 
     public void execute()
     {        
+
         File srcDir = getTargetSrcXdocDirectory();
         if( !srcDir.exists() ) return;
 
@@ -105,7 +114,8 @@
         File themeRoot = getThemesDirectory();
         File themeDir = new File( themeRoot, theme + "/" + output );
         
-        log( "Source: " + srcDir.getAbsolutePath() );
+        log( "Year: " + getProject().getProperty( "magic.year" ) );
+        log( "Source: " + srcDir.getAbsolutePath() );
         log( "Theme: " + themeDir );
         
         try
@@ -146,13 +156,25 @@
           build, docs, xslFile, 
           "^.*\\.xml$", "^.*/navigation.xml$", "." + output, "html" );
     }
-    
-    private void copyResources( File themeDir )
+    
+    private void copyResources( File themeDir )
+    {
+        copyThemeResources( themeDir );
+        copySrcResources();
+    }
+
+    private void copySrcResources()
     {
         File destDir = getTargetDocsDirectory();
-        File toDir = new File( destDir, "resources" );
-        File fromDir = new File( themeDir, "resources" );
-        copy( fromDir, toDir, "**/*", "" );
+        File resources = PrepareTask.getTargetSrcResourcesDirectory( getProject() );
+        copy( resources, destDir, "**/*", "" );
+    }
+
+    private void copyThemeResources( File themeDir )
+    {
+        File destDir = getTargetDocsDirectory();
+        File fromDir = new File( themeDir, "resources" );
+        copy( fromDir, destDir, "**/*", "" );
     }
     
     private void copy( File fromDir, File toDir, String includes, String excludes )
@@ -166,6 +188,7 @@
         Copy copy = (Copy) getProject().createTask( "copy" );
         copy.setTodir( toDir );
         copy.addFileset( from );
+        copy.setPreserveLastModified( true );
         copy.execute();
     }
     
@@ -197,6 +220,12 @@
         FileFilter filter, String extension )
         throws BuildException
     {
+        String year = getProject().getProperty( "magic.year" );
+        String org = getProject().getProperty( "xdoc.organization" );
+        String copyright = 
+          "Copyright " + year + ", " + org + " All rights reserved.";
+
+
         File[] content = srcDir.listFiles( filter );
         for( int i = 0 ; i < content.length ; i++ )
         {
@@ -225,10 +254,31 @@
                 transformer.setParameter( "directory", getRelToPath( toDir ) );
                 transformer.setParameter( "fullpath", getRelToPath( newDest ) );
                 transformer.setParameter( "file", base );
-                transformer.setParameter( 
-                  "copyright", getProject().getProperty( "xdoc.footer.copyright"  ) );
                 transformer.setParameter( "svn-location", svnSource );
-                
+
+                transformer.setParameter( "copyright", copyright );
+                transformer.setParameter( 
+                  "logoright_file", 
+                  getProject().getProperty( "xdoc.logo.right.file" ).trim() );
+                transformer.setParameter( 
+                  "logoright_url", 
+                  getProject().getProperty( "xdoc.logo.right.url" ).trim() );
+                transformer.setParameter( 
+                  "logoleft_file", 
+                  getProject().getProperty( "xdoc.logo.left.file" ).trim() );
+                transformer.setParameter( 
+                  "logoleft_url", 
+                  getProject().getProperty( "xdoc.logo.left.url" ).trim() );
+                transformer.setParameter( 
+                  "logomiddle_file", 
+                  getProject().getProperty( "xdoc.logo.middle.file" ).trim() );
+                transformer.setParameter( 
+                  "logomiddle_url", 
+                  getProject().getProperty( "xdoc.logo.middle.url" ).trim() );
+                transformer.setParameter( 
+                  "brand_name", 
+                  getProject().getProperty( "xdoc.brand.name" ).trim() );
+
                 try
                 {
                     transformer.transform( xml, out );

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


Mime
View raw message