You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by bo...@apache.org on 2018/09/28 18:28:24 UTC

ant git commit: BZ 62424 minimal module support for javadoc

Repository: ant
Updated Branches:
  refs/heads/1.9.x d100b9003 -> 048015b7d


BZ 62424 minimal module support for javadoc


Project: http://git-wip-us.apache.org/repos/asf/ant/repo
Commit: http://git-wip-us.apache.org/repos/asf/ant/commit/048015b7
Tree: http://git-wip-us.apache.org/repos/asf/ant/tree/048015b7
Diff: http://git-wip-us.apache.org/repos/asf/ant/diff/048015b7

Branch: refs/heads/1.9.x
Commit: 048015b7d891edd74c8d458aa582a504511872c6
Parents: d100b90
Author: Stefan Bodewig <bo...@apache.org>
Authored: Fri Sep 28 20:27:53 2018 +0200
Committer: Stefan Bodewig <bo...@apache.org>
Committed: Fri Sep 28 20:27:53 2018 +0200

----------------------------------------------------------------------
 WHATSNEW                                        |   3 +
 manual/Tasks/javadoc.html                       |  73 ++++++++--
 .../org/apache/tools/ant/taskdefs/Javadoc.java  | 142 ++++++++++++++++++-
 3 files changed, 207 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ant/blob/048015b7/WHATSNEW
----------------------------------------------------------------------
diff --git a/WHATSNEW b/WHATSNEW
index 6cd11da..e5bfed3 100644
--- a/WHATSNEW
+++ b/WHATSNEW
@@ -32,6 +32,9 @@ Other changes:
    command line arguments that are not supported explicitly by the
    tasks via attributes.
 
+ * added several attributes to <javadoc> that support modules.
+   Bugzilla Report 62424
+
 Changes from Ant 1.9.12 TO Ant 1.9.13
 =====================================
 

http://git-wip-us.apache.org/repos/asf/ant/blob/048015b7/manual/Tasks/javadoc.html
----------------------------------------------------------------------
diff --git a/manual/Tasks/javadoc.html b/manual/Tasks/javadoc.html
index 430435f..a32ed47 100644
--- a/manual/Tasks/javadoc.html
+++ b/manual/Tasks/javadoc.html
@@ -92,9 +92,9 @@ to &lt;javadoc&gt; using <tt>classpath</tt>, <tt>classpathref</tt> attributes or
     <td valign="top">sourcepath</td>
     <td valign="top">Specify where to find source files</td>
     <td align="center" valign="top">all</td>
-    <td align="center" rowspan="3">At least one of the three or nested
-    <code>&lt;sourcepath&gt;</code>, <code>&lt;fileset&gt;</code> or
-    <code>&lt;packageset&gt;</code></td>
+    <td align="center" rowspan="3">At least one of the four or nested
+      <code>&lt;sourcepath&gt;</code>, <code>&lt;fileset&gt;</code>.
+      <code>module</code> or <code>&lt;packageset&gt;</code></td>
   </tr>
   <tr>
     <td valign="top">sourcepathref</td>
@@ -109,6 +109,12 @@ to &lt;javadoc&gt; using <tt>classpath</tt>, <tt>classpathref</tt> attributes or
     <td align="center" valign="top">all</td>
   </tr>
   <tr>
+    <td valign="top">modulenames</td>
+    <td valign="top">Comma separated list of module names -- see also
+    the nested <code>module</code> element. <em>since Ant 1.9.14</em></td>
+    <td align="center" valign="top">all</td>
+  </tr>
+  <tr>
     <td valign="top">destdir</td>
     <td valign="top">Destination directory for output files</td>
     <td align="center" valign="top">all</td>
@@ -530,6 +536,36 @@ to &lt;javadoc&gt; using <tt>classpath</tt>, <tt>classpathref</tt> attributes or
     <td align="center" valign="top">1.4</td>
     <td align="center" valign="top">No</td>
   </tr>
+  <tr>
+    <td valign="top">modulesourcepath</td>
+    <td valign="top">Specify where to find module source files
+      <em>since Ant 1.9.14</em></td>
+    <td align="center" valign="top">all</td>
+    <td align="center" valign="top">No</td>
+  </tr>
+  <tr>
+    <td valign="top">modulesourcepathref</td>
+    <td valign="top">Specify where to find module source files by <a
+      href="../using.html#references">reference</a> to a PATH defined elsewhere.
+      <em>since Ant 1.9.14</em></td>
+    <td align="center" valign="top">all</td>
+    <td align="center" valign="top">No</td>
+  </tr>
+  <tr>
+    <td valign="top">modulepath</td>
+    <td valign="top">Specify where to find module files
+      <em>since Ant 1.9.14</em></td>
+    <td align="center" valign="top">all</td>
+    <td align="center" valign="top">No</td>
+  </tr>
+  <tr>
+    <td valign="top">modulepathref</td>
+    <td valign="top">Specify where to find module files by <a
+      href="../using.html#references">reference</a> to a PATH defined elsewhere.
+      <em>since Ant 1.9.14</em></td>
+    <td align="center" valign="top">all</td>
+    <td align="center" valign="top">No</td>
+  </tr>
 </table>
 
 <h4><a name="groupattribute">Format of the group attribute</a></h4>
