protected void processResolverClass()

in maven-resolver-tools/src/main/java/org/eclipse/aether/tools/CollectConfiguration.java [244:294]


    protected void processResolverClass(Path path, List<Map<String, String>> discoveredKeys) {
        JavaType<?> type = parse(path);
        if (type instanceof JavaClassSource javaClassSource) {
            javaClassSource.getFields().stream()
                    .filter(this::hasConfigurationSource)
                    .forEach(f -> {
                        Map<String, String> constants = extractConstants(Paths.get(path.toString()
                                .replace("/src/main/java/", "/target/classes/")
                                .replace(".java", ".class")));

                        String name = f.getName();
                        String key = constants.get(name);
                        String fqName = f.getOrigin().getCanonicalName() + "." + name;
                        String configurationType = getConfigurationType(f);
                        String defValue = getTag(f, "@configurationDefaultValue");
                        if (defValue != null && defValue.startsWith("{@link #") && defValue.endsWith("}")) {
                            // constant "lookup"
                            String lookupValue = constants.get(defValue.substring(8, defValue.length() - 1));
                            if (lookupValue == null) {
                                // currently we hard fail if javadoc cannot be looked up
                                // workaround: at cost of redundancy, but declare constants in situ for now
                                // (in same class)
                                throw new IllegalArgumentException(
                                        "Could not look up " + defValue + " for configuration " + fqName);
                            }
                            defValue = lookupValue;
                            if ("java.lang.Long".equals(configurationType)
                                    && (defValue.endsWith("l") || defValue.endsWith("L"))) {
                                defValue = defValue.substring(0, defValue.length() - 1);
                            }
                        }
                        discoveredKeys.add(Map.of(
                                KEY,
                                key,
                                "defaultValue",
                                nvl(defValue, ""),
                                "fqName",
                                fqName,
                                "description",
                                cleanseJavadoc(f),
                                "since",
                                nvl(getSince(f), ""),
                                "configurationSource",
                                getConfigurationSource(f),
                                "configurationType",
                                configurationType,
                                "supportRepoIdSuffix",
                                toYesNo(getTag(f, "@configurationRepoIdSuffix"))));
                    });
        }
    }