diff --git a/extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/StartupBuildSteps.java b/extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/StartupBuildSteps.java index 8261d2e093c54..d215861b37a5b 100644 --- a/extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/StartupBuildSteps.java +++ b/extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/StartupBuildSteps.java @@ -1,6 +1,5 @@ package io.quarkus.arc.deployment; -import javax.enterprise.context.ApplicationScoped; import javax.enterprise.context.spi.Contextual; import javax.enterprise.context.spi.CreationalContext; @@ -18,8 +17,6 @@ import io.quarkus.arc.deployment.ObserverRegistrationPhaseBuildItem.ObserverConfiguratorBuildItem; import io.quarkus.arc.impl.CreationalContextImpl; import io.quarkus.arc.processor.AnnotationStore; -import io.quarkus.arc.processor.Annotations; -import io.quarkus.arc.processor.AnnotationsTransformer; import io.quarkus.arc.processor.BeanInfo; import io.quarkus.arc.processor.BuildExtension; import io.quarkus.arc.processor.BuiltinScope; @@ -51,26 +48,13 @@ public class StartupBuildSteps { private static final Logger LOGGER = Logger.getLogger(StartupBuildSteps.class); @BuildStep - AnnotationsTransformerBuildItem annotationTransformer(CustomScopeAnnotationsBuildItem customScopes) { - return new AnnotationsTransformerBuildItem(new AnnotationsTransformer() { - - @Override - public boolean appliesTo(org.jboss.jandex.AnnotationTarget.Kind kind) { - return kind == org.jboss.jandex.AnnotationTarget.Kind.CLASS; - } - - @Override - public void transform(TransformationContext context) { - if (context.isClass() && !customScopes.isScopeDeclaredOn(context.getTarget().asClass())) { - // Class with no built-in scope annotation but with @Scheduled method - if (Annotations.contains(context.getTarget().asClass().classAnnotations(), STARTUP_NAME)) { - LOGGER.debugf("Found @Startup on a class %s with no scope annotations - adding @ApplicationScoped", - context.getTarget()); - context.transform().add(ApplicationScoped.class).done(); - } - } - } - }); + AutoAddScopeBuildItem addScope(CustomScopeAnnotationsBuildItem customScopes) { + // Class with no built-in scope annotation but with @Startup method + return AutoAddScopeBuildItem.builder() + .defaultScope(BuiltinScope.APPLICATION) + .isAnnotatedWith(STARTUP_NAME) + .reason("Found classes containing @Startup annotation.") + .build(); } @BuildStep