Repository: GradleUp/shadow (kotlin)

Issue:
Document relocate only trick
### Shadow Version

7.1.2

### Gradle Version

7.4

### Proposal

So far, the page [Configuring Shadowed Dependencies](https://imperceptiblethoughts.com/shadow/configuration/dependencies/#embedding-jar-files-inside-your-shadow-jar) tells how to define configurations as `configurations = [project.configurations.compileClasspath]` so that we don't include runtime only dependencies in the final jar.

However, there are some use cases don't want the compile dependencies even. This may be like a use case of `com.google.code.maven-replacer-plugin` ([examples](https://github.com/apache/ratis/blob/cbf31291ba113a8ea437a5c92c6987fa14b9604d/ratis-proto/pom.xml#L121-L150)) but can be implemented with this shadow plugin for a gradle variant:


```gradle
shadowJar {
    configurations = []
    relocate 'com.google.protobuf', 'org.apache.ratis.thirdparty.com.google.protobuf'
}
```

I propose we add a section in the page mentioned above sharing this trick. If the proposal is accepted, I'm glad to prepare the content.

cc @johnrengelman what do you think?

Pull request:
Closes #759.

Patch:
diff --git a/docs/configuration/relocation/README.md b/docs/configuration/relocation/README.md
index 333e9cc5a..8dee715e2 100644
--- a/docs/configuration/relocation/README.md
+++ b/docs/configuration/relocation/README.md
@@ -127,3 +127,31 @@ In versions before 8.1.0 it was necessary to configure a separate `ConfigureShad
 in the configurations declared to be shadowed. By default, this is the `runtime` or `runtimeClasspath` configurations.
 Be mindful that some Gradle plugins will automatically add dependencies to your class path. You may need to remove these 
 dependencies if you do not intend to shadow them into your library.
+
+## Relocating Project Resources Only
+
+If you want to relocate the resources of the project only and exclude all dependencies (related to a normal JAR but with 
+relocating), you can try out the trick like:
+
+=== "Kotlin"
+
+    ```kotlin
+    tasks.shadowJar {
+      // Empty configurations list will exclude all dependencies.
+      configurations = emptyList()
+      relocate("com.example", "shadow.com.example")
+    }
+    ```
+
+=== "Groovy"
+
+    ```groovy
+    tasks.named('shadowJar', com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) {
+      // Empty configurations list will exclude all dependencies.
+      configurations = []
+      relocate 'com.example', 'shadow.com.example'
+    }
+    ```
+
+This is useful in some cases like [#759](https://github.com/GradleUp/shadow/issues/759) mentioned. See 
+[Configuring Shadowed Dependencies](../dependencies/README.md) for more information about `configurations`.


Test patch:
diff --git a/src/functionalTest/kotlin/com/github/jengelman/gradle/plugins/shadow/RelocationTest.kt b/src/functionalTest/kotlin/com/github/jengelman/gradle/plugins/shadow/RelocationTest.kt
index 36e4d0ff9..8bff7997c 100644
--- a/src/functionalTest/kotlin/com/github/jengelman/gradle/plugins/shadow/RelocationTest.kt
+++ b/src/functionalTest/kotlin/com/github/jengelman/gradle/plugins/shadow/RelocationTest.kt
@@ -517,6 +517,36 @@ class RelocationTest : BasePluginTest() {
     }
   }
 
+  @Test
+  fun relocateProjectResourcesOnly() {
+    val mainClassEntry = writeClass()
+    projectScriptPath.appendText(
+      """
+        dependencies {
+          implementation 'junit:junit:3.8.2'
+        }
+        $shadowJar {
+          configurations = []
+          relocate('', 'foo/')
+        }
+      """.trimIndent(),
+    )
+
+    run(shadowJarTask)
+
+    assertThat(outputShadowJar).useAll {
+      containsEntries(
+        "foo/$mainClassEntry",
+        "foo/META-INF/MANIFEST.MF",
+      )
+      doesNotContainEntries(
+        "META-INF/MANIFEST.MF",
+        *junitEntries,
+        *junitEntries.map { "foo/$it" }.toTypedArray(),
+      )
+    }
+  }
+
   private companion object {
     @JvmStatic
     fun prefixProvider() = listOf(