From 2fb9147303b7da711e2ff6e489ebf055db4b5b12 Mon Sep 17 00:00:00 2001 From: Florian Hussonnois Date: Tue, 23 Apr 2024 15:20:23 +0200 Subject: [PATCH] refactor: migrate to Java ServiceLoader for plugin registration --- .github/workflows/main.yml | 2 +- build.gradle | 6 ++++-- gradle.properties | 2 +- src/main/java/io/kestra/storage/gcs/GcsStorage.java | 5 ++++- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ec12177..54188ed 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -38,7 +38,7 @@ jobs: uses: actions/setup-java@v4 with: distribution: 'temurin' - java-version: 17 + java-version: 21 - name: Validate Gradle wrapper uses: gradle/wrapper-validation-action@v2 diff --git a/build.gradle b/build.gradle index 64d4f98..b961f62 100644 --- a/build.gradle +++ b/build.gradle @@ -22,8 +22,8 @@ repositories { } } -sourceCompatibility = 17 -targetCompatibility = 17 +sourceCompatibility = 21 +targetCompatibility = 21 group "io.kestra.storage" description = 'Google Cloud Storage storage plugin for Kestra' @@ -57,6 +57,7 @@ dependencies { // kestra compileOnly group: "io.kestra", name: "core", version: kestraVersion + annotationProcessor group: "io.kestra", name: "processor", version: kestraVersion // libs api platform('com.google.cloud:libraries-bom:26.37.0') @@ -99,6 +100,7 @@ dependencies { testImplementation group: "io.kestra", name: "core", version: kestraVersion testImplementation group: "io.kestra", name: "core", version: kestraVersion, classifier: 'tests' + testAnnotationProcessor group: "io.kestra", name: "processor", version: kestraVersion } /**********************************************************************************************************************\ diff --git a/gradle.properties b/gradle.properties index 7a14be6..ce7f3f5 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ version=0.17.0-SNAPSHOT -kestraVersion=[0.16,) +kestraVersion=[0.17,) micronautVersion=4.3.7 lombokVersion=1.18.32 diff --git a/src/main/java/io/kestra/storage/gcs/GcsStorage.java b/src/main/java/io/kestra/storage/gcs/GcsStorage.java index 5113582..6a6f2eb 100644 --- a/src/main/java/io/kestra/storage/gcs/GcsStorage.java +++ b/src/main/java/io/kestra/storage/gcs/GcsStorage.java @@ -3,6 +3,7 @@ import com.google.api.gax.paging.Page; import com.google.cloud.WriteChannel; import com.google.cloud.storage.*; +import io.kestra.core.models.annotations.Plugin; import io.kestra.core.storages.FileAttributes; import io.micronaut.core.annotation.Introspected; import io.kestra.core.storages.StorageInterface; @@ -22,12 +23,15 @@ import jakarta.inject.Inject; import jakarta.inject.Singleton; +import lombok.NoArgsConstructor; import static io.kestra.core.utils.Rethrow.throwFunction; @Singleton @GcsStorageEnabled @Introspected +@Plugin +@NoArgsConstructor public class GcsStorage implements StorageInterface { @Inject Storage storage; @@ -35,7 +39,6 @@ public class GcsStorage implements StorageInterface { @Inject GcsConfig config; - private BlobId blob(String tenantId, URI uri) { String path = getPath(tenantId, uri); return blob(path);