-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
CRD Generator maven plugin fails to detect CustomResources that are located in test sources #6683
Comments
Ok looks like you ran directly into the most tricky part.^^ First some background, details can be found here:
In your case, if you want to generate CRDs for CustomResource classes from your test classes only, you have to configure the maven plugin in the following way: <plugin>
<groupId>io.fabric8</groupId>
<artifactId>crd-generator-maven-plugin</artifactId>
<version>${fabric8-client.version}</version>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
<phase>process-test-classes</phase>
<configuration>
<classesToScan>${project.build.testOutputDirectory}</classesToScan>
<classpath>WITH_ALL_DEPENDENCIES_AND_TESTS</classpath>
</configuration>
</execution>
</executions>
</plugin>
Please note that this will output the CRDs in <plugin>
<groupId>io.fabric8</groupId>
<artifactId>crd-generator-maven-plugin</artifactId>
<version>${fabric8-client.version}</version>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
<phase>process-test-classes</phase>
<configuration>
<classesToScan>${project.build.testOutputDirectory}</classesToScan>
<classpath>WITH_ALL_DEPENDENCIES_AND_TESTS</classpath>
<outputDirectory>${project.build.testOutputDirectory}</outputDirectory>
</configuration>
</execution>
</executions>
</plugin> |
Describe the bug
I have tests that rely on being able to deploy the CRD associated with test custom resources. However, this currently doesn't work with the maven plugin. I've tried to use the
configuration option but this didn't change anything. Looking at the code of the plugin, it seems as if the classpath only takes effect for loading the custom resource classes, not when indexing, which means that the classes are never detected. I've tried to change the plugin code but the tests are now failing in an obscure way and that's about as far as I got tonight 😅
That's the modification I made:
the idea being that if a user wants to change the lookup classpath, then the corresponding elements should probably also be indexed.
This actually raises another issue (for which I might create a separate ticket but still mentioning it here): we need another scope that includes only the runtime and test scopes instead of forcing everything just to get the test scope.
/cc @baloo42
Fabric8 Kubernetes Client version
SNAPSHOT
Steps to reproduce
You can see an example of the failure at operator-framework/java-operator-sdk#2540
Expected behavior
CRDs should also be generated for test classes if requested (and it should be easy to configure the plugin to also consider test classes).
Runtime
Kubernetes (vanilla)
Kubernetes API Server version
next (development version)
Environment
macOS
Fabric8 Kubernetes Client Logs
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: