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
Double generation from CRD to Java and back to CRD #4351
Comments
Maybe you want to separate the Java Generation into a separate module. AFAIK you cannot disable an annotation processor for specific parts of the code. So considering
|
@manusa Thanks for replying! Yeah that's indeed a good workaround, although it may feel slightly overcomplicated for a small code base. I think I will be fine to live with the fact that there are duplicates, which doesn't do any harm. Please feel free to close this issue or keep it open if you plan to document this type of things. |
We should either document this, or work on something code-wise to prevent this from happening. Maybe the CRD generator can be tuned to detect if a Java Class was generated by the client Java-Generator. |
Right that is a possible solution. So for generated code, it is usually a good practice to use import javax.annotation.processing.Generated;
@Generated("...")
@io.fabric8.kubernetes.model.annotation.Version(value = "v1", storage = true, served = true)
@io.fabric8.kubernetes.model.annotation.Group("com.example")
public class Foo
extends io.fabric8.kubernetes.client.CustomResource<
FooSpec,
FooStatus>
implements io.fabric8.kubernetes.api.model.Namespaced {} So the CRD generator could look at the annotation to skip a file. |
I guess, better to have some identity so it won't skip other generated files, |
I checked and there is, at the moment, no easy way to disable the CRD generator on a particular CRD and the separation @manusa suggested is the only viable option. That said I'm all in for adding The only suggestion(if it's not me going to implement it) is to make it configurable (even a hidden configuration is fine) to not prevent testing the two generators as we are doing in the |
Describe the bug
I have the use case that I need to both generate CDR from Java, as well as generating Java from CDR. So I have both the annotation processor and maven plugin configured.
From what I can see, the maven plugin runs first and it generates Java code, and then the annotation processor kicks in, which totally makes sense because before compilation code needs to be generated.
The result is a roundtrip happens for the CDR and I get the generated one under
/META-INF/fabric8
along with the original one in a different place. This is not a real problem, but could be confusing.Fabric8 Kubernetes Client version
6.0.0
Steps to reproduce
Configure annotation processor
Configure maven plugin
Compile
mvn compile
Expected behavior
Maybe there is a way to configure the annotation processor to skip generated code that I'm not aware of. The expected behaviour is not to generate CDR form generated code.
Runtime
Kubernetes (vanilla)
Kubernetes API Server version
1.24.2@latest
Environment
macOS
Fabric8 Kubernetes Client Logs
Additional context
For a reason I have to use
5.12.3
annotation processor, but6.0.0
maven plugin. Not sure whether that matters.The text was updated successfully, but these errors were encountered: