javaquarkusbuild-timequarkus-extension

Disable beans with build time property in my quarkus extension


I am writing a quarkus extension. This extension includes a capability, which should be disableable by build property.

I accordingly annotated the beans of this optional capability with @IfBuildProperty(name = "myProperty", stringValue = "true")

In my deployment Processor class, I am adding the beans via AdditionalBeanBuildItem.

When using this extension in my project, the ifBuildProperty seems to be ignored, as the bean is still available even if myProperty is not set to true.

How can I disable a bean of a custom extension via build property? Can I somehow skip the whole build step that add the beans as AdditionalBeanBuildItem?


Solution

  • You simply need to make the beans of your extension discoverable. There are multiple ways to do this, but the easiest would be to add an empty META-INF/beans.xml file to src/main/resources of the runtime part of your extension.