0

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?

Herr Derb
  • 4,977
  • 5
  • 34
  • 62
  • You likely 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. – geoand Jan 11 '23 at 07:12
  • Simple as... That's it. Adding the beans via `AdditionalBeanBuildItem` apparently does not apply `IfBuildProperty`. I still got to learn a lot about extensions... Thank you for your ubiquitousness :) – Herr Derb Jan 11 '23 at 08:35
  • You are welcome :). I will add the comment as answer so future users can easily see it without having to read the comments. – geoand Jan 11 '23 at 13:30

1 Answers1

1

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.

geoand
  • 60,071
  • 24
  • 172
  • 190