diff options
author | Stefan Bodewig <bodewig@apache.org> | 2018-09-28 20:42:18 +0200 |
---|---|---|
committer | Stefan Bodewig <bodewig@apache.org> | 2018-09-28 20:42:18 +0200 |
commit | 872a9bcdedc9611e3703cfe739dc53896adce4ee (patch) | |
tree | 99fbb684c711c182fa0e3133f81788fb39f68e43 /src/main/org | |
parent | 24e47067a2ee35cd63597d92ab66a1d410a1f1bf (diff) | |
parent | 048015b7d891edd74c8d458aa582a504511872c6 (diff) | |
download | ant-872a9bcdedc9611e3703cfe739dc53896adce4ee.tar.gz |
Merge branch '1.9.x'
Diffstat (limited to 'src/main/org')
-rw-r--r-- | src/main/org/apache/tools/ant/taskdefs/Javadoc.java | 135 |
1 files changed, 132 insertions, 3 deletions
diff --git a/src/main/org/apache/tools/ant/taskdefs/Javadoc.java b/src/main/org/apache/tools/ant/taskdefs/Javadoc.java index dc0887636..13b8fed37 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Javadoc.java +++ b/src/main/org/apache/tools/ant/taskdefs/Javadoc.java @@ -451,11 +451,14 @@ public class Javadoc extends Task { private final List<SourceFile> sourceFiles = new Vector<>(); private final List<PackageName> packageNames = new Vector<>(); private final List<PackageName> excludePackageNames = new Vector<>(1); + private final List<PackageName> moduleNames = new ArrayList<>(); 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 List<LinkArgument> links = new Vector<>(); @@ -567,6 +570,88 @@ public class Javadoc extends Task { } /** + * Specify where to find modules + * + * @param src a Path instance containing the modules. + * + * @since Ant 1.10.6 + */ + 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.10.6 + */ + 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.10.6 + */ + 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.10.6 + */ + 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.10.6 + */ + 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.10.6 + */ + public void setModuleSourcePathref(final Reference r) { + createModuleSourcePath().setRefid(r); + } + + /** * Set the directory where the Javadoc output will be generated. * * @param dir the destination directory. @@ -620,6 +705,21 @@ public class Javadoc extends Task { } /** + * Set the module names to be processed. + * + * @param modules a comma separated list of module names + * + * @since Ant 1.10.6 + */ + public void setModulenames(final String modules) { + for (String m : modules.split(",")) { + final PackageName mn = new PackageName(); + mn.setName(m); + addModule(mn); + } + } + + /** * Add a single package to be processed. * * If the package name ends with ".*" the Javadoc task @@ -632,6 +732,17 @@ public class Javadoc extends Task { } /** + * Add a single module to be processed. + * + * @param mn the module name + * + * @since Ant 1.10.6 + */ + 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. @@ -1737,6 +1848,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)) { @@ -1852,9 +1964,9 @@ public class Javadoc extends Task { private void checkPackagesToDoc( final List<String> packagesToDoc, final List<SourceFile> sourceFilesToDoc) { if (packageList == null && packagesToDoc.isEmpty() - && sourceFilesToDoc.isEmpty()) { - throw new BuildException( - "No source files and no packages have been specified."); + && sourceFilesToDoc.isEmpty() && moduleNames.isEmpty()) { + throw new BuildException("No source files, no packages and no modules have " + + "been specified."); } } @@ -2479,6 +2591,23 @@ public class Javadoc extends Task { return fileContents; } + private void doModuleArguments(Commandline toExecute) { + if (!moduleNames.isEmpty()) { + toExecute.createArgument().setValue("--module"); + toExecute.createArgument() + .setValue(moduleNames.stream().map(PackageName::getName) + .collect(Collectors.joining(","))); + } + 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); |