Repository: GradleUp/shadow
Pull request #1228 (2025-02-06 02:25:18)

No need to call builtin builders


Patch:
diff --git a/src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/internal/RelocatorRemapper.kt b/src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/internal/RelocatorRemapper.kt
index 6fbba312..4e8f59af 100644
--- a/src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/internal/RelocatorRemapper.kt
+++ b/src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/internal/RelocatorRemapper.kt
@@ -44,10 +44,10 @@ internal class RelocatorRemapper(
 
     for (relocator in relocators) {
       if (relocator.canRelocateClass(newName)) {
-        val classContext = RelocateClassContext.builder().className(newName).stats(stats).build()
+        val classContext = RelocateClassContext(className = newName, stats = stats)
         return prefix + relocator.relocateClass(classContext) + suffix
       } else if (relocator.canRelocatePath(newName)) {
-        val pathContext = RelocatePathContext.builder().path(newName).stats(stats).build()
+        val pathContext = RelocatePathContext(path = newName, stats = stats)
         return prefix + relocator.relocatePath(pathContext) + suffix
       }
     }
diff --git a/src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/tasks/ShadowCopyAction.kt b/src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/tasks/ShadowCopyAction.kt
index 1c9498e1..5433e758 100644
--- a/src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/tasks/ShadowCopyAction.kt
+++ b/src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/tasks/ShadowCopyAction.kt
@@ -374,12 +374,12 @@ public open class ShadowCopyAction internal constructor(
         transformers.find {
           it.canTransformResource(element)
         }?.transform(
-          TransformerContext.builder()
-            .path(mappedPath)
-            .inputStream(steam)
-            .relocators(relocators)
-            .stats(stats)
-            .build(),
+          TransformerContext(
+            path = mappedPath,
+            inputStream = steam,
+            relocators = relocators,
+            stats = stats,
+          ),
         )
       }
     }
diff --git a/src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/transformers/ServiceFileTransformer.kt b/src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/transformers/ServiceFileTransformer.kt
index d9476b6d..f8144571 100644
--- a/src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/transformers/ServiceFileTransformer.kt
+++ b/src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/transformers/ServiceFileTransformer.kt
@@ -48,12 +48,12 @@ public open class ServiceFileTransformer(
     var targetPath = context.path
     context.relocators.forEach { rel ->
       if (rel.canRelocateClass(File(targetPath).name)) {
-        val classContext = RelocateClassContext.builder().className(targetPath).stats(context.stats).build()
+        val classContext = RelocateClassContext(className = targetPath, stats = context.stats)
         targetPath = rel.relocateClass(classContext)
       }
       lines.forEachIndexed { i, line ->
         if (rel.canRelocateClass(line)) {
-          val lineContext = RelocateClassContext.builder().className(line).stats(context.stats).build()
+          val lineContext = RelocateClassContext(className = line, stats = context.stats)
           lines[i] = rel.relocateClass(lineContext)
         }
       }


Test patch:
diff --git a/src/test/kotlin/com/github/jengelman/gradle/plugins/shadow/transformers/ApacheNoticeResourceTransformerTest.kt b/src/test/kotlin/com/github/jengelman/gradle/plugins/shadow/transformers/ApacheNoticeResourceTransformerTest.kt
index a8146761..40ea4493 100644
--- a/src/test/kotlin/com/github/jengelman/gradle/plugins/shadow/transformers/ApacheNoticeResourceTransformerTest.kt
+++ b/src/test/kotlin/com/github/jengelman/gradle/plugins/shadow/transformers/ApacheNoticeResourceTransformerTest.kt
@@ -63,10 +63,10 @@ class ApacheNoticeResourceTransformerTest : BaseTransformerTest<ApacheNoticeReso
   private fun processAndFailOnNullPointer(noticeText: String) {
     try {
       transformer.transform(
-        TransformerContext.builder()
-          .path(NOTICE_RESOURCE)
-          .inputStream(noticeText.byteInputStream())
-          .build(),
+        TransformerContext(
+          path = NOTICE_RESOURCE,
+          inputStream = noticeText.byteInputStream(),
+        ),
       )
     } catch (ignored: NullPointerException) {
       fail("Null pointer should not be thrown when no parameters are set.")
diff --git a/src/test/kotlin/com/github/jengelman/gradle/plugins/shadow/transformers/ComponentsXmlResourceTransformerTest.kt b/src/test/kotlin/com/github/jengelman/gradle/plugins/shadow/transformers/ComponentsXmlResourceTransformerTest.kt
index dac3e6d0..276ac455 100644
--- a/src/test/kotlin/com/github/jengelman/gradle/plugins/shadow/transformers/ComponentsXmlResourceTransformerTest.kt
+++ b/src/test/kotlin/com/github/jengelman/gradle/plugins/shadow/transformers/ComponentsXmlResourceTransformerTest.kt
@@ -15,16 +15,16 @@ class ComponentsXmlResourceTransformerTest : BaseTransformerTest<ComponentsXmlRe
     XMLUnit.setNormalizeWhitespace(true)
 
     transformer.transform(
-      TransformerContext.builder()
-        .path("components-1.xml")
-        .inputStream(requireResourceAsStream("components-1.xml"))
-        .build(),
+      TransformerContext(
+        path = "components-1.xml",
+        inputStream = requireResourceAsStream("components-1.xml"),
+      ),
     )
     transformer.transform(
-      TransformerContext.builder()
-        .path("components-1.xml")
-        .inputStream(requireResourceAsStream("components-2.xml"))
-        .build(),
+      TransformerContext(
+        path = "components-1.xml",
+        inputStream = requireResourceAsStream("components-2.xml"),
+      ),
     )
     val diff = XMLUnit.compareXML(
       requireResourceAsStream("components-expected.xml").bufferedReader().readText(),