in maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/extractor/annotations/scanner/DefaultMojoAnnotationsScanner.java [224:270]
private void analyzeClassStream(
Map<String, MojoAnnotatedClass> mojoAnnotatedClasses,
InputStream is,
Artifact artifact,
boolean excludeMojo,
String source,
String file)
throws IOException, ExtractionException {
MojoClassVisitor mojoClassVisitor = new MojoClassVisitor();
try {
ClassReader rdr = new ClassReader(is);
rdr.accept(mojoClassVisitor, ClassReader.SKIP_FRAMES | ClassReader.SKIP_CODE | ClassReader.SKIP_DEBUG);
} catch (ArrayIndexOutOfBoundsException aiooe) {
LOGGER.warn(
"Error analyzing class " + file + " in " + source + ": ignoring class",
LOGGER.isDebugEnabled() ? aiooe : null);
return;
} catch (IllegalArgumentException iae) {
if (iae.getMessage() == null) {
LOGGER.warn(
"Error analyzing class " + file + " in " + source + ": ignoring class",
LOGGER.isDebugEnabled() ? iae : null);
return;
} else {
throw iae;
}
}
analyzeVisitors(mojoClassVisitor);
MojoAnnotatedClass mojoAnnotatedClass = mojoClassVisitor.getMojoAnnotatedClass();
if (excludeMojo) {
mojoAnnotatedClass.setMojo(null);
}
if (mojoAnnotatedClass != null) // see MPLUGIN-206 we can have intermediate classes without annotations
{
if (LOGGER.isDebugEnabled() && mojoAnnotatedClass.hasAnnotations()) {
LOGGER.debug(
"found MojoAnnotatedClass:" + mojoAnnotatedClass.getClassName() + ":" + mojoAnnotatedClass);
}
mojoAnnotatedClass.setArtifact(artifact);
mojoAnnotatedClasses.put(mojoAnnotatedClass.getClassName(), mojoAnnotatedClass);
mojoAnnotatedClass.setClassVersion(mojoClassVisitor.getVersion());
}
}