Skip to content

Remove javapoet dependency #3555

Description

@fs-alecbg

Is your feature request related to a problem? Please describe.
Javapoet has not been updated since 2024. At my work, this has made it be deemed an end of life package and thus not approved for use. This blocks our use of the java-operator-sdk library.

Describe the solution you'd like
Remove java poet as a dependency, it's barely used in this codebase (only in io.javaoperatorsdk.operator.config.runtime.ControllerConfigurationAnnotationProcessor) and can be quite trivially swapped out for methods from the standard library.

Describe alternatives you've considered
Sadly none

Additional context

My understanding is that javapoet was used back in 2020 for version 4 of the fabric8 client, but since upgrading to version 5 of fabric8 it's basically not needed anymore.

This is the necessary diff to the main source code

--- a/operator-framework/src/main/java/io/javaoperatorsdk/operator/config/runtime/ControllerConfigurationAnnotationProcessor.java
+++ b/operator-framework/src/main/java/io/javaoperatorsdk/operator/config/runtime/ControllerConfigurationAnnotationProcessor.java
@@ -34,8 +34,6 @@ import org.slf4j.LoggerFactory;
 import io.fabric8.kubernetes.client.CustomResource;
 import io.javaoperatorsdk.operator.api.reconciler.Reconciler;
 
-import com.squareup.javapoet.TypeName;
-
 import static io.javaoperatorsdk.operator.config.runtime.RuntimeControllerMetadata.RECONCILERS_RESOURCE_PATH;
 
 @SupportedAnnotationTypes("io.javaoperatorsdk.operator.api.reconciler.ControllerConfiguration")
@@ -103,9 +101,12 @@ public class ControllerConfigurationAnnotationProcessor extends AbstractProcesso
                 + "': ignoring!");
         return;
       }
-      final TypeName customResourceType = TypeName.get(resourceType);
+      // the resolved resource type is always a declared type, so its element is a TypeElement
+      final var customResourceType =
+          (TypeElement) processingEnv.getTypeUtils().asElement(resourceType);
       controllersResourceWriter.add(
-          controllerClassSymbol.getQualifiedName().toString(), customResourceType.toString());
+          controllerClassSymbol.getQualifiedName().toString(),
+          customResourceType.getQualifiedName().toString());

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions