Search in sources :

Example 6 with GeneratedBeanBuildItem

use of io.quarkus.arc.deployment.GeneratedBeanBuildItem in project quarkus-github-action by quarkiverse.

the class GitHubActionProcessor method generateClasses.

@BuildStep
void generateClasses(CombinedIndexBuildItem combinedIndex, LaunchModeBuildItem launchMode, BuildProducer<AdditionalBeanBuildItem> additionalBeans, BuildProducer<GeneratedBeanBuildItem> generatedBeans, BuildProducer<GeneratedClassBuildItem> generatedClasses, BuildProducer<ReflectiveClassBuildItem> reflectiveClasses, BuildProducer<AnnotationsTransformerBuildItem> annotationsTransformer) {
    Collection<EventDefinition> allEventDefinitions = getAllEventDefinitions(combinedIndex.getIndex());
    // Add @Vetoed to all the user-defined event listening classes
    annotationsTransformer.produce(new AnnotationsTransformerBuildItem(new VetoUserDefinedEventListeningClassesAnnotationsTransformer(allEventDefinitions.stream().map(d -> d.getAnnotation()).collect(Collectors.toSet()))));
    // Add the qualifiers as beans
    String[] subscriberAnnotations = allEventDefinitions.stream().map(d -> d.getAnnotation().toString()).toArray(String[]::new);
    additionalBeans.produce(new AdditionalBeanBuildItem(subscriberAnnotations));
    additionalBeans.produce(new AdditionalBeanBuildItem(Action.class));
    DispatchingConfiguration dispatchingConfiguration = getDispatchingConfiguration(combinedIndex.getIndex(), allEventDefinitions);
    ClassOutput classOutput = new GeneratedClassGizmoAdaptor(generatedClasses, true);
    generateAnnotationLiterals(classOutput, dispatchingConfiguration);
    ClassOutput beanClassOutput = new GeneratedBeanGizmoAdaptor(generatedBeans);
    generatePayloadTypeResolver(beanClassOutput, reflectiveClasses, allEventDefinitions);
    generateActionMain(beanClassOutput, combinedIndex, launchMode, dispatchingConfiguration, reflectiveClasses);
    generateMultiplexers(beanClassOutput, dispatchingConfiguration, reflectiveClasses);
}
Also used : DotNames(io.quarkus.arc.processor.DotNames) GeneratedClassGizmoAdaptor(io.quarkus.deployment.GeneratedClassGizmoAdaptor) Arrays(java.util.Arrays) MethodVisitor(org.objectweb.asm.MethodVisitor) PayloadTypeResolver(io.quarkiverse.githubaction.runtime.PayloadTypeResolver) ClassOutput(io.quarkus.gizmo.ClassOutput) RunTimeConfigurationDefaultBuildItem(io.quarkus.deployment.builditem.RunTimeConfigurationDefaultBuildItem) ClassInfo(org.jboss.jandex.ClassInfo) CombinedIndexBuildItem(io.quarkus.deployment.builditem.CombinedIndexBuildItem) BuildProducer(io.quarkus.deployment.annotations.BuildProducer) GeneratedBeanBuildItem(io.quarkus.arc.deployment.GeneratedBeanBuildItem) MethodInfo(org.jboss.jandex.MethodInfo) Context(io.quarkiverse.githubaction.Context) AdditionalBeanBuildItem(io.quarkus.arc.deployment.AdditionalBeanBuildItem) FeatureBuildItem(io.quarkus.deployment.builditem.FeatureBuildItem) AnnotationLiteral(javax.enterprise.util.AnnotationLiteral) Map(java.util.Map) BytecodeCreator(io.quarkus.gizmo.BytecodeCreator) GHEventPayload(org.kohsuke.github.GHEventPayload) ConfigFileReader(io.quarkiverse.githubaction.runtime.ConfigFileReader) MethodParameterInfo(org.jboss.jandex.MethodParameterInfo) ClassVisitor(org.objectweb.asm.ClassVisitor) GitHub(org.kohsuke.github.GitHub) AnnotationsTransformerBuildItem(io.quarkus.arc.deployment.AnnotationsTransformerBuildItem) ActionDispatchingConfiguration(io.quarkiverse.githubaction.deployment.DispatchingConfiguration.ActionDispatchingConfiguration) AnnotationValue(org.jboss.jandex.AnnotationValue) ReflectiveHierarchyBuildItem(io.quarkus.deployment.builditem.nativeimage.ReflectiveHierarchyBuildItem) EventAnnotationLiteral(io.quarkiverse.githubaction.deployment.DispatchingConfiguration.EventAnnotationLiteral) Collection(java.util.Collection) Set(java.util.Set) ActionLiteral(io.quarkiverse.githubaction.Action.ActionLiteral) BuiltinScope(io.quarkus.arc.processor.BuiltinScope) Collectors(java.util.stream.Collectors) MethodDescriptors(io.quarkus.arc.processor.MethodDescriptors) List(java.util.List) GitHubEvent(io.quarkiverse.githubaction.runtime.GitHubEvent) GitHubApiClassWithBridgeMethodsBuildItem(io.quarkiverse.githubapi.deployment.GitHubApiClassWithBridgeMethodsBuildItem) ActionDispatchingMethod(io.quarkiverse.githubaction.deployment.DispatchingConfiguration.ActionDispatchingMethod) Actions(io.quarkiverse.githubapp.event.Actions) AnnotationInstance(org.jboss.jandex.AnnotationInstance) Modifier(java.lang.reflect.Modifier) Annotation(java.lang.annotation.Annotation) Entry(java.util.Map.Entry) Optional(java.util.Optional) Multiplexer(io.quarkiverse.githubaction.runtime.Multiplexer) HashUtil(io.quarkus.runtime.util.HashUtil) ResultHandle(io.quarkus.gizmo.ResultHandle) ReflectiveClassBuildItem(io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem) Logger(org.jboss.logging.Logger) MethodCreator(io.quarkus.gizmo.MethodCreator) DotName(org.jboss.jandex.DotName) Type(org.jboss.jandex.Type) AnnotatedElement(io.quarkus.gizmo.AnnotatedElement) HashMap(java.util.HashMap) ClassCreator(io.quarkus.gizmo.ClassCreator) Singleton(javax.inject.Singleton) TreeSet(java.util.TreeSet) ArrayList(java.util.ArrayList) EVENT(io.quarkiverse.githubaction.deployment.GitHubActionDotNames.EVENT) Inject(javax.inject.Inject) BuildStep(io.quarkus.deployment.annotations.BuildStep) INJECTABLE_TYPES(io.quarkiverse.githubaction.deployment.GitHubActionDotNames.INJECTABLE_TYPES) Kind(org.jboss.jandex.AnnotationTarget.Kind) EventAnnotation(io.quarkiverse.githubaction.deployment.DispatchingConfiguration.EventAnnotation) Gizmo(io.quarkus.gizmo.Gizmo) PrintStream(java.io.PrintStream) Event(javax.enterprise.event.Event) IndexView(org.jboss.jandex.IndexView) Opcodes(org.objectweb.asm.Opcodes) MethodDescriptor(io.quarkus.gizmo.MethodDescriptor) CONFIG_FILE(io.quarkiverse.githubaction.deployment.GitHubActionDotNames.CONFIG_FILE) GitHubEventHandler(io.quarkiverse.githubaction.runtime.GitHubEventHandler) FieldDescriptor(io.quarkus.gizmo.FieldDescriptor) Action(io.quarkiverse.githubaction.Action) GeneratedBeanGizmoAdaptor(io.quarkus.arc.deployment.GeneratedBeanGizmoAdaptor) ACTION(io.quarkiverse.githubaction.deployment.GitHubActionDotNames.ACTION) GeneratedClassBuildItem(io.quarkus.deployment.builditem.GeneratedClassBuildItem) LaunchModeBuildItem(io.quarkus.deployment.builditem.LaunchModeBuildItem) FieldCreator(io.quarkus.gizmo.FieldCreator) BytecodeTransformerBuildItem(io.quarkus.deployment.builditem.BytecodeTransformerBuildItem) Collections(java.util.Collections) AdditionalBeanBuildItem(io.quarkus.arc.deployment.AdditionalBeanBuildItem) Action(io.quarkiverse.githubaction.Action) GeneratedBeanGizmoAdaptor(io.quarkus.arc.deployment.GeneratedBeanGizmoAdaptor) GeneratedClassGizmoAdaptor(io.quarkus.deployment.GeneratedClassGizmoAdaptor) AnnotationsTransformerBuildItem(io.quarkus.arc.deployment.AnnotationsTransformerBuildItem) ActionDispatchingConfiguration(io.quarkiverse.githubaction.deployment.DispatchingConfiguration.ActionDispatchingConfiguration) ClassOutput(io.quarkus.gizmo.ClassOutput) BuildStep(io.quarkus.deployment.annotations.BuildStep)

