private Collection scanGroovy()

in winegrower-core/src/main/java/org/apache/winegrower/scanner/StandaloneScanner.java [133:155]


    private Collection<BundleDefinition> scanGroovy() {
        if (loader == null || !loader.getClass().getName().equals("groovy.lang.GroovyClassLoader")) {
            return emptyList();
        }
        try { // groovy - note that the classloader returns classes but not .class as resource so we fail to activate our contributors
            final Class<?>[] loadedClasses = Class[].class.cast(
                    loader.getClass().getMethod("getLoadedClasses").invoke(loader));
            try {
                final Archive archive = new ClassesArchive(loadedClasses);
                final Manifest groovyClassesManifest = tryLoadManifest(archive, "EmbeddedGroovyClasses");
                if (groovyClassesManifest == null) {
                    return emptyList();
                }
                LOGGER.debug("EmbeddedGroovyClasses was scanned and is converted to a bundle");
                return singletonList(new BundleDefinition(groovyClassesManifest, null, emptyList()));
            } catch (final LinkageError e) {
                LOGGER.debug("EmbeddedGroovyClasses is not scannable, maybe exclude it in framework configuration");
                return emptyList();
            }
        } catch (final Exception e) {
            return emptyList();
        }
    }