in maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/extractor/annotations/JavaAnnotationsMojoDescriptorExtractor.java [242:293]
private JavaProjectBuilder scanJavadoc(
PluginToolsRequest request, Collection<MojoAnnotatedClass> mojoAnnotatedClasses)
throws ExtractionException {
// found artifact from reactors to scan sources
// we currently only scan sources from reactors
List<MavenProject> mavenProjects = new ArrayList<>();
// if we need to scan sources from external artifacts
Set<Artifact> externalArtifacts = new HashSet<>();
JavaProjectBuilder builder = new JavaProjectBuilder(new SortedClassLibraryBuilder());
builder.setEncoding(request.getEncoding());
extendJavaProjectBuilder(builder, request.getProject());
for (MojoAnnotatedClass mojoAnnotatedClass : mojoAnnotatedClasses) {
if (Objects.equals(
mojoAnnotatedClass.getArtifact().getArtifactId(),
request.getProject().getArtifact().getArtifactId())) {
continue;
}
if (!isMojoAnnnotatedClassCandidate(mojoAnnotatedClass)) {
// we don't scan sources for classes without mojo annotations
continue;
}
MavenProject mavenProject =
getFromProjectReferences(mojoAnnotatedClass.getArtifact(), request.getProject());
if (mavenProject != null) {
mavenProjects.add(mavenProject);
} else {
externalArtifacts.add(mojoAnnotatedClass.getArtifact());
}
}
// try to get artifact with sources classifier, extract somewhere then scan for @since, @deprecated
for (Artifact artifact : externalArtifacts) {
// parameter for test-sources too ?? olamy I need that for it test only
if (StringUtils.equalsIgnoreCase("tests", artifact.getClassifier())) {
extendJavaProjectBuilderWithSourcesJar(builder, artifact, request, "test-sources");
} else {
extendJavaProjectBuilderWithSourcesJar(builder, artifact, request, "sources");
}
}
for (MavenProject mavenProject : mavenProjects) {
extendJavaProjectBuilder(builder, mavenProject);
}
return builder;
}