use of org.mule.runtime.extension.api.resources.ResourcesGenerator in project mule by mulesoft.
the class BaseExtensionResourcesGeneratorAnnotationProcessor method process.
@Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
log("Starting Resources generator for Extensions");
ResourcesGenerator generator = new AnnotationProcessorResourceGenerator(fetchResourceFactories(), processingEnv);
try {
getExtension(roundEnv).ifPresent(extensionElement -> {
if (!shouldProcess(extensionElement, processingEnv)) {
return;
}
Optional<Class<Object>> annotatedClass = processor.classFor(extensionElement, processingEnv);
ExtensionElement extension = toExtensionElement(extensionElement, processingEnv);
ClassLoader classLoader = annotatedClass.map(Class::getClassLoader).orElseGet(ExtensionModel.class::getClassLoader);
withContextClassLoader(classLoader, () -> {
ExtensionModel extensionModel = parseExtension(extensionElement, extension, roundEnv, classLoader);
generator.generateFor(extensionModel);
});
});
return false;
} catch (MuleRuntimeException e) {
Optional<IllegalModelDefinitionException> exception = extractOfType(e, IllegalModelDefinitionException.class);
if (exception.isPresent()) {
throw exception.get();
}
processingEnv.getMessager().printMessage(ERROR, format("%s\n%s", e.getMessage(), getStackTrace(e)));
throw e;
}
}
Aggregations