File tree 2 files changed +58
-0
lines changed
docs/configuration/relocation
src/functionalTest/kotlin/com/github/jengelman/gradle/plugins/shadow
2 files changed +58
-0
lines changed Original file line number Diff line number Diff line change @@ -127,3 +127,31 @@ In versions before 8.1.0 it was necessary to configure a separate `ConfigureShad
127
127
in the configurations declared to be shadowed. By default, this is the ` runtime ` or ` runtimeClasspath ` configurations.
128
128
Be mindful that some Gradle plugins will automatically add dependencies to your class path. You may need to remove these
129
129
dependencies if you do not intend to shadow them into your library.
130
+
131
+ ## Relocating Project Resources Only
132
+
133
+ If you want to relocate the resources of the project only and exclude all dependencies (related to a normal JAR but with
134
+ relocating), you can try out the trick like:
135
+
136
+ === "Kotlin"
137
+
138
+ ```kotlin
139
+ tasks.shadowJar {
140
+ // Empty configurations list will exclude all dependencies.
141
+ configurations = emptyList()
142
+ relocate("com.example", "shadow.com.example")
143
+ }
144
+ ```
145
+
146
+ === "Groovy"
147
+
148
+ ```groovy
149
+ tasks.named('shadowJar', com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) {
150
+ // Empty configurations list will exclude all dependencies.
151
+ configurations = []
152
+ relocate 'com.example', 'shadow.com.example'
153
+ }
154
+ ```
155
+
156
+ This is useful in some cases like [ #759 ] ( https://github.com/GradleUp/shadow/issues/759 ) mentioned. See
157
+ [ Configuring Shadowed Dependencies] ( ../dependencies/README.md ) for more information about ` configurations ` .
Original file line number Diff line number Diff line change @@ -517,6 +517,36 @@ class RelocationTest : BasePluginTest() {
517
517
}
518
518
}
519
519
520
+ @Test
521
+ fun relocateProjectResourcesOnly () {
522
+ val mainClassEntry = writeClass()
523
+ projectScriptPath.appendText(
524
+ """
525
+ dependencies {
526
+ implementation 'junit:junit:3.8.2'
527
+ }
528
+ $shadowJar {
529
+ configurations = []
530
+ relocate('', 'foo/')
531
+ }
532
+ """ .trimIndent(),
533
+ )
534
+
535
+ run (shadowJarTask)
536
+
537
+ assertThat(outputShadowJar).useAll {
538
+ containsEntries(
539
+ " foo/$mainClassEntry " ,
540
+ " foo/META-INF/MANIFEST.MF" ,
541
+ )
542
+ doesNotContainEntries(
543
+ " META-INF/MANIFEST.MF" ,
544
+ * junitEntries,
545
+ * junitEntries.map { " foo/$it " }.toTypedArray(),
546
+ )
547
+ }
548
+ }
549
+
520
550
private companion object {
521
551
@JvmStatic
522
552
fun prefixProvider () = listOf (
You can’t perform that action at this time.
0 commit comments