@@ -607,6 +643,24 @@ javadoc as source files.</p>
 <h5>Parameters</h5>
 Same as for <code>package</code>.
 
+<h4>module</h4>
+<p><em>since Ant 1.9.14</em></p>
+<p>Same as one entry in the list given by <code>modulenames</code>.</p>
+
+<h5>Parameters</h5>
+<table width="90%" border="1" cellpadding="2" cellspacing="0">
+  <tr>
+    <td valign="top"><b>Attribute</b></td>
+    <td valign="top"><b>Description</b></td>
+    <td align="center" valign="top"><b>Required</b></td>
+  </tr>
+  <tr>
+    <td valign="top">name</td>
+    <td valign="top">The module name</td>
+    <td align="center" valign="top">Yes</td>
+  </tr>
+</table>
+
 <h4>source</h4>
 <p>Same as one entry in the list given by <code>sourcefiles</code>.</p>
 
@@ -830,12 +884,13 @@ the javadoc program.
   </tr>
 </table>
 
-<h4>sourcepath, classpath and bootclasspath</h4>
-<p><code>Javadoc</code>'s <i>sourcepath</i>, <i>classpath</i> and
-<i>bootclasspath</i> attributes are <a href="../using.html#path">PATH like
-structure</a> and can also be set via nested <i>sourcepath</i>,
-<i>classpath</i> and <i>bootclasspath</i> elements
-respectively.</p>
+<h4>sourcepath, classpath, bootclasspath, modulepath, modulesourcepath</h4>
+<p><code>Javadoc</code>'s <i>sourcepath</i>, <i>classpath</i>,
+<i>bootclasspath</i>, <i>modulepath</i>, and <i>modulesourcepath</i>
+attributes are <a href="../using.html#path">PATH like structure</a>
+and can also be set via nested <i>sourcepath</i>,
+<i>classpath</i>, <i>bootclasspath</i>, <i>modulepath</i>,
+and <i>modulesourcepath</i> elements respectively.</p>
 
 <h4>arg</h4>
 

http://git-wip-us.apache.org/repos/asf/ant/blob/048015b7/src/main/org/apache/tools/ant/taskdefs/Javadoc.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/Javadoc.java b/src/main/org/apache/tools/ant/taskdefs/Javadoc.java
index 7a5c2ec..999b103 100644
--- a/src/main/org/apache/tools/ant/taskdefs/Javadoc.java
+++ b/src/main/org/apache/tools/ant/taskdefs/Javadoc.java
@@ -37,6 +37,7 @@ import java.util.Collections;
 import java.util.Enumeration;
 import java.util.HashSet;
 import java.util.Iterator;
+import java.util.List;
 import java.util.Locale;
 import java.util.StringTokenizer;
 import java.util.Vector;
