From 0f157a89d4127b4d582295a0d2c430e623e2102c Mon Sep 17 00:00:00 2001 From: Peter Donald Date: Wed, 6 Mar 2002 09:33:08 +0000 Subject: [PATCH] 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 --- proposal/myrmidon/antlib.xml | 3 + proposal/myrmidon/build.xml | 22 ++++- .../apache/myrmidon/build/AntDocSubTask.java | 87 +++++++++++++++++++ .../myrmidon/build/AntlibDescriptorTask.java | 17 +++- 4 files changed, 122 insertions(+), 7 deletions(-) create mode 100644 proposal/myrmidon/src/make/org/apache/myrmidon/build/AntDocSubTask.java diff --git a/proposal/myrmidon/antlib.xml b/proposal/myrmidon/antlib.xml index 1609a5116..67df1eb6d 100644 --- a/proposal/myrmidon/antlib.xml +++ b/proposal/myrmidon/antlib.xml @@ -18,6 +18,7 @@ Legal: + @@ -36,6 +37,7 @@ Legal: + @@ -59,6 +61,7 @@ Legal: + diff --git a/proposal/myrmidon/build.xml b/proposal/myrmidon/build.xml index 6fb3fc8e1..7d67b2737 100644 --- a/proposal/myrmidon/build.xml +++ b/proposal/myrmidon/build.xml @@ -185,12 +185,15 @@ Legal: + - - + + + + @@ -320,6 +323,15 @@ Legal: + + + + + + + + + @@ -357,12 +369,13 @@ Legal: + - - + + @@ -373,6 +386,7 @@ Legal: + diff --git a/proposal/myrmidon/src/make/org/apache/myrmidon/build/AntDocSubTask.java b/proposal/myrmidon/src/make/org/apache/myrmidon/build/AntDocSubTask.java new file mode 100644 index 000000000..cdce80a50 --- /dev/null +++ b/proposal/myrmidon/src/make/org/apache/myrmidon/build/AntDocSubTask.java @@ -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 Peter Donald + * @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; + } + } +} diff --git a/proposal/myrmidon/src/make/org/apache/myrmidon/build/AntlibDescriptorTask.java b/proposal/myrmidon/src/make/org/apache/myrmidon/build/AntlibDescriptorTask.java index 117b65678..88f593764 100644 --- a/proposal/myrmidon/src/make/org/apache/myrmidon/build/AntlibDescriptorTask.java +++ b/proposal/myrmidon/src/make/org/apache/myrmidon/build/AntlibDescriptorTask.java @@ -25,13 +25,14 @@ import xdoclet.TemplateSubTask; public class AntlibDescriptorTask 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_descriptorFileName; 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. */ @@ -56,6 +57,11 @@ public class AntlibDescriptorTask m_rolesFileName = rolesFileName; } + public void addAntdoc( final AntDocSubTask antDocs ) + { + m_antDocs = antDocs; + } + public void execute() throws BuildException { // Add the base directories of all the filesets to the sourcepath @@ -76,6 +82,11 @@ public class AntlibDescriptorTask makeTemplateSubTask( ROLES_TEMPLATE, getRolesFileName() ); addTemplate( rolesTemplate ); + if( null != m_antDocs ) + { + addTemplate( m_antDocs ); + } + if( !upToDate() ) { log( "Generating Antlib descriptors for: " + m_libName );