quarkus: @Produce(EmptyBuildItem.class) not working
Describe the bug
As suggested in a comment, when a build step is not producing any build item, we can annotate with @Produce(EmptyBuildItem.class) and the build step is going to be invoked always. See line https://github.com/quarkusio/quarkus/blob/2a41f877abb93112b5bd58d56165c2c06e64aa3a/core/builder/src/main/java/io/quarkus/builder/BuildStepBuilder.java#L204.
However, this is not working for me. See reproducer.
Expected behavior
No response
Actual behavior
No response
How to Reproduce?
- git clone
https://github.com/quarkiverse/quarkus-helm - cd quarkus-helm
- git branch avoid_both_extensions
- mvn clean install
The build fails because the resources are not generated (if @Produce(EmptyBuildItem.class) would work, the resources would be generated (see main branch).
Output of uname -a or ver
No response
Output of java -version
No response
GraalVM version (if different from Java)
No response
Quarkus version or git rev
No response
Build tool (ie. output of mvnw --version or gradlew --version)
No response
Additional information
No response
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 36 (36 by maintainers)
Commits related to this issue
- Clarify ValidationErrorBuildItem/ArtifactResultBuildItem/EmptyBuildItem Fix https://github.com/quarkusio/quarkus/issues/27314 — committed to Sgitario/quarkus by Sgitario 2 years ago
- Clarify ValidationErrorBuildItem/ArtifactResultBuildItem/EmptyBuildItem Fix https://github.com/quarkusio/quarkus/issues/27314 — committed to Sgitario/quarkus by Sgitario 2 years ago
- Clarify ValidationErrorBuildItem/ArtifactResultBuildItem/EmptyBuildItem Fix https://github.com/quarkusio/quarkus/issues/27314 — committed to Sgitario/quarkus by Sgitario 2 years ago
- Clarify ValidationErrorBuildItem/ArtifactResultBuildItem/EmptyBuildItem Fix https://github.com/quarkusio/quarkus/issues/27314 — committed to Sgitario/quarkus by Sgitario 2 years ago
- Clarify ValidationErrorBuildItem/ArtifactResultBuildItem/EmptyBuildItem Fix https://github.com/quarkusio/quarkus/issues/27314 — committed to Sgitario/quarkus by Sgitario 2 years ago
- Clarify ValidationErrorBuildItem/ArtifactResultBuildItem/EmptyBuildItem Fix https://github.com/quarkusio/quarkus/issues/27314 — committed to Sgitario/quarkus by Sgitario 2 years ago
- Clarify ValidationErrorBuildItem/ArtifactResultBuildItem/EmptyBuildItem Fix https://github.com/quarkusio/quarkus/issues/27314 — committed to fercomunello/quarkus by Sgitario 2 years ago
- Clarify ValidationErrorBuildItem/ArtifactResultBuildItem/EmptyBuildItem Fix https://github.com/quarkusio/quarkus/issues/27314 — committed to nenros/quarkus by Sgitario 2 years ago
It does not exist yet 😉. Some code relies on it but it simply does not work.
Well, that’s something that needs to be investigated IMO…
I don’t think that it’s possible.
I think it does make sense to create such a build item given some people were expecting it to work anyway.
As for the name, I think I would prefer
AlwaysConsumedBuildItem.That raises an interesting question: do we really want the build step marked with
@Produce(AlwaysConsumedBuildItem.class)to always be executed? E.g. I know we somehow consume a particular build item when generating dev services configuration; surely we don’t want to execute the build step then?Maybe the name should be something like
ExtensionCompleteBuildItem, to convey the meaning “the extension can only be considered complete once all those build items have been produced”? Then it would make sense to execute various checks in build steps that produce that build item.Gladly, thanks 😃
You will have to:
EmptyBuildItem(if EmptyBuildItem.class.equals(itemId.getType()) { throw ... })AlwaysConsumedBuildItemorExtensionCompleteBuildItem, but I’m fine with anything else, really)EmptyBuildItem?)AlwaysConsumedBuildItemis indeed always consumed. @mkouba might have a hint about that; I believe initializingio.quarkus.builder.BuildChainBuilder#finalIdswith the id ofAlwaysConsumedBuildItemmight do the trick.io.quarkus.builder.BasicTestsintegration-tests/test-extension/extension/deployment/src/test. Maybe add a build step with@Produce(AlwaysConsumedBuildItem)to the test extension, have that build step set some static variable, and check in the test that the variable was set?docs/src/main/asciidoc/writing-extensions.adocto mention that new build item, probably in the same section that mentionsEmptyBuildItem.