@@ -447,11 +448,14 @@ public class Javadoc extends Task {
     private final Vector<SourceFile> sourceFiles = new Vector<SourceFile>();
     private final Vector<PackageName> packageNames = new Vector<PackageName>();
     private final Vector<PackageName> excludePackageNames = new Vector<PackageName>(1);
+    private final List<PackageName> moduleNames = new ArrayList<PackageName>();
     private boolean author = true;
     private boolean version = true;
     private DocletInfo doclet = null;
     private Path classpath = null;
     private Path bootclasspath = null;
+    private Path modulePath = null;
+    private Path moduleSourcePath = null;
     private String group = null;
     private String packageList = null;
     private final Vector<LinkArgument> links = new Vector<LinkArgument>();
@@ -563,6 +567,88 @@ public class Javadoc extends Task {
     }
 
     /**
+     * Specify where to find modules
+     *
+     * @param src a Path instance containing the modules.
+     *
+     * @since Ant 1.9.14
+     */
+    public void setModulePath(final Path mp) {
+        if (modulePath == null) {
+            modulePath = mp;
+        } else {
+            modulePath.append(mp);
+        }
+    }
+
+    /**
+     * Create a path to be configured with the locations of the module
+     * files.
+     *
+     * @return a new Path instance to be configured by the Ant core.
+     *
+     * @since Ant 1.9.14
+     */
+    public Path createModulePath() {
+        if (modulePath == null) {
+            modulePath = new Path(getProject());
+        }
+        return modulePath.createPath();
+    }
+
+    /**
+     * Adds a reference to a path defined elsewhere that defines the module path.
+     *
+     * @param r the reference containing the module path definition.
+     *
+     * @since Ant 1.9.14
+     */
+    public void setModulePathref(final Reference r) {
+        createModulePath().setRefid(r);
+    }
+
+    /**
+     * Specify where to find sources for modules
+     *
+     * @param src a Path instance containing the sources for modules.
+     *
+     * @since Ant 1.9.14
+     */
+    public void setModuleSourcePath(final Path mp) {
+        if (moduleSourcePath == null) {
+            moduleSourcePath = mp;
+        } else {
+            moduleSourcePath.append(mp);
+        }
+    }
+
+    /**
+     * Create a path to be configured with the locations of the module
+     * source files.
+     *
+     * @return a new Path instance to be configured by the Ant core.
+     *
+     * @since Ant 1.9.14
+     */
+    public Path createModuleSourcePath() {
+        if (moduleSourcePath == null) {
+            moduleSourcePath = new Path(getProject());
+        }
+        return moduleSourcePath.createPath();
+    }
+
+    /**
+     * Adds a reference to a path defined elsewhere that defines the module source path.
+     *
+     * @param r the reference containing the module source path definition.
+     *
+     * @since Ant 1.9.14
+     */
+    public void setModuleSourcePathref(final Reference r) {
+        createModuleSourcePath().setRefid(r);
+    }
+
+    /**
      * Set the directory where the Javadoc output will be generated.
      *
      * @param dir the destination directory.
@@ -616,6 +702,23 @@ public class Javadoc extends Task {
     }
 
     /**
+     * Set the module names to be processed.
+     *
+     * @param modules a comma separated list of module names
+     *
+     * @since Ant 1.9.14
+     */
+    public void setModulenames(final String modules) {
+        final StringTokenizer tok = new StringTokenizer(modules, ",");
+        while (tok.hasMoreTokens()) {
+            final String m = tok.nextToken();
+            final PackageName mn = new PackageName();
+            mn.setName(m);
+            addModule(mn);
+        }
+    }
+
+    /**
      * Add a single package to be processed.
      *
      * If the package name ends with &quot;.*&quot; the Javadoc task
@@ -628,6 +731,17 @@ public class Javadoc extends Task {
     }
 
     /**
+     * Add a single module to be processed.
+     *
+     * @param mn the module name
+     *
+     * @since Ant 1.9.14
+     */
+    public void addModule(final PackageName mn) {
+        moduleNames.add(mn);
+    }
+
+    /**
      * Set the list of packages to be excluded.
      *
      * @param packages a comma separated list of packages to be excluded.
@@ -1746,6 +1860,7 @@ public class Javadoc extends Task {
         doGroup(toExecute);    // group attribute
         doGroups(toExecute);  // groups attribute
         doDocFilesSubDirs(toExecute); // docfilessubdir attribute
+        doModuleArguments(toExecute);
 
         doJava14(toExecute);
         if (breakiterator && (doclet == null || JAVADOC_5)) {
@@ -1862,8 +1977,8 @@ public class Javadoc extends Task {
     private void checkPackagesToDoc(
         final Vector<String> packagesToDoc, final Vector<SourceFile> sourceFilesToDoc) {
         if (packageList == null && packagesToDoc.size() == 0
-            && sourceFilesToDoc.size() == 0) {
-            throw new BuildException("No source files and no packages have "
+            && sourceFilesToDoc.size() == 0 && moduleNames.isEmpty()) {
+            throw new BuildException("No source files, no packages and no modules have "
                                      + "been specified.");
         }
     }
@@ -2549,6 +2664,29 @@ public class Javadoc extends Task {
         return fileContents;
     }
 
+    private void doModuleArguments(Commandline toExecute) {
+        if (!moduleNames.isEmpty()) {
+            StringBuilder sb = null;
+            for (PackageName mn : moduleNames) {
+                if (sb == null) {
+                    sb = new StringBuilder(mn.getName());
+                } else {
+                    sb.append(",").append(mn.getName());
+                }
+            }
+            toExecute.createArgument().setValue("--module");
+            toExecute.createArgument().setValue(sb.toString());
+        }
+        if (modulePath != null) {
+            toExecute.createArgument().setValue("--module-path");
+            toExecute.createArgument().setPath(modulePath);
+        }
+        if (moduleSourcePath != null) {
+            toExecute.createArgument().setValue("--module-source-path");
+            toExecute.createArgument().setPath(moduleSourcePath);
+        }
+    }
+
     private class JavadocOutputStream extends LogOutputStream {
         JavadocOutputStream(final int level) {
             super(Javadoc.this, level);