elharo commented on code in PR #829:
URL: 
https://github.com/apache/maven-shade-plugin/pull/829#discussion_r3856769544


##########
src/site/markdown/examples/module-info-merging.md.vm:
##########
@@ -0,0 +1,200 @@
+---
+title: Merging Java Module Descriptors
+author:
+  - The Apache Maven Team
+date: 2026-07-30
+---
+
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+# Merging Java Module Descriptors
+
+By default, the plugin discards every root and versioned `module-info.class` 
from the inputs. This preserves the
+historical behavior: an unmodified descriptor would describe the original 
artifact rather than the contents of the

Review Comment:
   would describe --> describes



##########
src/main/java/org/apache/maven/plugins/shade/DefaultShader.java:
##########
@@ -189,6 +240,30 @@ public void shade(ShadeRequest shadeRequest) throws 
IOException, MojoExecutionEx
         }
     }
 
+    private List<File> findMultiReleaseInputs(ShadeRequest shadeRequest) 
throws IOException {
+        List<File> result = new ArrayList<>();
+        for (File jar : shadeRequest.getJars()) {
+            Manifest manifest = null;
+            if (jar.isDirectory()) {
+                File manifestFile = new File(jar, JarFile.MANIFEST_NAME);
+                if (manifestFile.isFile()) {
+                    try (InputStream input = 
Files.newInputStream(manifestFile.toPath())) {
+                        manifest = new Manifest(input);
+                    }
+                }
+            } else {
+                try (JarFile jarFile = newJarFile(jar)) {
+                    manifest = jarFile.getManifest();
+                }
+            }
+            if (manifest != null

Review Comment:
   this might be able to be extracted to a private method and then pushed into 
the try blocks



##########
src/main/java/org/apache/maven/plugins/shade/ModuleInfoMode.java:
##########
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.maven.plugins.shade;
+
+/**
+ * Controls how module descriptors are handled while shading.
+ */
+public enum ModuleInfoMode {

Review Comment:
   do enums have to be public?



##########
src/site/markdown/examples/module-info-merging.md.vm:
##########
@@ -0,0 +1,200 @@
+---
+title: Merging Java Module Descriptors
+author:
+  - The Apache Maven Team
+date: 2026-07-30
+---
+
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+# Merging Java Module Descriptors
+
+By default, the plugin discards every root and versioned `module-info.class` 
from the inputs. This preserves the
+historical behavior: an unmodified descriptor would describe the original 
artifact rather than the contents of the
+shaded JAR.
+
+Modular projects can opt into descriptor merging:
+
+```xml
+<project>
+  ...
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-shade-plugin</artifactId>
+        <version>${project.version}</version>
+        <executions>
+          <execution>
+            <phase>package</phase>
+            <goals>
+              <goal>shade</goal>
+            </goals>
+            <configuration>
+              <moduleInfoMode>merge</moduleInfoMode>
+              <moduleInfo>
+                <publicBoundary>merge</publicBoundary>
+                <analysisJdkToolchain>
+                  <version>21</version>
+                </analysisJdkToolchain>
+              </moduleInfo>
+              <relocations>
+                <relocation>
+                  <pattern>com.example.internal</pattern>
+                  <shadedPattern>com.example.shaded.internal</shadedPattern>
+                </relocation>
+              </relocations>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+  ...
+</project>
+```
+
+Merge mode models the shaded JAR as if the retained, relocated source files 
had been compiled together as one module.
+The primary artifact remains authoritative for the module name, version, main 
class, and, by default, the public

Review Comment:
   Is this right? Shouldn't a shaded jar change the module name? One purpose of 
shading is to allow multiple versions to exists in the classpath at the same 
time.



##########
src/main/java/org/apache/maven/plugins/shade/ModuleInfoMode.java:
##########
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.maven.plugins.shade;
+
+/**
+ * Controls how module descriptors are handled while shading.
+ */
+public enum ModuleInfoMode {
+    /** Discard module descriptors, retaining the historical behavior. */
+    discard,

Review Comment:
   These are usually UPPER CASE



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to