@@ -118,32 +118,47 @@ public class JavadocUtil {
118118 + "environment variable using -Xms:<size> and -Xmx:<size>." ;
119119
120120 /**
121- * Method that removes the invalid directories in the specified directories. <b>Note</b>: All elements in
122- * <code>dirs</code> could be an absolute or relative against the project's base directory <code>String</code> path.
121+ * Method that removes invalid classpath elements in the specified paths.
122+ * <b>Note</b>: All elements in {@code paths} could be absolute or relative against the project's base directory.
123+ * When pruning classpath elements, you can optionally include files in the result, otherwise only directories are
124+ * permitted.
123125 *
124126 * @param project the current Maven project not null
125- * @param dirs the collection of <code>String</code> directories path that will be validated.
126- * @return a List of valid <code>String</code> directories absolute paths.
127+ * @param paths the collection of paths that will be validated
128+ * @param includeFiles whether to include files in the result as well
129+ * @return a list of valid classpath elements as absolute paths
127130 */
128- public static Collection <Path > pruneDirs (MavenProject project , Collection <String > dirs ) {
131+ public static Collection <Path > prunePaths (MavenProject project , Collection <String > paths , boolean includeFiles ) {
129132 final Path projectBasedir = project .getBasedir ().toPath ();
130133
131- Set <Path > pruned = new LinkedHashSet <>(dirs .size ());
132- for (String dir : dirs ) {
133- if (dir == null ) {
134+ Set <Path > pruned = new LinkedHashSet <>(paths .size ());
135+ for (String path : paths ) {
136+ if (path == null ) {
134137 continue ;
135138 }
136139
137- Path directory = projectBasedir .resolve (dir );
140+ Path resolvedPath = projectBasedir .resolve (path );
138141
139- if (Files .isDirectory (directory )) {
140- pruned .add (directory .toAbsolutePath ());
142+ if (Files .isDirectory (resolvedPath ) || includeFiles && Files . isRegularFile ( resolvedPath )) {
143+ pruned .add (resolvedPath .toAbsolutePath ());
141144 }
142145 }
143146
144147 return pruned ;
145148 }
146149
150+ /**
151+ * Method that removes the invalid classpath directories in the specified directories.
152+ * <b>Note</b>: All elements in {@code dirs} could be absolute or relative against the project's base directory.
153+ *
154+ * @param project the current Maven project not null
155+ * @param dirs the collection of directories that will be validated
156+ * @return a list of valid claspath elements as absolute paths
157+ */
158+ public static Collection <Path > pruneDirs (MavenProject project , Collection <String > dirs ) {
159+ return prunePaths (project , dirs , false );
160+ }
161+
147162 /**
148163 * Method that removes the invalid files in the specified files. <b>Note</b>: All elements in <code>files</code>
149164 * should be an absolute <code>String</code> path.
0 commit comments