public void execute()

in src/main/java/org/apache/sling/maven/bundlesupport/GenerateAdapterMetadataMojo.java [87:129]


    public void execute() throws MojoExecutionException, MojoFailureException {
        final Map<String, Object> descriptor = new HashMap<>();
        ClassGraph classGraph = new ClassGraph()
                .enableAnnotationInfo() // only consider annotation info
                .overrideClasspath(
                        buildOutputDirectory) // just the classpath of the output directory needed (annotation classes
                // themselves not relevant)
                .enableExternalClasses();
        if (getLog().isDebugEnabled()) {
            classGraph.verbose();
        }
        try (ScanResult result = classGraph.scan()) {
            ClassInfoList classInfoList = result.getClassesWithAnnotation(Adaptable.class);
            classInfoList = classInfoList.union(result.getClassesWithAnnotation(Adaptables.class));

            for (ClassInfo annotationClassInfo : classInfoList) {
                getLog().info(String.format("found adaptable annotation on %s", annotationClassInfo.getSimpleName()));
                for (AnnotationInfo annotationInfo :
                        annotationClassInfo.getAnnotationInfo().filter(new AdaptableAnnotationInfoFilter())) {
                    AnnotationParameterValueList annotationParameterValues = annotationInfo.getParameterValues();
                    if (annotationInfo.getName().equals(Adaptables.class.getName())) {
                        parseAdaptablesAnnotation(
                                annotationParameterValues, annotationClassInfo.getSimpleName(), descriptor);
                    } else if (annotationInfo.getName().equals(Adaptable.class.getName())) {
                        parseAdaptableAnnotation(
                                annotationParameterValues, annotationClassInfo.getSimpleName(), descriptor);
                    } else {
                        throw new IllegalStateException("Unexpected annotation class found: " + annotationInfo);
                    }
                }
            }

            final File outputFile = new File(outputDirectory, fileName);
            outputFile.getParentFile().mkdirs();
            try (FileWriter writer = new FileWriter(outputFile);
                    JsonWriter jsonWriter = Json.createWriter(writer)) {
                jsonWriter.writeObject(JsonSupport.toJson(descriptor));
            }

        } catch (IOException | JsonException e) {
            throw new MojoExecutionException("Unable to generate metadata", e);
        }
    }