Aggregations

GeneratedBeanBuildItem (io.quarkus.arc.deployment.GeneratedBeanBuildItem)6 ArrayList (java.util.ArrayList)4 DotName (org.jboss.jandex.DotName)4 AdditionalBeanBuildItem (io.quarkus.arc.deployment.AdditionalBeanBuildItem)3 GeneratedBeanGizmoAdaptor (io.quarkus.arc.deployment.GeneratedBeanGizmoAdaptor)3 BuildProducer (io.quarkus.deployment.annotations.BuildProducer)3 BuildStep (io.quarkus.deployment.annotations.BuildStep)3 CombinedIndexBuildItem (io.quarkus.deployment.builditem.CombinedIndexBuildItem)3 FeatureBuildItem (io.quarkus.deployment.builditem.FeatureBuildItem)3 ReflectiveClassBuildItem (io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem)3 ClassInfo (org.jboss.jandex.ClassInfo)3 MethodInfo (org.jboss.jandex.MethodInfo)3 GitHubApiClassWithBridgeMethodsBuildItem (io.quarkiverse.githubapi.deployment.GitHubApiClassWithBridgeMethodsBuildItem)2 Actions (io.quarkiverse.githubapp.event.Actions)2 ClassCreator (io.quarkus.gizmo.ClassCreator)2 FieldCreator (io.quarkus.gizmo.FieldCreator)2 MethodCreator (io.quarkus.gizmo.MethodCreator)2 MethodDescriptor (io.quarkus.gizmo.MethodDescriptor)2 ResultHandle (io.quarkus.gizmo.ResultHandle)2 Modifier (java.lang.reflect.Modifier)2