New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
@Produce(EmptyBuildItem.class) not working #27314
Comments
Hm, I'm still not sure what's going on but I noticed that your build step is annotated with |
Yes, that's intended. I only want to be executed during the build. |
Ok, so I believe that the error message in the @yrodiere I think that the sentence "Use |
@mkouba Ok, it seems I misunderstood that part, indeed (and I'm not the only one as I got the advice to use Your plan makes sense, but I have a question first: is there any reason to forbid using EDIT: I guess one argument to forbid using |
This is actually a very good argument because |
Thanks for your comments, they all make sense to me. |
That raises an interesting question: do we really want the build step marked with Maybe the name should be something like
Gladly, thanks :)
You will have to:
|
Let's also CC others to see if it actually makes sense to create such a build item... @dmlloyd @geoand @gsmet @stuartwdouglas @Sanne @aloubyansky?
@Sgitario You can add a |
FWIW we already have multiple places where we want to execute a build step but don't produce anything. I used Lines 193 to 201 in 56ab22e
Lines 87 to 100 in 95c52f7
|
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 |
I could not find any workaround to my issue. Previously, I was producing a FeatureBuildItem item and everything worked fine until I started using the OpenShift Container Image extension that needs a JAR build item. Here is where the build chain got crazy and I'm sure the issue is related to how the Kubernetes/OpenShift extensions are written. Note I tried to use either |
Well, that's something that needs to be investigated IMO...
I don't think that it's possible. |
Indeed. I've reported an issue to refactor this: #27313 |
I'm skeptical about such a thing to exist as it would easily allow to abuse it to shape extensions in imperative style, throwing much of the potential optimisations out of the window. IMO it's better to have to think a bit more about what actually wants to achieve so to insert the action in the right place of the dependency chain. But since it exists and we're relying on it... OK with that I guess, but let's try to phase it out?
In particular the cases raised by Yoann are interesting and would certainly need some more work; I believe conceptually they could use a dedicated "capabilities integrity phase", but also perhaps they could be better solved when we restructure the dependency chain among these modules. |
It does not exist yet ;-). Some code relies on it but it simply does not work. |
Right I understand that - it's the title of this issue. I mean it's "conceptually relying on it" - but broken. BTW another reason to not have it is that it would be fairly easy to deadlock if this "empty thing" gets widely used and misunderstood. |
In spite of I need this to workaround a blocker issue I have on my side, I agree with @Sanne . By the way, thanks to @yrodiere for your hints! I already added the AlwaysConsumedBuildItem and it worked for me pretty well :) |
We don't have a plan yet - that's what this discussion is for :-)
Definitely not. It was designed for a legal (but different) use case. |
Technically, the few use cases I found are just about validation. We could move them around to a build step within the same extension that we know is always executed, but that might lead to cyclic dependency problems if the validation depends indirectly on the output of that build step. If we provide a better solution, I doubt we'll be able to avoid abuses. But we could "hide" the fact that the new build item is always consumed, by giving it a name that's in relation with the use case (validate the extension), rather than with the solution (always execute the build step). So... what about naming the build item Or, if we really don't want that, we could just use |
In my eyes |
In my use case, I do want to generate resources after the build has finished. This is the exact sequence:
Now, I need a fourth step that consumes GeneratedKubernetesResourceBuildItem and produces nothing:
Nothing I tried it worked for me: either producing either FeatureBuildItem (I can avoid the cycle detected issue, but still not working); or EmptyBuildItem (what this issue is about); or ArtifactResultBuildItem or ServiceStartBuildItem. The only thing that made it work was to create an AlwaysConsumedBuildItem and consumes it at the end of the build item. |
Update: adding ArtifactResultBuildItem made actually it work for me: @BuildStep(onlyIf = { HelmEnabled.class, IsNormal.class })
void generateResources(ApplicationInfoBuildItem app, OutputTargetBuildItem outputTarget,
DekorateOutputBuildItem dekorateOutput,
List<GeneratedKubernetesResourceBuildItem> generatedResources,
// this is added to ensure that the build step will be run
BuildProducer<ArtifactResultBuildItem> dummy) { I took this dummy code snippet from Line 37 in 233f8b8
|
To follow up on the discussion, I think the proper solution would be:
I think a build item |
You mean naming-wise @Sgitario? |
io.quarkus.deployment.pkg.builditem.ArtifactResultBuildItem was actually intended for this situation (even though the javadoc is a bit misleading). It is a multibuilditem to represent multiple outputs from the build, while JarResultBuild item is a specific output. |
If the |
@yrodiere Like @Sgitario mentioned this would not help in his use case.
What we need is effectively a
I don't think that |
It actually is what it was designed to represent: https://github.com/quarkiverse/quarkus-helm/blob/main/deployment/src/main/java/io/quarkiverse/helm/deployment/HelmProcessor.java#L54 Basically every one of these files would be an additional output from the build, so you would create one I know in this particular case it does not matter, but build steps are not really supposed to do things as a 'side effect', they should only produce things the build has asked for, and conceptually in this case the build has asked for all the output artifacts, and these are also output artifacts (just not a runnable jar). |
I see. If that's the case then let's just improve the javadoc and maybe even mention this build step in the docs? @yrodiere WRT |
+1 |
Sure, but that use case is different from the examples that already exist.
Thanks for the hint. If the error is reported at build time, then indeed I should probably use that. |
So to sum up, here's our to-do list:
@Sgitario do you still want to give this a try, or should I have a look? |
It depends whether you're ok with the fact that it's CDI-specific. FTR it's already described here: https://quarkus.io/guides/cdi-integration#use-case-i-need-to-validate-the-deployment |
I am. AFAIK CDI is always included in every Quarkus application and the only places where we currently use
Okay, so a simple link to that part of the documentation might cut it. I'll update the to-do list. |
Sure |
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 linequarkus/core/builder/src/main/java/io/quarkus/builder/BuildStepBuilder.java
Line 204 in 2a41f87
However, this is not working for me. See reproducer.
Expected behavior
No response
Actual behavior
No response
How to Reproduce?
https://github.com/quarkiverse/quarkus-helm
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
orver
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
orgradlew --version
)No response
Additional information
No response
The text was updated successfully, but these errors were encountered: