avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mcconn...@apache.org
Subject svn commit: rev 21361 - in avalon/trunk: central/system runtime/merlin/impl runtime/meta/spi tools/magic/src/main/org/apache/avalon/tools tools/magic/src/main/org/apache/avalon/tools/project tools/magic/src/main/org/apache/avalon/tools/tasks
Date Wed, 16 Jun 2004 19:45:21 GMT
Author: mcconnell
Date: Wed Jun 16 12:45:21 2004
New Revision: 21361

Added:
   avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/AbstractDeliverableTask.java
  (contents, props changed)
   avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/JavadocTask.java   (contents,
props changed)
Modified:
   avalon/trunk/central/system/index.xml
   avalon/trunk/runtime/merlin/impl/build.xml
   avalon/trunk/runtime/meta/spi/build.xml
   avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/antlib.xml
   avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/project/Definition.java
   avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/ArtifactTask.java
   avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/BarTask.java
   avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/JarTask.java
Log:
first cut of the javadoc task

Modified: avalon/trunk/central/system/index.xml
==============================================================================
--- avalon/trunk/central/system/index.xml	(original)
+++ avalon/trunk/central/system/index.xml	Wed Jun 16 12:45:21 2004
@@ -141,7 +141,7 @@
       </info>
       <dependencies>
         <include key="avalon-framework-api"/>
-        <include key="avalon-framework-legacy"/>
+        <include key="avalon-framework-legacy" runtime="false" />
       </dependencies>
     </project>
 

Modified: avalon/trunk/runtime/merlin/impl/build.xml
==============================================================================
--- avalon/trunk/runtime/merlin/impl/build.xml	(original)
+++ avalon/trunk/runtime/merlin/impl/build.xml	Wed Jun 16 12:45:21 2004
@@ -17,6 +17,7 @@
 
   <target name="package" depends="standard.package">
     <x:artifact/>
+    <x:javadoc/>
   </target>
 
 </project>

Modified: avalon/trunk/runtime/meta/spi/build.xml
==============================================================================
--- avalon/trunk/runtime/meta/spi/build.xml	(original)
+++ avalon/trunk/runtime/meta/spi/build.xml	Wed Jun 16 12:45:21 2004
@@ -1,6 +1,9 @@
 <?xml version="1.0" encoding="UTF-8" ?>
 
-<project name="avalon-meta-spi" default="dist" basedir=".">
+<project name="avalon-meta-spi" default="dist" basedir="."
+    xmlns:x="antlib:org.apache.avalon.tools">
+
   <property file="build.properties"/>
   <import file="${project.home}/build/standard.xml"/>
+
 </project>

Modified: avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/antlib.xml
==============================================================================
--- avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/antlib.xml	(original)
+++ avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/antlib.xml	Wed Jun 16 12:45:21
2004
@@ -18,5 +18,6 @@
   <taskdef name="info" classname="org.apache.avalon.tools.tasks.AnnounceTask"/> 
   <taskdef name="artifact" classname="org.apache.avalon.tools.tasks.ArtifactTask"/>

   <taskdef name="bar" classname="org.apache.avalon.tools.tasks.BarTask"/> 
+  <taskdef name="javadoc" classname="org.apache.avalon.tools.tasks.JavadocTask"/> 
 
 </antlib>

Modified: avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/project/Definition.java
==============================================================================
--- avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/project/Definition.java	(original)
+++ avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/project/Definition.java	Wed
Jun 16 12:45:21 2004
@@ -114,6 +114,23 @@
         return path;
     }
 
