fix(APIScanner): log and continue when one module fails to scan
Addresses the "Scanner TypeAnnotationsScanner was not configured" error we get from Cities.
More "kludge" than "fix," but the sort of thing that's better addressed when we're not on an obsolete version of gestalt-module.
package org.terasology.engine.module;
+import org.reflections.ReflectionsException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.terasology.module.Module;
import org.terasology.module.ModuleRegistry;
import org.terasology.module.sandbox.APIScanner;
* {@inheritDoc}
*/
class APIScannerTolerantOfAssetOnlyModules extends APIScanner {
+ private static final Logger logger = LoggerFactory.getLogger(APIScannerTolerantOfAssetOnlyModules.class);
+
APIScannerTolerantOfAssetOnlyModules(StandardPermissionProviderFactory permissionProviderFactory) {
super(permissionProviderFactory);
}
public void scan(ModuleRegistry registry) {
for (Module module : registry) {
if (module.isOnClasspath() && !IS_ASSET.isProvidedBy(module)) {
+ try {
scan(module);
+ } catch (ReflectionsException e) {
+ // {@link org.terasology.cities} is an example of a module that fails here.
+ // It is not asset-only, but it also doesn't have any of its classes annotated,
+ // and it gets an error about TypeAnnotationScanner configuration here.
+ logger.warn("Scanning module {} failed:", module, e);
+ }
}
}
}
