File tree Expand file tree Collapse file tree 4 files changed +50
-1
lines changed
functionalTest/kotlin/com/github/jengelman/gradle/plugins/shadow/transformers
main/kotlin/com/github/jengelman/gradle/plugins/shadow/transformers Expand file tree Collapse file tree 4 files changed +50
-1
lines changed Original file line number Diff line number Diff line change @@ -266,6 +266,7 @@ public class com/github/jengelman/gradle/plugins/shadow/transformers/ApacheNotic
266266 public final fun getObjectFactory ()Lorg/gradle/api/model/ObjectFactory;
267267 public fun getOrganizationName ()Lorg/gradle/api/provider/Property;
268268 public fun getOrganizationURL ()Lorg/gradle/api/provider/Property;
269+ public fun getOutputPath ()Lorg/gradle/api/provider/Property;
269270 public fun getPreamble1 ()Lorg/gradle/api/provider/Property;
270271 public fun getPreamble2 ()Lorg/gradle/api/provider/Property;
271272 public fun getPreamble3 ()Lorg/gradle/api/provider/Property;
Original file line number Diff line number Diff line change 99- Expose ` patternSet ` of ` ServiceFileTransformer ` as ` public ` . ([ #1849 ] ( https://github.com/GradleUp/shadow/pull/1849 ) )
1010- Expose ` patternSet ` of ` ApacheLicenseResourceTransformer ` as ` public ` . ([ #1850 ] ( https://github.com/GradleUp/shadow/pull/1850 ) )
1111- Expose ` patternSet ` of ` ApacheNoticeResourceTransformer ` as ` public ` . ([ #1850 ] ( https://github.com/GradleUp/shadow/pull/1850 ) )
12+ - Support overriding output path of ` ApacheNoticeResourceTransformer ` . ([ #1851 ] ( https://github.com/GradleUp/shadow/pull/1851 ) )
1213
1314### Changed
1415
Original file line number Diff line number Diff line change @@ -251,6 +251,45 @@ class TransformersTest : BaseTransformerTest() {
251251 }
252252 }
253253
254+ @Test
255+ fun overrideOutputPathOfNoticeFile () {
256+ val noticeEntry = " META-INF/NOTICE"
257+ val customNoticeEntry = " META-INF/CUSTOM_NOTICE"
258+ val one = buildJarOne {
259+ insert(noticeEntry, " Notice from A" )
260+ }
261+ val two = buildJarTwo {
262+ insert(noticeEntry, " Notice from B" )
263+ }
264+ projectScript.appendText(
265+ transform<ApacheNoticeResourceTransformer >(
266+ dependenciesBlock = implementationFiles(one, two),
267+ transformerBlock = " addHeader = false; outputPath = '$customNoticeEntry '" ,
268+ ),
269+ )
270+
271+ runWithSuccess(shadowJarPath)
272+
273+ assertThat(outputShadowedJar).useAll {
274+ containsOnly(
275+ customNoticeEntry,
276+ * manifestEntries,
277+ )
278+ getContent(customNoticeEntry).isEqualTo(
279+ """
280+ Copyright 2006-2025 The Apache Software Foundation
281+
282+ This product includes software developed at
283+ The Apache Software Foundation (https://www.apache.org/).
284+
285+ Notice from A
286+
287+ Notice from B
288+ """ .trimIndent(),
289+ )
290+ }
291+ }
292+
254293 @ParameterizedTest
255294 @MethodSource(" transformerConfigProvider" )
256295 fun otherTransformers (pair : Pair <String , KClass <* >>) {
Original file line number Diff line number Diff line change @@ -76,6 +76,14 @@ public open class ApacheNoticeResourceTransformer(
7676 @get:Input
7777 public open val charsetName: Property <String > = objectFactory.property(Charsets .UTF_8 .name())
7878
79+ /* *
80+ * The output path of the `NOTICE` file.
81+ *
82+ * Defaults to `META-INF/NOTICE`.
83+ */
84+ @get:Input
85+ public open val outputPath: Property <String > = objectFactory.property(NOTICE_PATH )
86+
7987 @Inject
8088 public constructor (objectFactory: ObjectFactory ) : this (
8189 objectFactory,
@@ -190,7 +198,7 @@ public open class ApacheNoticeResourceTransformer(
190198 }
191199 }
192200
193- os.putNextEntry(zipEntry(NOTICE_PATH , preserveFileTimestamps))
201+ os.putNextEntry(zipEntry(outputPath.get() , preserveFileTimestamps))
194202 os.write(sb.toString().trim().toByteArray(charset))
195203 os.closeEntry()
196204
You can’t perform that action at this time.
0 commit comments