From 7e333c6b2a84fcfd7089fa86704aeae18cca334e Mon Sep 17 00:00:00 2001 From: slinkydeveloper Date: Fri, 15 Dec 2023 15:36:19 +0100 Subject: [PATCH] Add correct transformers to gradle build configurations --- java/hello-world-lambda/build.gradle.kts | 9 +++++++++ kotlin/hello-world-lambda-cdk/lambda/build.gradle.kts | 4 +++- kotlin/hello-world-lambda/build.gradle.kts | 10 +++++++++- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/java/hello-world-lambda/build.gradle.kts b/java/hello-world-lambda/build.gradle.kts index 174e9812..ba87cb88 100644 --- a/java/hello-world-lambda/build.gradle.kts +++ b/java/hello-world-lambda/build.gradle.kts @@ -1,3 +1,6 @@ +import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar +import com.github.jengelman.gradle.plugins.shadow.transformers.Log4j2PluginsCacheFileTransformer +import com.github.jengelman.gradle.plugins.shadow.transformers.ServiceFileTransformer import com.google.protobuf.gradle.id plugins { @@ -58,6 +61,12 @@ protobuf { } } +// Configure shadowJar plugin to properly merge SPI files and Log4j plugin configurations +tasks.withType { + transform(Log4j2PluginsCacheFileTransformer::class.java) + transform(ServiceFileTransformer::class.java) +} + // Configure test platform tasks.withType { useJUnitPlatform() diff --git a/kotlin/hello-world-lambda-cdk/lambda/build.gradle.kts b/kotlin/hello-world-lambda-cdk/lambda/build.gradle.kts index c882c32e..4e822bc4 100644 --- a/kotlin/hello-world-lambda-cdk/lambda/build.gradle.kts +++ b/kotlin/hello-world-lambda-cdk/lambda/build.gradle.kts @@ -1,5 +1,6 @@ import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar import com.github.jengelman.gradle.plugins.shadow.transformers.Log4j2PluginsCacheFileTransformer +import com.github.jengelman.gradle.plugins.shadow.transformers.ServiceFileTransformer import com.google.protobuf.gradle.id val restateVersion = "0.6.0" @@ -80,9 +81,10 @@ protobuf { } } -// Configure shadowJar plugin to properly transform Log4j plugin configurations - needed for AWS Lambda logger +// Configure shadowJar plugin to properly merge SPI files and Log4j plugin configurations tasks.withType { transform(Log4j2PluginsCacheFileTransformer::class.java) + transform(ServiceFileTransformer::class.java) } // Configure test platform diff --git a/kotlin/hello-world-lambda/build.gradle.kts b/kotlin/hello-world-lambda/build.gradle.kts index e519f623..3e7243c5 100644 --- a/kotlin/hello-world-lambda/build.gradle.kts +++ b/kotlin/hello-world-lambda/build.gradle.kts @@ -1,5 +1,7 @@ +import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar +import com.github.jengelman.gradle.plugins.shadow.transformers.Log4j2PluginsCacheFileTransformer +import com.github.jengelman.gradle.plugins.shadow.transformers.ServiceFileTransformer import com.google.protobuf.gradle.id -import org.jetbrains.kotlin.gradle.tasks.KotlinCompile plugins { kotlin("jvm") version "1.9.10" @@ -76,6 +78,12 @@ protobuf { } } +// Configure shadowJar plugin to properly merge SPI files and Log4j plugin configurations +tasks.withType { + transform(Log4j2PluginsCacheFileTransformer::class.java) + transform(ServiceFileTransformer::class.java) +} + // Configure test platform tasks.withType { useJUnitPlatform()