ehatcher 02/03/03 04:57:38 Modified: proposal/xdocs/dvsl build.xml task.dvsl proposal/xdocs/src/org/apache/tools/ant/xdoclet AntTagsHandler.java proposal/xdocs/templates task_xdoc.template Added: proposal/xdocs/src/org/apache/tools/ant/taskdefs condition.xml javac.xml javadoc.xml tar.xml Log: thanks again Bill Burton! all i can say is "wow!" Revision Changes Path 1.2 +9 -2 jakarta-ant/proposal/xdocs/dvsl/build.xml Index: build.xml =================================================================== RCS file: /home/cvs/jakarta-ant/proposal/xdocs/dvsl/build.xml,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- build.xml 1 Mar 2002 11:46:07 -0000 1.1 +++ build.xml 3 Mar 2002 12:57:38 -0000 1.2 @@ -24,13 +24,20 @@ + + + + + + style="task.dvsl" extension=".html" + includes="**/*.xml"> + + 1.2 +178 -108 jakarta-ant/proposal/xdocs/dvsl/task.dvsl Index: task.dvsl =================================================================== RCS file: /home/cvs/jakarta-ant/proposal/xdocs/dvsl/task.dvsl,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- task.dvsl 1 Mar 2002 11:46:07 -0000 1.1 +++ task.dvsl 3 Mar 2002 12:57:38 -0000 1.2 @@ -2,7 +2,7 @@ * DVSL Stylesheet to format the Ant Task documentation. *# -#set( $relative-path = "." ) +#set( $relative-path = "../../" ) #if (false) #set( $body-bg = '#ffffff' ) #set( $body-fg = '#000000' ) @@ -44,115 +44,124 @@ #if ( $test )$output#end #end -#match( "task" ) - #set( $task_name = $attrib.name ) - ## Create task title with first letter in upper case - #set( $task_title = "$task_name.substring(0,1).toUpperCase()$task_name.substring(1)" ) - - - - $task_title Task - - - - - - - ## PAGE HEADER - - - - ## HEADER SEPARATOR - - ## - +#match( "task" ) + #set( $project = $node.selectSingleNode("document('xdocs/stylesheets/project.xml')/project" ) ) + #if ($node.name().equals("task")) + #set( $title = "#capitalize($attrib.name) Task" ) + #set( $summary = $node.short-description ) + #end + + + + + $title + + + + +
- - ## JAKARTA LOGO - - The Jakarta Project - - - #if( $project.logo ) - - #set( $alt = $project.logo ) - #set( $home = $project.attribute("href") ) - #set( $src = $project.logo.attribute( "href" ) ) - - ## PROJECT LOGO - - $alt - - #end +## Macro to capitalize a word making the first letter upper case +#macro(capitalize $word) +$word.substring(0,1).toUpperCase()$word.substring(1) +#end -
- -
-
+ + + + + - - - - + + + + + - - - - + + + + - - - - + + + + -
+ + + +
+ $title +#* *##if( $summary ) +
$summary +#* *##end +
+#* *##if( $project.logo ) + #set( $alt = $project.logo ) + #set( $home = $project.attribute("href") ) + #set( $src = $project.logo.attribute( "href" ) ) + + + $alt + +#* *##end +
+
- $context.applyTemplates("long-description") - $context.applyTemplates("structure/attributes") - $context.applyTemplates("structure/elements") -
+#* *##if ($node.name().equals("task")) +#* Use description from merged XML if available, else javadoc comment *# +#* *##if ($node.external.description) + +#* *#$context.applyTemplates("external/description") +#* *##else + +#* *#$context.applyTemplates("long-description") +#* *##end +#* *#$context.applyTemplates("structure/attributes") +#* *#$context.applyTemplates("structure/elements") +#* *#$context.applyTemplates("external/section") +#* *##end +
-
-
+
+
-
- Copyright © 2000-2002, Apache Software Foundation -
-
+
+ Copyright © 2000-2002, Apache Software Foundation +
+
+ - - + + #end #* Macro to format a table heading cell *# #macro( th $text ) - - - $text - + + $text + #end #* Macro to format a table body cell *# #macro( td $text ) - - - $text - - + + $text + #end #* Macro to format a section banner *# #macro( section $anchor $name ) - - - - $name - + + + + $name + #end #* @@ -168,75 +177,136 @@ #* - Match long-description section + Process javadoc long description section *# #match( "long-description" ) + - #section($task_name "$task_title Task Description") +#* *##section("description" "Description")
 
