Browse Source

Start to integrate antdocs generation into build process.

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@271763 13f79535-47bb-0310-9956-ffa450edef68
master
Peter Donald 23 years ago
parent
commit
0f157a89d4
4 changed files with 122 additions and 7 deletions
  1. +3
    -0
      proposal/myrmidon/antlib.xml
  2. +18
    -4
      proposal/myrmidon/build.xml
  3. +87
    -0
      proposal/myrmidon/src/make/org/apache/myrmidon/build/AntDocSubTask.java
  4. +14
    -3
      proposal/myrmidon/src/make/org/apache/myrmidon/build/AntlibDescriptorTask.java

+ 3
- 0
proposal/myrmidon/antlib.xml View File

@@ -18,6 +18,7 @@ Legal:


<property name="build.dir" value="build"/> <property name="build.dir" value="build"/>
<property name="build.lib" value="${build.dir}/lib"/> <property name="build.lib" value="${build.dir}/lib"/>
<property name="build.custom-tasks" value="${build.dir}/tasks"/>


<property name="src.base" value="src"/> <property name="src.base" value="src"/>
<property name="java.dir" value="${src.base}/java"/> <property name="java.dir" value="${src.base}/java"/>
@@ -36,6 +37,7 @@ Legal:
<include name="*.jar" /> <include name="*.jar" />
</fileset> </fileset>
<pathelement path="${build.classes}" /> <pathelement path="${build.classes}" />
<pathelement path="${build.custom-tasks}" />
</path> </path>


<!-- Main target --> <!-- Main target -->
@@ -59,6 +61,7 @@ Legal:
<fileset dir="${java.dir}"> <fileset dir="${java.dir}">
<patternset refid="antlib.include"/> <patternset refid="antlib.include"/>
</fileset> </fileset>
<!-- antdoc docsDestDir="${gen.dir}/docs"/-->
</antlib-descriptor> </antlib-descriptor>
</target> </target>




+ 18
- 4
proposal/myrmidon/build.xml View File

@@ -185,12 +185,15 @@ Legal:
<!-- Compiles and installs the custom build tasks --> <!-- Compiles and installs the custom build tasks -->
<target name="custom-tasks"> <target name="custom-tasks">
<property name="custom-tasks-dir" value="${build.dir}/tasks"/> <property name="custom-tasks-dir" value="${build.dir}/tasks"/>
<property name="custom-package-dir" value="${custom-tasks-dir}/org/apache/myrmidon/build"/>
<mkdir dir="${custom-tasks-dir}"/> <mkdir dir="${custom-tasks-dir}"/>
<javac srcdir="src/make" destdir="${custom-tasks-dir}"> <javac srcdir="src/make" destdir="${custom-tasks-dir}">
<classpath refid="project.class.path"/> <classpath refid="project.class.path"/>
</javac> </javac>
<copy file="${manifest.dir}/ant-descriptor.template" todir="${build.dir}/tasks"/>
<copy file="${manifest.dir}/ant-roles.template" todir="${build.dir}/tasks"/>

<copy file="${manifest.dir}/ant-descriptor.template" tofile="${custom-package-dir}/ant-descriptor.j"/>
<copy file="${manifest.dir}/ant-roles.template" tofile="${custom-package-dir}/ant-roles.j"/>
<copy file="${manifest.dir}/type.j" tofile="${custom-package-dir}/type.j"/>


<taskdef name="antlib-jar" classname="org.apache.myrmidon.build.AntlibJarTask"> <taskdef name="antlib-jar" classname="org.apache.myrmidon.build.AntlibJarTask">
<classpath location="${custom-tasks-dir}"/> <classpath location="${custom-tasks-dir}"/>
@@ -320,6 +323,15 @@ Legal:
<include name="org/apache/myrmidon/launcher/*" /> <include name="org/apache/myrmidon/launcher/*" />
</patternset> </patternset>


<patternset id="myrmidon-api-xdoclet.include">
<include name="org/apache/myrmidon/api/*" />
<include name="org/apache/myrmidon/aspects/*" />
<include name="org/apache/myrmidon/interfaces/**" />
<include name="org/apache/myrmidon/listeners/*" />
<include name="org/apache/myrmidon/framework/**" />
<include name="org/apache/aut/converter/**" />
</patternset>

<patternset id="myrmidon-api.include"> <patternset id="myrmidon-api.include">
<include name="org/apache/myrmidon/api/*" /> <include name="org/apache/myrmidon/api/*" />
<include name="org/apache/myrmidon/aspects/*" /> <include name="org/apache/myrmidon/aspects/*" />
@@ -357,12 +369,13 @@ Legal:
<!-- The "builtin" descriptors include metainfo for both <!-- The "builtin" descriptors include metainfo for both
myrmidon-api and myrmidon-container jars. myrmidon-api and myrmidon-container jars.
(Packaged with myrmidon-api.jar). --> (Packaged with myrmidon-api.jar). -->

<antlib-descriptor libName="builtin" <antlib-descriptor libName="builtin"
destdir="${gen.dir}" destdir="${gen.dir}"
classpathref="project.class.path"> classpathref="project.class.path">
<fileset dir="${java.dir}"> <fileset dir="${java.dir}">
<patternset refid="myrmidon-api.include"/>
<patternset refid="myrmidon-container.include"/>
<patternset refid="myrmidon-api-xdoclet.include"/>
<!-- <patternset refid="myrmidon-container.include"/>-->
</fileset> </fileset>
</antlib-descriptor> </antlib-descriptor>


@@ -373,6 +386,7 @@ Legal:
<patternset refid="selftest.include"/> <patternset refid="selftest.include"/>
</fileset> </fileset>
</antlib-descriptor> </antlib-descriptor>

</target> </target>


<!-- Package the jar files --> <!-- Package the jar files -->


+ 87
- 0
proposal/myrmidon/src/make/org/apache/myrmidon/build/AntDocSubTask.java View File

@@ -0,0 +1,87 @@
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE.txt file.
*/
package org.apache.myrmidon.build;

import com.sun.javadoc.ClassDoc;
import java.io.File;
import java.net.URL;
import xdoclet.TemplateSubTask;
import xdoclet.XDocletException;

/**
* Generates the XML Documentation for Ant types (including tasks and DataTypes).
*
* @author <a href="mailto:peter@apache.org">Peter Donald</a>
* @version $Revision$ $Date$
*/
public class AntDocSubTask
extends TemplateSubTask
{
public final static String SUBTASK_NAME = "antdoc";

private static final String GENERATED_FILE_NAME = "{0}.xml";
private static final String DEFAULT_TEMPLATE_FILE =
"/org/apache/myrmidon/build/type.j";

private File m_docsDestDir;

public AntDocSubTask()
{
setTemplateFile( new File( DEFAULT_TEMPLATE_FILE ) );
setDestinationFile( GENERATED_FILE_NAME );

final TemplateSubTask.ExtentTypes extent = new TemplateSubTask.ExtentTypes();
extent.setValue( "hierarchy" );
setExtent( extent );
}

/**
* Specifies the directory that is the destination of generated generated
* xml documentation for types.
*/
public void setDocsDestDir( final File docsDestDir )
{
m_docsDestDir = docsDestDir;
}

public String getSubTaskName()
{
return SUBTASK_NAME;
}

/**
* Called to validate configuration parameters.
*/
public void validateOptions()
throws XDocletException
{
super.validateOptions();

if( null == m_docsDestDir )
{
throw new XDocletException( "'docsDestDir' attribute is missing ." );
}
}

protected boolean matchesGenerationRules( final ClassDoc clazz )
throws XDocletException
{
if( !super.matchesGenerationRules( clazz ) )
{
return false;
}
else if( clazz.isAbstract() )
{
return false;
}
else
{
return true;
}
}
}

+ 14
- 3
proposal/myrmidon/src/make/org/apache/myrmidon/build/AntlibDescriptorTask.java View File

@@ -25,13 +25,14 @@ import xdoclet.TemplateSubTask;
public class AntlibDescriptorTask public class AntlibDescriptorTask
extends DocletTask extends DocletTask
{ {
private static final String DESCRIPTOR_TEMPLATE = "/org/apache/myrmidon/build/ant-descriptor.j";
private static final String ROLES_TEMPLATE = "/org/apache/myrmidon/build/ant-roles.j";

private TemplateSubTask m_antDocs;
private String m_libName; private String m_libName;
private String m_descriptorFileName; private String m_descriptorFileName;
private String m_rolesFileName; private String m_rolesFileName;


private static final String DESCRIPTOR_TEMPLATE = "/ant-descriptor.template";
private static final String ROLES_TEMPLATE = "/ant-roles.template";

/** /**
* Specifies the Antlib name, which is used to name the generated files. * Specifies the Antlib name, which is used to name the generated files.
*/ */
@@ -56,6 +57,11 @@ public class AntlibDescriptorTask
m_rolesFileName = rolesFileName; m_rolesFileName = rolesFileName;
} }


public void addAntdoc( final AntDocSubTask antDocs )
{
m_antDocs = antDocs;
}

public void execute() throws BuildException public void execute() throws BuildException
{ {
// Add the base directories of all the filesets to the sourcepath // Add the base directories of all the filesets to the sourcepath
@@ -76,6 +82,11 @@ public class AntlibDescriptorTask
makeTemplateSubTask( ROLES_TEMPLATE, getRolesFileName() ); makeTemplateSubTask( ROLES_TEMPLATE, getRolesFileName() );
addTemplate( rolesTemplate ); addTemplate( rolesTemplate );


if( null != m_antDocs )
{
addTemplate( m_antDocs );
}

if( !upToDate() ) if( !upToDate() )
{ {
log( "Generating Antlib descriptors for: " + m_libName ); log( "Generating Antlib descriptors for: " + m_libName );


Loading…
Cancel
Save