Skip to content

Make the crd-generator-maven-plugin be toolchain aware? #6923

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

Open
ejschoen opened this issue Feb 28, 2025 · 0 comments
Open

Make the crd-generator-maven-plugin be toolchain aware? #6923

ejschoen opened this issue Feb 28, 2025 · 0 comments
Labels
component/crd-generator Related to the CRD generator

Comments

@ejschoen
Copy link

Is your enhancement related to a problem? Please describe

Would it be feasible to make crd-generator-maven-plugin be toolchain aware? My scenario is that the default Java comes from JDK11, but the Java Operator SDK is compiling with JDK17, and I'm trying to build a CRD when I build an operator.

The maven toolchain plugin makes it easy to compile the operator code with JDK17, but the CRD generator errors out suggesting that it's running my default Java (11), which I assume is because mvn itself is running my default JDK:

[ERROR] Failed to execute goal io.fabric8:crd-generator-maven-plugin:7.1.0:generate (default) on project i2k-operator: Execution default of goal io.fabric8:crd-generator-maven-plugin:7.1.0:generate failed: An API incompatibility was encountered while executing io.fabric8:crd-generator-maven-plugin:7.1.0:generate: java.lang.UnsupportedClassVersionError: com/i2kconnect/kubernetes/operator/customresource/Platform has been compiled by a more recent version of the Java Runtime (class file version 61.0), this version of the Java Runtime only recognizes class file versions up to 55.0

This is easy to fix by running JAVA_HOME=/path/to/jdk17 mvn package but it would be nice if the toolchain worked.

Describe the solution you'd like

Add a configuration section to specify the JDK version:

    <plugin>
        <groupId>io.fabric8</groupId>
        <artifactId>crd-generator-maven-plugin</artifactId>
        <version>${fabric8-client.version}</version>
        <executions>
          <execution>
            <goals>
              <goal>generate</goal>
            </goals>
            <configuration>
                <toolchains>
                    <jdk>
                       <version>${jdk.version}</version>
                     </jdk>
                </toolchains>
            <configuration>
          </execution>
        </executions>
      </plugin>

Describe alternatives you've considered

JAVA_HOME=/path/to/jdk17 mvn package

Works, but easy to forget to specify the JAVA_HOME.

Additional context

No response

@manusa manusa moved this to Planned in Eclipse JKube Mar 5, 2025
@manusa manusa added the component/crd-generator Related to the CRD generator label Apr 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/crd-generator Related to the CRD generator
Projects
None yet
Development

No branches or pull requests

2 participants