From 1f3f9ea5d2a144c6beb87f5cd1df4015abc179a0 Mon Sep 17 00:00:00 2001 From: Geri Shehu Date: Fri, 23 Aug 2024 11:38:19 +0200 Subject: [PATCH] FileSystemNotFoundException was thrown when listing manifest files. --- annotation-processor/pom.xml | 2 +- .../clockify/annotationprocessor/Constants.java | 6 ++++++ .../ManifestExtensionProcessor.java | 4 +++- .../cake/clockify/annotationprocessor/Utils.java | 16 ---------------- 4 files changed, 10 insertions(+), 18 deletions(-) diff --git a/annotation-processor/pom.xml b/annotation-processor/pom.xml index fe0d761..6a505d3 100644 --- a/annotation-processor/pom.xml +++ b/annotation-processor/pom.xml @@ -6,7 +6,7 @@ com.cake.clockify addon-sdk-annotation-processor - 1.0.8 + 1.0.9 17 diff --git a/annotation-processor/src/main/java/com/cake/clockify/annotationprocessor/Constants.java b/annotation-processor/src/main/java/com/cake/clockify/annotationprocessor/Constants.java index 4aa38f5..8da23c6 100644 --- a/annotation-processor/src/main/java/com/cake/clockify/annotationprocessor/Constants.java +++ b/annotation-processor/src/main/java/com/cake/clockify/annotationprocessor/Constants.java @@ -3,6 +3,8 @@ import lombok.AccessLevel; import lombok.NoArgsConstructor; +import java.util.List; + @NoArgsConstructor(access = AccessLevel.PRIVATE) public class Constants { public static final String DELIMITER_NAME_PARTS = "_"; @@ -12,6 +14,10 @@ public class Constants { public static final String CLOCKIFY_MODEL_PACKAGE = "com.cake.clockify.addonsdk.clockify.model"; public static final String CLOCKIFY_MANIFESTS_DIR = "clockify-manifests"; + public static final List CLOCKIFY_MANIFESTS = List.of( + CLOCKIFY_MANIFESTS_DIR + "/1.2.json", + CLOCKIFY_MANIFESTS_DIR + "/1.3.json" + ); public static final String CLOCKIFY_PREFIX = "Clockify"; public static final String CLOCKIFY_MANIFEST_INTERFACE = "ClockifyManifest"; diff --git a/annotation-processor/src/main/java/com/cake/clockify/annotationprocessor/ManifestExtensionProcessor.java b/annotation-processor/src/main/java/com/cake/clockify/annotationprocessor/ManifestExtensionProcessor.java index f637668..d72c0f8 100644 --- a/annotation-processor/src/main/java/com/cake/clockify/annotationprocessor/ManifestExtensionProcessor.java +++ b/annotation-processor/src/main/java/com/cake/clockify/annotationprocessor/ManifestExtensionProcessor.java @@ -17,6 +17,8 @@ import java.util.List; import java.util.Set; +import static com.cake.clockify.annotationprocessor.Constants.CLOCKIFY_MANIFESTS; + @AutoService(javax.annotation.processing.Processor.class) @SupportedSourceVersion(SourceVersion.RELEASE_18) @NoArgsConstructor @@ -44,7 +46,7 @@ private void processAnnotation(TypeElement annotation, RoundEnvironment roundEnv for (Element element : elements) { DeclaredType type = (DeclaredType) element.asType(); - for (String manifestPath: Utils.getClockifyManifestPaths()) { + for (String manifestPath: CLOCKIFY_MANIFESTS) { try { files.addAll(new ClockifyManifestProcessor(type, manifestPath).process()); } catch (Exception e) { diff --git a/annotation-processor/src/main/java/com/cake/clockify/annotationprocessor/Utils.java b/annotation-processor/src/main/java/com/cake/clockify/annotationprocessor/Utils.java index 38c7d6d..8d54809 100644 --- a/annotation-processor/src/main/java/com/cake/clockify/annotationprocessor/Utils.java +++ b/annotation-processor/src/main/java/com/cake/clockify/annotationprocessor/Utils.java @@ -10,10 +10,6 @@ import javax.lang.model.type.DeclaredType; import java.io.InputStream; -import java.net.URL; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; import java.util.Iterator; import java.util.LinkedList; import java.util.List; @@ -21,7 +17,6 @@ import java.util.Map; import static com.cake.clockify.annotationprocessor.Constants.CLOCKIFY_PREFIX; -import static com.cake.clockify.annotationprocessor.Constants.CLOCKIFY_MANIFESTS_DIR; import static com.cake.clockify.annotationprocessor.Constants.REGEX_METHOD_NAME_SPLIT; import static com.cake.clockify.annotationprocessor.Constants.REGEX_UPPER_CASE_SPLIT; import static java.util.Collections.emptyList; @@ -34,17 +29,6 @@ public class Utils { "lifecycle", "lifecycleEvent" ); - @SneakyThrows - public static List getClockifyManifestPaths() { - URL url = Utils.class.getClassLoader().getResource(CLOCKIFY_MANIFESTS_DIR); - Path path = Paths.get(url.toURI()); - try (var files = Files.walk(path, 1)) { - return files.filter(p -> p.toFile().isFile()) - .map(p -> CLOCKIFY_MANIFESTS_DIR + "/" + p.getFileName().toString()) - .toList(); - } - } - @SneakyThrows public static JsonNode readManifestDefinition(ObjectMapper mapper, String manifestPath) { InputStream is = Utils.class.getClassLoader().getResourceAsStream(manifestPath);