- $node.value() + $node.value().trim()
+ #end #* - Match structure/attributes section + Process external desciption *# -#match( "structure/attributes" ) +#match( "external/description" ) + - #section("attributes" "Parameters") +#* *##section("description" "Description")
 
- - - #th("Attribute") - #th("Description") - #th("Type") - - $context.applyTemplates("*") -
+#* *#$context.applyTemplates("*")
+ #end #* - Match structure/elements section + Process top level attributes *# -#match( "structure/elements" ) +#match( "structure/attributes" ) + - #section("elements" "Parameters as nested elements") +#* *##section("attributes" "Parameters")
 
- $context.applyTemplates("*") + + +#* *##th("Attribute") +#* *##th("Description") +#* *##th("Type") + +#* *#$context.applyTemplates("*") +
+ #end +#* + Process a single attribute +*# #match( "attribute" ) + - #td($attrib.name) - #td($node.description) - #td($attrib.type) +#* *##td($attrib.name) +#* *##td($node.description) +#* *##td($attrib.type) #end +#* + Process all elements +*# +#match( "elements" ) + + + + +#* *##section("elements" "Parameters as nested elements") + + + +
 
+#* *#$context.applyTemplates("*") +
+ +#end + +#* + Process a single element +*# #match( "element" ) + - #subsection($attrib.name $attrib.name) + +
 
+ + $attrib.name ($attrib.type) +
- $node.description + $node.description.toString().trim() +#* *#$context.applyTemplates("*")
+ +#end + +#* + Process attributes within elements +*# +#match( "element/attributes" ) + + + + + + +
 
+ + +#* *##th("Attribute") +#* *##th("Description") +#* *##th("Type") + +#* *#$context.applyTemplates("*") +
+
+ #end 1.1 jakarta-ant/proposal/xdocs/src/org/apache/tools/ant/taskdefs/condition.xml Index: condition.xml ===================================================================

Sets a property if a certain condition holds true - this is a generalization of Available and Uptodate.

If the condition holds true, the property value is set to true by default; otherwise, the property is not set. You can set the value to something other than the default by specifying the value attribute.

Conditions are specified as nested elements, you must specify exactly one condition.

    <condition property="javamail.complete">
      <and>
        <available classname="javax.activation.DataHandler" />
        <available classname="javax.mail.Transport" />
      </and>
    </condition>
  

sets the property javamail.complete if both the JavaBeans Activation Framework and JavaMail are available in the classpath.

    <condition property="isMacOsButNotMacOsX">
      <and>
        <os family="mac" />
        <not>
          <os family="unix" />
        </not>
      </and>
    </condition>
  

sets the property isMacOsButNotMacOsX if the current operating system is MacOS, but not MacOS X - which Ant considers to be in the Unix family as well.

    <condition property="isSunOSonSparc">
      <os name="SunOS" arch="sparc" />
    </condition>
  

sets the property isSunOSonSparc if the current operating system is SunOS and if it is running on a sparc architecture.

1.1 jakarta-ant/proposal/xdocs/src/org/apache/tools/ant/taskdefs/javac.xml Index: javac.xml ===================================================================

Compiles a Java source tree.

The source and destination directory will be recursively scanned for Java source files to compile. Only Java files that have no corresponding class file or where the class file is older than the java file will be compiled.

Note: Ant uses only the names of the source and class files to find the classes that need a rebuild. It will not scan the source and therefor will have no knowledge about nested classes, classes that are named different from the source file and so on.

The directory structure of the source tree should follow the package hierarchy.

It is possible to refine the set of files that are being compiled/copied. This can be done with the includes, includesfile, excludes, excludesfile and defaultexcludes attributes. With the includes or includesfile attribute you specify the files you want to have included by using patterns. The exclude or excludesfile attribute is used to specify the files you want to have excluded. This is also done with patterns. And finally with the defaultexcludes attribute, you can specify whether you want to use default exclusions or not. See the section on directory based tasks, on how the inclusion/exclusion of files works, and how to write patterns.

It is possible to use different compilers. This can be selected with the "build.compiler" property or the compiler attribute. Here are the choices:-

  • classic (the standard compiler of JDK 1.1/1.2) - javac1.1 and javac1.2 can be used as aliases
  • modern (the standard compiler of JDK 1.3/1.4) - javac1.3 and javac1.4 can be used as aliases
  • jikes (the Jikes compiler)
  • jvc (the Command-Line Compiler from Microsoft's SDK for Java / Visual J++) - microsoft can be used as an alias
  • kjc (the kopi compiler)
  • gcj (the gcj compiler from gcc)
  • sj (Symantec java compiler) - symantec can be used as an alias
  • extJavac (run either modern or classic in a JVM of its own)

For JDK 1.1/1.2, classic is the default. For JDK 1.3/1.4, modern is the default. If you wish to use a different compiler interface than those supplied, write a class that implements the CompilerAdapter interface (package org.apache.tools.ant.taskdefs.compilers). Supply the full classname in the "build.compiler" property.

The fork attribute overrides the build.compiler setting and expects a JDK1.1 or higher to be set in java.home.

This task will drop all entries that point to non-existent files/directories from the CLASSPATH it passes to the compiler.

Windows Note:When the modern compiler is used in unforked mode on Windows, it locks up the files present in the classpath of the <javac> task, and does not release them. The side effect of this is that you will not be able to delete or move those files later on in the build. The workaround is to fork when invoking the compiler.

  <javac srcdir="${src}"
           destdir="${build}"
           classpath="xyz.jar"
           debug="on"
    />

compiles all .java files under the ${src} directory, and stores the .class files in the ${build} directory. The classpath used contains xyz.jar, and debug information is on.

  <javac srcdir="${src}"
           destdir="${build}"
           fork="true"
    />

compiles all .java files under the ${src} directory, and stores the .class files in the ${build} directory. This will fork off the javac compiler using the default javac executable.

  <javac srcdir="${src}"
           destdir="${build}"
           fork="java$$javac.exe"
    />

compiles all .java files under the ${src} directory, and stores the .class files in the ${build} directory. This will fork off the javac compiler using the executable named java$javac.exe. Note that the $ sign needs to be escaped by a second one.

  <javac srcdir="${src}"
           destdir="${build}"
           includes="mypackage/p1/**,mypackage/p2/**"
           excludes="mypackage/p1/testpackage/**"
           classpath="xyz.jar"
           debug="on"
    />

compiles .java files under the ${src} directory, and stores the .class files in the ${build} directory. The classpath used contains xyz.jar, and debug information is on. Only files under mypackage/p1 and mypackage/p2 are used. Files in the mypackage/p1/testpackage directory are excluded from compilation.

  <javac srcdir="${src}:${src2}"
           destdir="${build}"
           includes="mypackage/p1/**,mypackage/p2/**"
           excludes="mypackage/p1/testpackage/**"
           classpath="xyz.jar"
           debug="on"
    />

is the same as the previous example, with the addition of a second source path, defined by the property src2. This can also be represented using nested <src> elements as follows:

  <javac destdir="${build}"
           classpath="xyz.jar"
           debug="on">
      <src path="${src}"/>
      <src path="${src2}"/>
      <include name="mypackage/p1/**"/>
      <include name="mypackage/p2/**"/>
      <exclude name="mypackage/p1/testpackage/**"/>
    </javac>

Note: If you are using Ant on Windows and a new DOS window pops up for every use of an external compiler, this may be a problem of the JDK you are using. This problem may occur with all JDKs < 1.2.

Note: If you wish to compile only source-files located in some packages below a common root you should not include these packages in the srcdir-attribute. Use include/exclude-attributes or elements to filter for these packages. If you include part of your package-structure inside the srcdir-attribute (or nested src-elements) Ant will start to recompile your sources every time you call it.

Jikes supports some extra options, which can be set be defining properties prior to invoking the task. The ant developers are aware that this is ugly and inflexible -expect a better solution in the future. All the options are boolean, and must be set to "true" or "yes" to be interpreted as anything other than false; by default build.compiler.warnings is "true" while all others are "false"

build.compiler.emacs Enable emacs compatible error messages
build.compiler.warnings
This property has been deprecated, use the nowarn attribute instead
don't disable warning messages
build.compiler.pedantic enable pedantic warnings
build.compiler.fulldepend enable full dependency checking,
"+F" in the jikes manual.
1.1 jakarta-ant/proposal/xdocs/src/org/apache/tools/ant/taskdefs/javadoc.xml Index: javadoc.xml ===================================================================

Generates code documentation using the javadoc tool.

The source directory will be recursively scanned for Java source files to process but only those matching the inclusion rules, and not matching the exclusions rules will be passed to the javadoc tool. This allows wildcards to be used to choose between package names, reducing verbosity and management costs over time. This task, however, has no notion of "changed" files, unlike the javac task. This means all packages will be processed each time this task is run. In general, however, this task is used much less frequently.

This task works seamlessly between different javadoc versions (1.1 and 1.2), with the obvious restriction that the 1.2 attributes will be ignored if run in a 1.1 VM.

NOTE: since javadoc calls System.exit(), javadoc cannot be run inside the same VM as ant without breaking functionality. For this reason, this task always forks the VM. This overhead is not significant since javadoc is normally a heavy application and will be called infrequently.

NOTE: the packagelist attribute allows you to specify the list of packages to document outside of the Ant file. It's a much better practice to include everything inside the build.xml file. This option was added in order to make it easier to migrate from regular makefiles, where you would use this option of javadoc. The packages listed in packagelist are not checked, so the task performs even if some packages are missing or broken. Use this option if you wish to convert from an existing makefile. Once things are running you should then switch to the regular notation.

DEPRECATION: the javadoc2 task simply points to the javadoc task and it's there for back compatibility reasons. Since this task will be removed in future versions, you are strongly encouraged to use javadoc instead.

  <javadoc packagenames="com.dummy.test.*"
             sourcepath="src"
             excludepackagenames="com.dummy.test.doc-files.*"
             defaultexcludes="yes"
             destdir="docs/api"
             author="true"
             version="true"
             use="true"
             windowtitle="Test API">
      <doctitle><![CDATA[<h1>Test</h1>]]></doctitle>
      <bottom><![CDATA[<i>Copyright &#169; 2000 Dummy Corp. All Rights Reserved.</i>]]></bottom>
      <tag name="todo" scope="all" description="To do:" />
      <group title="Group 1 Packages" packages="com.dummy.test.a*"/>
      <group title="Group 2 Packages" packages="com.dummy.test.b*:com.dummy.test.c*"/>
      <link offline="true" href="http://java.sun.com/products/jdk/1.2/docs/api/" packagelistLoc="C:\tmp"/>
      <link href="http://developer.java.sun.com/developer/products/xml/docs/api/"/>
    </javadoc>
1.1 jakarta-ant/proposal/xdocs/src/org/apache/tools/ant/taskdefs/tar.xml Index: tar.xml ===================================================================

Creates a tar archive.

The basedir attribute is the reference directory from where to tar.

This task is a directory based task and, as such, forms an implicit Fileset. This defines which files, relative to the basedir, will be included in the archive. The tar task supports all the attributes of Fileset to refine the set of files to be included in the implicit fileset.

In addition to the implicit fileset, the tar task supports nested filesets. These filesets are extended to allow control over the access mode, username and groupname to be applied to the tar entries. This is useful, for example, when preparing archives for Unix systems where some files need to have execute permission.

Early versions of tar did not support path lengths greater than 100 characters. Modern versions of tar do so, but in incompatible ways. The behaviour of the tar task when it encounters such paths is controlled by the longfile attribute. If the longfile attribute is set to fail, any long paths will cause the tar task to fail. If the longfile attribute is set to truncate, any long paths will be truncated to the 100 character maximum length prior to adding to the archive. If the value of the longfile attribute is set to omit then files containing long paths will be omitted from the archive. Either option ensures that the archive can be untarred by any compliant version of tar. If the loss of path or file information is not acceptable, and it rarely is, longfile may be set to the value gnu. The tar task will then produce a GNU tar file which can have arbitrary length paths. Note however, that the resulting archive will only be able to be untarred with GNU tar. The default for the longfile attribute is warn which behaves just like the gnu option except that it produces a warning for each file path encountered that does not match the limit.

Note that this task does not perform compression. You might want to use the GZip task to prepare a .tar.gz package.

  <tar tarfile="${dist}/manual.tar" basedir="htdocs/manual"/>
    <gzip zipfile="${dist}/manual.tar.gz" src="${dist}/manual.tar"/>

tars all files in the htdocs/manual directory into a file called manual.tar in the ${dist} directory, then applies the gzip task to compress it.

  <tar destfile="${dist}/manual.tar"
         basedir="htdocs/manual"
         excludes="mydocs/**, **/todo.html"
    />

tars all files in the htdocs/manual directory into a file called manual.tar in the ${dist} directory. Files in the directory mydocs, or files with the name todo.html are excluded.

  <tar destfile="${basedir}/docs.tar">
    <tarfileset dir="${dir.src}/docs"
                fullpath="/usr/doc/ant/README"
                preserveLeadingSlashes="true">
      <include name="readme.txt"/>
    </tarfileset>
    <tarfileset dir="${dir.src}/docs"
                prefix="/usr/doc/ant"
                preserveLeadingSlashes="true">
      <include name="*.html"/>
    </tarfileset>
  </tar>

Writes the file docs/readme.txt as /usr/doc/ant/README into the archive. All *.html files in the docs directory are prefixed by /usr/doc/ant, so for example docs/index.html is written as /usr/doc/ant/index.html to the archive.

<tar longfile="gnu"
       destfile="${dist.base}/${dist.name}-src.tar" >
    <tarfileset dir="${dist.name}/.." mode="755" username="ant" group="ant">
      <include name="${dist.name}/bootstrap.sh"/>
      <include name="${dist.name}/build.sh"/>
    </tarfileset>
    <tarfileset dir="${dist.name}/.." username="ant" group="ant">
      <include name="${dist.name}/**"/>
      <exclude name="${dist.name}/bootstrap.sh"/>
      <exclude name="${dist.name}/build.sh"/>
    </tarfileset>
  </tar> 

This example shows building a tar which uses the GNU extensions for long paths and where some files need to be marked as executable (mode 755) and the rest are use the default mode (read-write by owner). The first fileset selects just the executable files. The second fileset must exclude the executable files and include all others.

Note: The tar task does not ensure that a file is only selected by one fileset. If the same file is selected by more than one fileset, it will be included in the tar file twice, with the same path.

Note: The patterns in the include and exclude elements are considered to be relative to the corresponding dir attribute as with all other filesets. In the example above, ${dist.name} is not an absolute path, but a simple name of a directory, so ${dist.name} is a valid path relative to ${dist.name}/...

1.5 +74 -2 jakarta-ant/proposal/xdocs/src/org/apache/tools/ant/xdoclet/AntTagsHandler.java Index: AntTagsHandler.java =================================================================== RCS file: /home/cvs/jakarta-ant/proposal/xdocs/src/org/apache/tools/ant/xdoclet/AntTagsHandler.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- AntTagsHandler.java 28 Feb 2002 03:51:40 -0000 1.4 +++ AntTagsHandler.java 3 Mar 2002 12:57:38 -0000 1.5 @@ -55,6 +55,9 @@ import com.sun.javadoc.ClassDoc; import com.sun.javadoc.MethodDoc; +import com.sun.javadoc.Parameter; +import com.sun.javadoc.Type; + import xdoclet.XDocletException; import xdoclet.XDocletTagSupport; import xdoclet.tags.AbstractProgramElementTagsHandler; @@ -123,6 +126,25 @@ } /** + * Determines if there's at least one Ant attribute. + * + *@param template XDoclet template + *@param attributes Tag parameters + *@exception XDocletException Oops! + */ + public void ifHasAttributes(String template, Properties attributes) throws XDocletException { + // throw exception if not an Ant task + + ClassDoc cur_class = getCurrentClass(); + + MethodDoc[] methods = getAttributeMethods(cur_class); + + if (methods.length > 0) { + generate(template); + } + } + + /** * Iterates over all Ant nested element methods (addXXX, addConfiguredXXX, addXXX) * *@param template XDoclet template @@ -161,11 +183,43 @@ return elementName.toLowerCase(); } + /** + * Provides the element type for the current method + */ + public String elementType() throws XDocletException { + ClassDoc classDoc = elementClassDoc(); + if (classDoc == null) { + throw new XDocletException("Method is not an Ant element!"); + } + return classDoc.qualifiedName(); + } + + /** + * Provides the element type for the current method. If the return type + * is null, the first parameter is used. + */ + private ClassDoc elementClassDoc() throws XDocletException { + ClassDoc classDoc = null; + String methodName = getCurrentMethod().name(); + if (methodName.startsWith("addConfigured") || + methodName.startsWith("add") || + methodName.startsWith("create")) + { + classDoc = getCurrentMethod().returnType().asClassDoc(); + if (classDoc == null) { + Parameter[] params = getCurrentMethod().parameters(); + if (params.length == 1) { + classDoc = params[0].type().asClassDoc(); + } + } + } + return classDoc; + } /** * Provides the Ant task name. * - * @see getTaskName + * @see #getTaskName(ClassDoc) * @doc:tag type="content" */ public String taskName() throws XDocletException { @@ -204,7 +258,7 @@ /** * Provides the Ant category name. * - * @see getCategoryName + * @see #getCategoryName(ClassDoc) */ public String categoryName() throws XDocletException { return getCategoryName(getCurrentClass()); @@ -273,6 +327,12 @@ continue; } + // ensure method only has one parameter + Parameter[] params = methods[i].parameters(); + if (params.length != 1) { + continue; + } + attributeMethods.add(methods[i]); } @@ -290,6 +350,18 @@ for (int i = 0; i < methods.length; i++) { String name = methods[i].name(); + + // ensure if there are no parameters, there is a return type, + // otherwise ensure there's only one parameter. + Parameter[] params = methods[i].parameters(); + if (params.length == 0) { + if (methods[i].returnType().asClassDoc() == null) { + continue; + } + } + else if (params.length != 1) { + continue; + } if ((name.startsWith("add") && !name.equals("addTask")) || name.startsWith("create")) { 1.4 +30 -16 jakarta-ant/proposal/xdocs/templates/task_xdoc.template Index: task_xdoc.template =================================================================== RCS file: /home/cvs/jakarta-ant/proposal/xdocs/templates/task_xdoc.template,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- task_xdoc.template 1 Mar 2002 11:46:07 -0000 1.3 +++ task_xdoc.template 3 Mar 2002 12:57:38 -0000 1.4 @@ -1,8 +1,9 @@ - + + ]]> ]]> @@ -11,23 +12,37 @@ - - - - ]]> - - + + + + ]]> + + - - - - ]]> - - + + + + ]]> + + + + + + + + ]]> + + + + + + + + @@ -41,7 +56,6 @@ - -- To unsubscribe, e-mail: For additional commands, e-mail: