desruisseaux commented on code in PR #508:
URL: https://github.com/apache/maven-jar-plugin/pull/508#discussion_r3891895435


##########
src/main/java/org/apache/maven/plugins/jar/Archive.java:
##########
@@ -0,0 +1,692 @@
+/*
+ * 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.jar;
+
+import java.io.BufferedWriter;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.attribute.BasicFileAttributes;
+import java.util.ArrayList;
+import java.util.Comparator;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.NavigableMap;
+import java.util.NoSuchElementException;
+import java.util.Objects;
+import java.util.TreeMap;
+import java.util.jar.Attributes;
+import java.util.jar.Manifest;
+
+import org.apache.maven.api.Type;
+import org.apache.maven.api.annotations.Nonnull;
+import org.apache.maven.api.annotations.Nullable;
+import org.apache.maven.api.plugin.Log;
+import org.apache.maven.api.plugin.MojoException;
+
+/**
+ * Files or root directories to archive for a single module.
+ * A single instance of {@code Archive} may contain many directories for 
different target Java releases.
+ * Many instances of {@code Archive} may exist when archiving a multi-modules 
project.
+ */
+final class Archive {
+    /**
+     * Whether to repeat the {@code -C} option before each file.
+     * Doing so makes the command-line very verbose while the documentation of
+     * <a 
href="https://docs.oracle.com/en/java/javase/25/docs/specs/man/jar.html";>The 
jar Command</a>
+     * gives the impression that this option can be provided only once.
+     * However, our tests suggest that the first file after the directory 
specified by the {@code -C} option
+     * must be relative to that directory and all files after the first one 
must be prefixed by the directory
+     * which was specified in the {@code -C} option. This behavior is not 
documented, but we couldn't get the
+     * {@code jar} tool to work otherwise (except by repeating {@code -C} 
before each file).
+     * Furthermore, it seems that the relativized file needs to be the 
shortest one,
+     * otherwise the {@code jar} tool rejects files after the first one with 
"names do not match".
+     * Which file is first depends on the unspecified directory-iteration 
order.
+     *
+     * <p>If this flag is {@code true}, the plugin repeats {@code -C} before 
each file.
+     * This flag should be set to {@code false} if a future version of the 
{@code jar}
+     * tool allows to specify {@code -C} only once.</p>
+     *
+     * <p><b>Historical note:</b> we also tried to relativize only the first 
file after {@code -C}
+     * and keep all subsequent files as absolute. It works, but because we 
have to repeat the directory
+     * in the file name, it saves only 3 or 4 characters per file compared to 
repeating {@code -C}.</p>
+     */
+    private static final boolean REPEAT_C = true;
+
+    /**
+     * Path to the <abbr>POM</abbr> file generated for this archive, or {@code 
null} if none.
+     * This is non-null only if module source hierarchy is used, in which case 
the dependencies
+     * declared in this file are the intersection of the project dependencies 
and the content of
+     * the {@code module-info.class} file.
+     */
+    @Nullable
+    Path pomFile;
+
+    /**
+     * The <var>JAR</var> file to create. May be an existing file,

Review Comment:
   Replaced by "can".



-- 
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