use of com.thoughtworks.qdox.library.OrderedClassLibraryBuilder in project maven-plugins by apache.
the class AbstractFixJavadocMojo method getQdoxClasses.
/**
* Calling Qdox to find {@link JavaClass} objects from the Maven project sources.
* Ignore java class if Qdox has parsing errors.
*
* @return an array of {@link JavaClass} found by QDox
* @throws IOException if any
* @throws MojoExecutionException if any
*/
private Collection<JavaClass> getQdoxClasses() throws IOException, MojoExecutionException {
if ("pom".equalsIgnoreCase(project.getPackaging())) {
getLog().warn("This project has 'pom' packaging, no Java sources is available.");
return null;
}
List<File> javaFiles = new LinkedList<>();
for (String sourceRoot : getProjectSourceRoots(project)) {
File f = new File(sourceRoot);
if (f.isDirectory()) {
javaFiles.addAll(FileUtils.getFiles(f, includes, excludes, true));
} else {
if (getLog().isWarnEnabled()) {
getLog().warn(f + " doesn't exist. Ignored it.");
}
}
}
ClassLibraryBuilder classLibraryBuilder = new OrderedClassLibraryBuilder();
classLibraryBuilder.appendClassLoader(getProjectClassLoader());
JavaProjectBuilder builder = new JavaProjectBuilder(classLibraryBuilder);
builder.setEncoding(encoding);
for (File f : javaFiles) {
if (!f.getAbsolutePath().toLowerCase(Locale.ENGLISH).endsWith(".java") && getLog().isWarnEnabled()) {
getLog().warn("'" + f + "' is not a Java file. Ignored it.");
continue;
}
try {
builder.addSource(f);
} catch (ParseException e) {
if (getLog().isWarnEnabled()) {
getLog().warn("QDOX ParseException: " + e.getMessage() + ". Can't fix it.");
}
}
}
return builder.getClasses();
}
Aggregations