Repository: GradleUp/shadow (kotlin)

Issue:
`module-info.class` in Multi-Release folders is not excluded by default
### Shadow Version
7.1.0

### Gradle Version
Gradle 7.3

### Expected Behavior
`module-info.class` in Multi-Release folders should be excluded by default (see also #352).

Some libraries (such as Log4j 2) include the `module-info.class` in the Multi-Release JAR folder `META-INF/versions/<version>` to keep compatibility with < Java 9, but at the same time define a module descriptor for JREs >= Java 9.
There is no point in keeping these module descriptor classes because they are specific to a shadowed library and not relevant (or incorrect) for the resulting 'fat JAR'.

This becomes even more important once #449 has been implemented.

### Actual Behavior
The shadowed JAR contains `module-info.class` files in the Multi-Release JAR folder `META-INF/versions/<version>`.

### Gradle Build Script(s)
`build.gradle.kts`
```kotlin
plugins {
    java
    id("com.github.johnrengelman.shadow") version "7.1.0"
}

repositories {
    mavenCentral()
}

dependencies {
    implementation(platform("org.apache.logging.log4j:log4j-bom:2.14.1"))
    implementation("org.apache.logging.log4j:log4j-api")
    implementation("org.apache.logging.log4j:log4j-core")
}


java {
    toolchain {
        languageVersion.set(JavaLanguageVersion.of(11))
    }
}
```

### Content of Shadow JAR (`jar tf <jar file>` - post link to GIST if too long)

- `META-INF/versions/9/module-info.class`
- ...

Pull request:
Closes #729.

---

- [x] [CHANGELOG](https://github.com/GradleUp/shadow/blob/main/src/docs/changes/README.md)'s "Unreleased" section has been updated, if applicable.

Patch:
diff --git a/src/docs/changes/README.md b/src/docs/changes/README.md
index 435fbf8ff..350aa7ec2 100644
--- a/src/docs/changes/README.md
+++ b/src/docs/changes/README.md
@@ -3,6 +3,10 @@
 
 ## [Unreleased]
 
+**Added**
+
+- Exclude `module-info.class` in Multi-Release folders by default. ([#1177](https://github.com/GradleUp/shadow/pull/1177))
+
 **Fixed**
 
 - Fix `Log4j2PluginsCacheFileTransformer` not working for merging `Log4j2Plugins.dat` files. ([#1175](https://github.com/GradleUp/shadow/pull/1175))  
diff --git a/src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/ShadowJavaPlugin.kt b/src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/ShadowJavaPlugin.kt
index ab83f8e66..edcf9d3f3 100644
--- a/src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/ShadowJavaPlugin.kt
+++ b/src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/ShadowJavaPlugin.kt
@@ -96,6 +96,8 @@ public abstract class ShadowJavaPlugin @Inject constructor(
         "META-INF/*.SF",
         "META-INF/*.DSA",
         "META-INF/*.RSA",
+        // module-info.class in Multi-Release folders.
+        "META-INF/versions/**/module-info.class",
         "module-info.class",
       )
     }


Test patch:
diff --git a/src/functionalTest/kotlin/com/github/jengelman/gradle/plugins/shadow/JavaPluginTest.kt b/src/functionalTest/kotlin/com/github/jengelman/gradle/plugins/shadow/JavaPluginTest.kt
index 943754bc6..bd012d4b4 100644
--- a/src/functionalTest/kotlin/com/github/jengelman/gradle/plugins/shadow/JavaPluginTest.kt
+++ b/src/functionalTest/kotlin/com/github/jengelman/gradle/plugins/shadow/JavaPluginTest.kt
@@ -207,6 +207,8 @@ class JavaPluginTest : BasePluginTest() {
         insert("META-INF/a.DSA", "DSA Signature Block")
         insert("META-INF/a.RSA", "RSA Signature Block")
         insert("META-INF/a.properties", "key=value")
+        insert("META-INF/versions/9/module-info.class", "module myModuleName {}")
+        insert("META-INF/versions/16/module-info.class", "module myModuleName {}")
         insert("module-info.class", "module myModuleName {}")
       }
     }.publish()
@@ -238,6 +240,8 @@ class JavaPluginTest : BasePluginTest() {
         "META-INF/a.SF",
         "META-INF/a.DSA",
         "META-INF/a.RSA",
+        "META-INF/versions/9/module-info.class",
+        "META-INF/versions/16/module-info.class",
         "module-info.class",
       )
     }