+    public ResourceRef[] getQualifiedRefs( final List visited, int category )
+    {
+        ArrayList list = new ArrayList();
+        ResourceRef[] refs = 
+          getResourceRefs( Policy.RUNTIME, category, true );
+        for( int i=0; i<refs.length; i++ )
+        {
+            ResourceRef ref = refs[i];
+            if( !visited.contains(  ref ) )
+            {
+                list.add( ref );
+                visited.add( ref );
+            }
+        }
+        return (ResourceRef[]) list.toArray( new ResourceRef[0] );
+    }
+
     public String toString()
     {
         return "[" + getInfo().getGroup() + "/" + getInfo().getName() + "]";

Added: avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/AbstractDeliverableTask.java
==============================================================================
--- (empty file)
+++ avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/AbstractDeliverableTask.java
Wed Jun 16 12:45:21 2004
@@ -0,0 +1,92 @@
+/* 
+ * 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.Delete;
+import org.apache.tools.ant.taskdefs.Jar;
+import org.apache.tools.ant.taskdefs.Mkdir;
+import org.apache.tools.ant.taskdefs.Checksum;
+import org.apache.tools.ant.taskdefs.Manifest;
+import org.apache.tools.ant.taskdefs.ManifestException;
+import org.apache.tools.ant.taskdefs.Execute;
+import org.apache.tools.ant.types.FileSet;
+import org.apache.tools.ant.types.Path;
+
+import org.apache.avalon.tools.home.Context;
+import org.apache.avalon.tools.home.Home;
+import org.apache.avalon.tools.project.Definition;
+import org.apache.avalon.tools.project.ResourceRef;
+
+/**
+ * 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 class AbstractDeliverableTask extends SystemTask
+{
+    public static final String MD5_EXT = "md5";
+    public static final String ASC_EXT = "asc";
+    public static final String GPG_EXE_KEY = "project.gpg.exe";
+
+    public void checksum( File file )
+    {
+        log( "Creating md5 checksum" );
+
+        File md5 = new File( file.toString() + "." + MD5_EXT );
+
+        Delete delete = (Delete) getProject().createTask( "delete" );
+        delete.setFile( md5 );
+        delete.init();
+        delete.execute();
+
+        Checksum checksum = (Checksum) getProject().createTask( "checksum" );
+        checksum.setFile( file );
+        checksum.setFileext( "." + MD5_EXT );
+        checksum.init();
+        checksum.execute();
+    }
+
+    public void asc( File file ) throws IOException
+    {
+        File asc = new File( file.toString() + "." + ASC_EXT );
+        if( asc.exists() )
+        {
+            asc.delete();
+        }
+
+        String gpg = getProject().getProperty( GPG_EXE_KEY );
+        if(( null != gpg ) && !"".equals( gpg ) )
+        {
+            log( "Creating asc signature using '" + gpg + "']" );
+            Execute execute = new Execute();
+            execute.setCommandline( 
+              new String[]{ gpg, "-a", "-b", file.toString() } );
+            execute.setWorkingDirectory( getProject().getBaseDir() );
+            execute.setSpawn( true );
+            execute.execute();
+        }
+    }
+}

Modified: avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/ArtifactTask.java
==============================================================================
--- avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/ArtifactTask.java	(original)
+++ avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/ArtifactTask.java	Wed
Jun 16 12:45:21 2004
@@ -211,7 +211,7 @@
         throws IOException
     {
         ArrayList visited = new ArrayList();
-        ResourceRef[] apis = getQualifiedRefs( def, visited, ResourceRef.API );
+        ResourceRef[] apis = def.getQualifiedRefs( visited, ResourceRef.API );
         if( apis.length > 0 )
         {
             writer.write( "\n" );
@@ -221,7 +221,7 @@
             String lead = "avalon.artifact.dependency.api";
             writeRefs( writer, apis, lead );
         }
-        ResourceRef[] spis = getQualifiedRefs( def, visited, ResourceRef.SPI );
+        ResourceRef[] spis = def.getQualifiedRefs( visited, ResourceRef.SPI );
         if( spis.length > 0 )
         {
             writer.write( "\n" );
@@ -232,7 +232,7 @@
             writeRefs( writer, spis, lead );
         }
 
-        ResourceRef[] impl = getQualifiedRefs( def, visited, ResourceRef.IMPL );
+        ResourceRef[] impl = def.getQualifiedRefs( visited, ResourceRef.IMPL );
         if( impl.length > 0 )
         {
             writer.write( "\n" );
@@ -242,22 +242,6 @@
             String lead = "avalon.artifact.dependency";
             writeRefs( writer, impl, lead );
         }
-    }
-
-    private ResourceRef[] getQualifiedRefs( final Definition def, final List visited, int
category )
-    {
-        ArrayList list = new ArrayList();
-        ResourceRef[] refs = def.getResourceRefs( Policy.RUNTIME, category, true );
-        for( int i=0; i<refs.length; i++ )
-        {
-            ResourceRef ref = refs[i];
-            if( !visited.contains(  ref ) )
-            {
-                list.add( ref );
-                visited.add( ref );
-            }
-        }
-        return (ResourceRef[]) list.toArray( new ResourceRef[0] );
     }
 
     private void writeRefs( 

Modified: avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/BarTask.java
==============================================================================
--- avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/BarTask.java	(original)
+++ avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/BarTask.java	Wed Jun 16
12:45:21 2004
@@ -45,12 +45,9 @@
  * @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 BarTask extends SystemTask
+public class BarTask extends AbstractDeliverableTask
 {
-    public static final String MD5_EXT = "md5";
     public static final String BAR_EXT = "bar";
-    public static final String ASC_EXT = "asc";
-    public static final String GPG_EXE_KEY = "project.gpg.exe";
 
     private String m_name;
 
@@ -141,7 +138,10 @@
             addAttribute( block, "Block-Name", def.getInfo().getName() );
             if( null != def.getInfo().getVersion() )
             {
-                addAttribute( block, "Block-Version", def.getInfo().getVersion() );
+                addAttribute( 
+                  block, 
+                  "Block-Version", 
+                  def.getInfo().getVersion() );
             }
 
             manifest.addConfiguredSection( block );
@@ -159,45 +159,5 @@
     {
         Manifest.Attribute attribute = new Manifest.Attribute( name, value );
         section.addConfiguredAttribute( attribute );
-    }
-
-    private void checksum( File file )
-    {
-        log( "Creating md5 checksum" );
-
-        File md5 = new File( file.toString() + "." + MD5_EXT );
-
-        Delete delete = (Delete) getProject().createTask( "delete" );
-        delete.setFile( md5 );
-        delete.init();
-        delete.execute();
-
-        Checksum checksum = (Checksum) getProject().createTask( "checksum" );
-        checksum.setFile( file );
-        checksum.setFileext( "." + MD5_EXT );
-        checksum.init();
-        checksum.execute();
-    }
-
-    private void asc( File file ) throws IOException
-    {
-        File asc = new File( file.toString() + "." + ASC_EXT );
-
-        Delete delete = (Delete) getProject().createTask( "delete" );
-        delete.init();
-        delete.setFile( asc );
-        delete.execute();
-
-        String gpg = getProject().getProperty( GPG_EXE_KEY );
-        if( null != gpg )
-        {
-            log( "Creating asc signature" );
-            Execute execute = new Execute();
-            execute.setCommandline( 
-              new String[]{ gpg, "-a", "-b", file.toString() } );
-            execute.setWorkingDirectory( getProject().getBaseDir() );
-            execute.setSpawn( true );
-            execute.execute();
-        }
     }
 }

Modified: avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/JarTask.java
==============================================================================
--- avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/JarTask.java	(original)
+++ avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/JarTask.java	Wed Jun 16
12:45:21 2004
@@ -45,12 +45,9 @@
  * @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 SystemTask
+public class JarTask extends AbstractDeliverableTask
 {
-    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";
     public static final String JAR_MAIN_KEY = "project.jar.main.class";
     public static final String JAR_CLASSPATH_KEY = "project.jar.classpath";
     
@@ -173,45 +170,5 @@
     {
         Manifest.Attribute attribute = new Manifest.Attribute( name, value );
         section.addConfiguredAttribute( attribute );
-    }
-
-    private void checksum( File jar )
-    {
-        log( "Creating md5 checksum" );
-
-        File md5 = new File( jar.toString() + "." + MD5_EXT );
-
-        Delete delete = (Delete) getProject().createTask( "delete" );
-        delete.setFile( md5 );
-        delete.init();
-        delete.execute();
-
-        Checksum checksum = (Checksum) getProject().createTask( "checksum" );
-        checksum.setFile( jar );
-        checksum.setFileext( "." + MD5_EXT );
-        checksum.init();
-        checksum.execute();
-    }
-
-    private void asc( File jar ) throws IOException
-    {
-        File asc = new File( jar.toString() + "." + ASC_EXT );
-
-        Delete delete = (Delete) getProject().createTask( "delete" );
-        delete.init();
-        delete.setFile( asc );
-        delete.execute();
-
-        String gpg = getProject().getProperty( GPG_EXE_KEY );
-        if( null != gpg )
-        {
-            log( "Creating asc signature" );
-            Execute execute = new Execute();
-            execute.setCommandline( 
-              new String[]{ gpg, "-a", "-b", jar.toString() } );
-            execute.setWorkingDirectory( getProject().getBaseDir() );
-            execute.setSpawn( true );
-            execute.execute();
-        }
     }
 }

Added: avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/JavadocTask.java
==============================================================================
--- (empty file)
+++ avalon/trunk/tools/magic/src/main/org/apache/avalon/tools/tasks/JavadocTask.java	Wed Jun
16 12:45:21 2004
@@ -0,0 +1,133 @@
+/* 
+ * 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 java.util.List;
+import java.util.ArrayList;
+
+import org.apache.tools.ant.Task;
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.types.DirSet;
+import org.apache.tools.ant.types.Path;
+import org.apache.tools.ant.taskdefs.Javadoc;
+
+import org.apache.avalon.tools.home.Context;
+import org.apache.avalon.tools.home.Home;
+import org.apache.avalon.tools.project.Definition;
+import org.apache.avalon.tools.project.ResourceRef;
+import org.apache.avalon.tools.project.Resource;
+
+/**
+ * Build the javadoc for a project. 
+ *
+ * @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 JavadocTask extends SystemTask
+{
+    public static final String JAVADOC = "javadoc";
+    public static final String API = "api";
+    public static final String SPI = "spi";
+    public static final String IMPL = "impl";
+
+    public void execute() throws BuildException 
+    {
+        Definition def = getHome().getDefinition( getKey() );
+        File root = getJavadocRootDirectory( def );
+
+        ArrayList visited = new ArrayList();
+        execute( def, visited, ResourceRef.API, "api", root );
+        execute( def, visited, ResourceRef.SPI, "spi", root );
+        execute( def, visited, ResourceRef.IMPL, "impl", root );
+    }
+
+    private void execute( 
+      Definition def, List visited, int category, String branch, File root )
+    {
+        File base = new File( root, branch );
+        ResourceRef[] refs = def.getQualifiedRefs( visited, category );
+        if( refs.length > 0 )
+        {
+            log( 
+              "Javadoc preparation for category: " 
+              + branch + ", " 
+              + refs.length );
+            generate( def, refs, base );
+        }
+    }
+
+    private void generate( 
+       Definition definition, ResourceRef[] refs, File root )
+    {
+        Javadoc javadoc = (Javadoc) getProject().createTask( "javadoc" );
+
+        javadoc.init();
+        javadoc.setDestdir( root );
+        Path source = javadoc.createSourcepath();
+        Path classpath = javadoc.createClasspath();
+        for( int i=0; i<refs.length; i++ )
+        {
+            ResourceRef ref = refs[i];
+            Resource resource = getHome().getResource( ref );
+            if( resource instanceof Definition )
+            {
+                Definition def = (Definition) resource;
+                File base = def.getBasedir();
+                File src = new File( base, "target/build/main" );
+                if( src.exists() )
+                {
+                    source.createPathElement().setLocation( src );
+                    DirSet packages = new DirSet();
+                    packages.setDir( src );
+                    packages.setIncludes( "**/**" );
+                    javadoc.addPackageset( packages );
+                }
+            }
+            else
+            {
+                File artifact = resource.getArtifact( getProject() );
+                classpath.createPathElement().setLocation( artifact );
+            }
+        }
+
+        File basedir = definition.getBasedir();
+        File local = new File( basedir, "target/build/main" );
+        if( local.exists() )
+        {
+            source.createPathElement().setLocation( local );
+            javadoc.execute();
+        }
+    }
+
+    private File getJavadocRootDirectory( Definition def )
+    {
+        File docs = getContext().getDocsDirectory();
+        String version = def.getInfo().getVersion();
+        if( null == version )
+        {
+            return new File( docs, JAVADOC );
+        }
+        else
+        {
+            return new File( docs, version );
+        }
+    }
+}

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


Mime
View raw message