private Map extractMethodsAnnotations()

in maven-plugin-tools-annotations/src/main/java/org/apache/maven/tools/plugin/extractor/annotations/JavaAnnotationsMojoDescriptorExtractor.java [504:548]


    private Map<String, JavaAnnotatedElement> extractMethodsAnnotations(
            JavaClass javaClass, Map<String, JavaClass> javaClassesMap) {
        try {
            Map<String, JavaAnnotatedElement> rawParams = new TreeMap<>();

            // we have to add the parent methods first, so that they will be overwritten by the local methods if
            // that actually happens...
            JavaClass superClass = javaClass.getSuperJavaClass();

            if (superClass != null) {
                if (!superClass.getMethods().isEmpty()) {
                    rawParams = extractMethodsAnnotations(superClass, javaClassesMap);
                }
                // maybe sources comes from scan of sources artifact
                superClass = javaClassesMap.get(superClass.getFullyQualifiedName());
                if (superClass != null && !superClass.getMethods().isEmpty()) {
                    rawParams = extractMethodsAnnotations(superClass, javaClassesMap);
                }
            } else {

                rawParams = new TreeMap<>();
            }

            for (JavaMethod method : javaClass.getMethods()) {
                if (isPublicSetterMethod(method)) {
                    rawParams.put(
                            StringUtils.lowercaseFirstLetter(method.getName().substring(3)), method);
                }
            }

            return rawParams;
        } catch (NoClassDefFoundError e) {
            if (e.getMessage().replace('/', '.').contains(MojoAnnotationsScanner.V4_API_PLUGIN_PACKAGE)) {
                return new TreeMap<>();
            }
            String str;
            try {
                str = javaClass.getFullyQualifiedName();
            } catch (Throwable t) {
                str = javaClass.getValue();
            }
            LOGGER.warn("Failed extracting methods from " + str);
            throw (NoClassDefFoundError) new NoClassDefFoundError(e.getMessage()).initCause(e);
        }
    }