[ 
https://issues.apache.org/jira/browse/MNG-7357?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17457915#comment-17457915
 ] 

Michael Osipov commented on MNG-7357:
-------------------------------------

You mean the JAR spec. The JAR Spec does *not* mandate them to be first, *but* 
if you look into the Java code you'll see it tries to scan for {{META-INF/}}, 
followed by {{META-INF/MANIFEST.MF}} *or* {{META-INF/MANIFEST.MF}} to make 
proper decision how to proceed with this JAR. If those entries are at the end 
It would take time to arrive at the end of the file. If you put 
{{META-INF/MANIFEST.MF}} then there is zero reason to put {{META-INF/}} after 
it. Since we create empy dirs first I would expect the same approach here.

Impl in Java: 
https://github.com/AdoptOpenJDK/openjdk-jdk11/blob/19fb8f93c59dfd791f62d41f332db9e306bc1422/src/java.base/share/classes/java/util/jar/JarInputStream.java#L79-L87

> All Maven Core JARs have unusual entry order
> --------------------------------------------
>
>                 Key: MNG-7357
>                 URL: https://issues.apache.org/jira/browse/MNG-7357
>             Project: Maven
>          Issue Type: Bug
>            Reporter: Michael Osipov
>            Priority: Minor
>
> Built from 3a06530dbce82e2054afa3cc4c81631910474bd0 I receive this:
> {noformat}
> mosipov@bsd1srv:/usr/home/mosipov/var/Projekte/maven (master *=)
> $ find . -name maven-\*4.0.0-alpha-1-SNAPSHOT.jar -type f -exec sh -c 
> 'zipinfo {} | head -4' \; 2>&1 | less
> Archive:  ./maven-bom/target/maven-bom-4.0.0-alpha-1-SNAPSHOT.jar
> Zip file size: 7277 bytes, number of entries: 10
> -rw-r--r--  2.0 unx      358 b- defN 20-Jan-26 09:04 META-INF/MANIFEST.MF
> drwxr-xr-x  2.0 unx        0 b- stor 20-Jan-26 09:04 META-INF/
> Archive:  
> ./maven-model-builder/target/maven-model-builder-4.0.0-alpha-1-SNAPSHOT.jar
> Zip file size: 217583 bytes, number of entries: 173
> -rw-r--r--  2.0 unx      352 b- defN 21-Apr-05 08:12 META-INF/MANIFEST.MF
> drwxr-xr-x  2.0 unx        0 b- stor 21-Apr-05 08:12 META-INF/
> Archive:  ./maven-model/target/maven-model-4.0.0-alpha-1-SNAPSHOT.jar
> Zip file size: 203201 bytes, number of entries: 76
> -rw-r--r--  2.0 unx      336 b- defN 21-Apr-05 08:12 META-INF/MANIFEST.MF
> drwxr-xr-x  2.0 unx        0 b- stor 21-Apr-05 08:12 META-INF/
> Archive:  
> ./maven-slf4j-provider/target/maven-slf4j-provider-4.0.0-alpha-1-SNAPSHOT.jar
> Zip file size: 25315 bytes, number of entries: 26
> Archive:  ./maven-bom/target/maven-bom-4.0.0-alpha-1-SNAPSHOT.jar
> Zip file size: 7277 bytes, number of entries: 10
> -rw-r--r--  2.0 unx      358 b- defN 20-Jan-26 09:04 META-INF/MANIFEST.MF
> drwxr-xr-x  2.0 unx        0 b- stor 20-Jan-26 09:04 META-INF/
> Archive:  
> ./maven-model-builder/target/maven-model-builder-4.0.0-alpha-1-SNAPSHOT.jar
> Zip file size: 217583 bytes, number of entries: 173
> -rw-r--r--  2.0 unx      352 b- defN 21-Apr-05 08:12 META-INF/MANIFEST.MF
> drwxr-xr-x  2.0 unx        0 b- stor 21-Apr-05 08:12 META-INF/
> Archive:  ./maven-model/target/maven-model-4.0.0-alpha-1-SNAPSHOT.jar
> Zip file size: 203201 bytes, number of entries: 76
> -rw-r--r--  2.0 unx      336 b- defN 21-Apr-05 08:12 META-INF/MANIFEST.MF
> drwxr-xr-x  2.0 unx        0 b- stor 21-Apr-05 08:12 META-INF/
> Archive:  
> ./maven-slf4j-provider/target/maven-slf4j-provider-4.0.0-alpha-1-SNAPSHOT.jar
> Zip file size: 25315 bytes, number of entries: 26
> Archive:  ./maven-bom/target/maven-bom-4.0.0-alpha-1-SNAPSHOT.jar
> Zip file size: 7277 bytes, number of entries: 10
> -rw-r--r--  2.0 unx      358 b- defN 20-Jan-26 09:04 META-INF/MANIFEST.MF
> drwxr-xr-x  2.0 unx        0 b- stor 20-Jan-26 09:04 META-INF/
> Archive:  
> ./maven-model-builder/target/maven-model-builder-4.0.0-alpha-1-SNAPSHOT.jar
> Zip file size: 217583 bytes, number of entries: 173
> -rw-r--r--  2.0 unx      352 b- defN 21-Apr-05 08:12 META-INF/MANIFEST.MF
> drwxr-xr-x  2.0 unx        0 b- stor 21-Apr-05 08:12 META-INF/
> Archive:  ./maven-model/target/maven-model-4.0.0-alpha-1-SNAPSHOT.jar
> Zip file size: 203201 bytes, number of entries: 76
> -rw-r--r--  2.0 unx      336 b- defN 21-Apr-05 08:12 META-INF/MANIFEST.MF
> drwxr-xr-x  2.0 unx        0 b- stor 21-Apr-05 08:12 META-INF/
> Archive:  
> ./maven-slf4j-provider/target/maven-slf4j-provider-4.0.0-alpha-1-SNAPSHOT.jar
> Zip file size: 25315 bytes, number of entries: 26
> Archive:  ./maven-bom/target/maven-bom-4.0.0-alpha-1-SNAPSHOT.jar
> Zip file size: 7277 bytes, number of entries: 10
> -rw-r--r--  2.0 unx      358 b- defN 20-Jan-26 09:04 META-INF/MANIFEST.MF
> drwxr-xr-x  2.0 unx        0 b- stor 20-Jan-26 09:04 META-INF/
> Archive:  
> ./maven-model-builder/target/maven-model-builder-4.0.0-alpha-1-SNAPSHOT.jar
> Zip file size: 217583 bytes, number of entries: 173
> -rw-r--r--  2.0 unx      352 b- defN 21-Apr-05 08:12 META-INF/MANIFEST.MF
> drwxr-xr-x  2.0 unx        0 b- stor 21-Apr-05 08:12 META-INF/
> Archive:  ./maven-model/target/maven-model-4.0.0-alpha-1-SNAPSHOT.jar
> Zip file size: 203201 bytes, number of entries: 76
> -rw-r--r--  2.0 unx      336 b- defN 21-Apr-05 08:12 META-INF/MANIFEST.MF
> drwxr-xr-x  2.0 unx        0 b- stor 21-Apr-05 08:12 META-INF/
> Archive:  
> ./maven-slf4j-provider/target/maven-slf4j-provider-4.0.0-alpha-1-SNAPSHOT.jar
> Zip file size: 25315 bytes, number of entries: 26
> Archive:  ./maven-bom/target/maven-bom-4.0.0-alpha-1-SNAPSHOT.jar
> Zip file size: 7277 bytes, number of entries: 10
> -rw-r--r--  2.0 unx      358 b- defN 20-Jan-26 09:04 META-INF/MANIFEST.MF
> drwxr-xr-x  2.0 unx        0 b- stor 20-Jan-26 09:04 META-INF/
> Archive:  
> ./maven-model-builder/target/maven-model-builder-4.0.0-alpha-1-SNAPSHOT.jar
> Zip file size: 217583 bytes, number of entries: 173
> -rw-r--r--  2.0 unx      352 b- defN 21-Apr-05 08:12 META-INF/MANIFEST.MF
> drwxr-xr-x  2.0 unx        0 b- stor 21-Apr-05 08:12 META-INF/
> Archive:  ./maven-model/target/maven-model-4.0.0-alpha-1-SNAPSHOT.jar
> Zip file size: 203201 bytes, number of entries: 76
> -rw-r--r--  2.0 unx      336 b- defN 21-Apr-05 08:12 META-INF/MANIFEST.MF
> drwxr-xr-x  2.0 unx        0 b- stor 21-Apr-05 08:12 META-INF/
> Archive:  
> ./maven-slf4j-provider/target/maven-slf4j-provider-4.0.0-alpha-1-SNAPSHOT.jar
> Zip file size: 25315 bytes, number of entries: 26
> Archive:  ./maven-bom/target/maven-bom-4.0.0-alpha-1-SNAPSHOT.jar
> Zip file size: 7277 bytes, number of entries: 10
> -rw-r--r--  2.0 unx      358 b- defN 20-Jan-26 09:04 META-INF/MANIFEST.MF
> drwxr-xr-x  2.0 unx        0 b- stor 20-Jan-26 09:04 META-INF/
> Archive:  
> ./maven-model-builder/target/maven-model-builder-4.0.0-alpha-1-SNAPSHOT.jar
> Zip file size: 217583 bytes, number of entries: 173
> -rw-r--r--  2.0 unx      352 b- defN 21-Apr-05 08:12 META-INF/MANIFEST.MF
> drwxr-xr-x  2.0 unx        0 b- stor 21-Apr-05 08:12 META-INF/
> Archive:  ./maven-model/target/maven-model-4.0.0-alpha-1-SNAPSHOT.jar
> Zip file size: 203201 bytes, number of entries: 76
> -rw-r--r--  2.0 unx      336 b- defN 21-Apr-05 08:12 META-INF/MANIFEST.MF
> drwxr-xr-x  2.0 unx        0 b- stor 21-Apr-05 08:12 META-INF/
> Archive:  
> ./maven-slf4j-provider/target/maven-slf4j-provider-4.0.0-alpha-1-SNAPSHOT.jar
> Zip file size: 25315 bytes, number of entries: 26
> -rw-r--r--  2.0 unx      368 b- defN 21-Apr-05 08:12 META-INF/MANIFEST.MF
> drwxr-xr-x  2.0 unx        0 b- stor 21-Apr-05 08:12 META-INF/
> Archive:  
> ./maven-settings-builder/target/maven-settings-builder-4.0.0-alpha-1-SNAPSHOT.jar
> Zip file size: 42653 bytes, number of entries: 53
> -rw-r--r--  2.0 unx      358 b- defN 21-Apr-05 08:12 META-INF/MANIFEST.MF
> drwxr-xr-x  2.0 unx        0 b- stor 21-Apr-05 08:12 META-INF/
> Archive:  
> ./maven-toolchain-model/target/maven-toolchain-model-4.0.0-alpha-1-SNAPSHOT.jar
> Zip file size: 21015 bytes, number of entries: 24
> -rw-r--r--  2.0 unx      356 b- defN 21-Apr-05 08:12 META-INF/MANIFEST.MF
> drwxr-xr-x  2.0 unx        0 b- stor 21-Apr-05 08:12 META-INF/
> Archive:  
> ./maven-resolver-provider/target/maven-resolver-provider-4.0.0-alpha-1-SNAPSHOT.jar
> Zip file size: 73050 bytes, number of entries: 49
> -rw-r--r--  2.0 unx      378 b- defN 21-Apr-05 08:12 META-INF/MANIFEST.MF
> drwxr-xr-x  2.0 unx        0 b- stor 21-Apr-05 08:12 META-INF/
> Archive:  ./maven-embedder/target/maven-embedder-4.0.0-alpha-1-SNAPSHOT.jar
> Zip file size: 101384 bytes, number of entries: 77
> -rw-r--r--  2.0 unx      342 b- defN 21-Apr-05 08:12 META-INF/MANIFEST.MF
> drwxr-xr-x  2.0 unx        0 b- stor 21-Apr-05 08:12 META-INF/
> Archive:  
> ./maven-model-transform/target/maven-model-transform-4.0.0-alpha-1-SNAPSHOT.jar
> Zip file size: 29090 bytes, number of entries: 31
> -rw-r--r--  2.0 unx      364 b- defN 21-Apr-05 08:12 META-INF/MANIFEST.MF
> drwxr-xr-x  2.0 unx        0 b- stor 21-Apr-05 08:12 META-INF/
> Archive:  
> ./maven-repository-metadata/target/maven-repository-metadata-4.0.0-alpha-1-SNAPSHOT.jar
> Zip file size: 27175 bytes, number of entries: 27
> -rw-r--r--  2.0 unx      376 b- defN 21-Apr-05 08:12 META-INF/MANIFEST.MF
> drwxr-xr-x  2.0 unx        0 b- stor 21-Apr-05 08:12 META-INF/
> Archive:  
> ./maven-slf4j-wrapper/target/maven-slf4j-wrapper-4.0.0-alpha-1-SNAPSHOT.jar
> Zip file size: 8826 bytes, number of entries: 16
> -rw-r--r--  2.0 unx      352 b- defN 21-Apr-05 08:12 META-INF/MANIFEST.MF
> drwxr-xr-x  2.0 unx        0 b- stor 21-Apr-05 08:12 META-INF/
> Archive:  
> ./maven-toolchain-builder/target/maven-toolchain-builder-4.0.0-alpha-1-SNAPSHOT.jar
> Zip file size: 22110 bytes, number of entries: 32
> -rw-r--r--  2.0 unx      360 b- defN 21-Apr-05 08:12 META-INF/MANIFEST.MF
> drwxr-xr-x  2.0 unx        0 b- stor 21-Apr-05 08:12 META-INF/
> Archive:  
> ./maven-builder-support/target/maven-builder-support-4.0.0-alpha-1-SNAPSHOT.jar
> Zip file size: 15048 bytes, number of entries: 24
> -rw-r--r--  2.0 unx      356 b- defN 21-Apr-05 08:12 META-INF/MANIFEST.MF
> drwxr-xr-x  2.0 unx        0 b- stor 21-Apr-05 08:12 META-INF/
> Archive:  ./maven-artifact/target/maven-artifact-4.0.0-alpha-1-SNAPSHOT.jar
> Zip file size: 58253 bytes, number of entries: 59
> -rw-r--r--  2.0 unx      410 b- defN 21-Apr-05 08:12 META-INF/MANIFEST.MF
> drwxr-xr-x  2.0 unx        0 b- stor 21-Apr-05 08:12 META-INF/
> Archive:  ./maven-settings/target/maven-settings-4.0.0-alpha-1-SNAPSHOT.jar
> Zip file size: 44299 bytes, number of entries: 35
> -rw-r--r--  2.0 unx      342 b- defN 21-Apr-05 08:12 META-INF/MANIFEST.MF
> drwxr-xr-x  2.0 unx        0 b- stor 21-Apr-05 08:12 META-INF/
> Archive:  ./maven-core/target/maven-core-4.0.0-alpha-1-SNAPSHOT.jar
> Zip file size: 667682 bytes, number of entries: 507
> -rw-r--r--  2.0 unx      334 b- defN 21-Apr-05 08:12 META-INF/MANIFEST.MF
> drwxr-xr-x  2.0 unx        0 b- stor 21-Apr-05 08:12 META-INF/
> Archive:  ./maven-compat/target/maven-compat-4.0.0-alpha-1-SNAPSHOT.jar
> Zip file size: 286906 bytes, number of entries: 212
> -rw-r--r--  2.0 unx      338 b- defN 21-Apr-05 08:12 META-INF/MANIFEST.MF
> drwxr-xr-x  2.0 unx        0 b- stor 21-Apr-05 08:12 META-INF/
> Archive:  
> ./maven-plugin-api/target/maven-plugin-api-4.0.0-alpha-1-SNAPSHOT.jar
> Zip file size: 46443 bytes, number of entries: 45
> -rw-r--r--  2.0 unx      346 b- defN 21-Apr-05 08:12 META-INF/MANIFEST.MF
> drwxr-xr-x  2.0 unx        0 b- stor 21-Apr-05 08:12 META-INF/
> {noformat}
> {{META-INF/MANIFEST.MF}} comes *before* {{META-INF/}} which does not make any 
> sense logically. Either the dir should come first or the not at all and it is 
> implied. My {{unzip(1)}} says:
> {noformat}
> $ unzip /tmp/maven-plugin-api-4.0.0-alpha-1-SNAPSHOT.jar
> Archive:  /tmp/maven-plugin-api-4.0.0-alpha-1-SNAPSHOT.jar
>   inflating: META-INF/MANIFEST.MF
>    creating: org/
>    creating: org/apache/
>    creating: org/apache/maven/
>    creating: org/apache/maven/plugin/
>    creating: org/apache/maven/plugin/descriptor/
>    creating: org/apache/maven/plugin/lifecycle/
>    creating: org/apache/maven/plugin/lifecycle/io/
>    creating: org/apache/maven/plugin/lifecycle/io/xpp3/
>    creating: org/apache/maven/plugin/logging/
>    creating: META-INF/maven/
>    creating: META-INF/maven/org.apache.maven/
>    creating: META-INF/maven/org.apache.maven/maven-plugin-api/
>   inflating: META-INF/DEPENDENCIES
>   inflating: META-INF/LICENSE
>   inflating: META-INF/NOTICE
>   inflating: org/apache/maven/plugin/AbstractMojo.class
>   inflating: org/apache/maven/plugin/AbstractMojoExecutionException.class
>   inflating: org/apache/maven/plugin/ContextEnabled.class
>   inflating: org/apache/maven/plugin/Mojo.class
>   inflating: org/apache/maven/plugin/MojoExecutionException.class
>   inflating: org/apache/maven/plugin/MojoFailureException.class
>   inflating: org/apache/maven/plugin/MojoNotFoundException.class
>   inflating: 
> org/apache/maven/plugin/descriptor/DuplicateMojoDescriptorException.class
>   inflating: 
> org/apache/maven/plugin/descriptor/DuplicateParameterException.class
>   inflating: 
> org/apache/maven/plugin/descriptor/InvalidParameterException.class
>   inflating: 
> org/apache/maven/plugin/descriptor/InvalidPluginDescriptorException.class
>   inflating: org/apache/maven/plugin/descriptor/MojoDescriptor.class
>   inflating: org/apache/maven/plugin/descriptor/Parameter.class
>   inflating: org/apache/maven/plugin/descriptor/PluginDescriptor.class
>   inflating: org/apache/maven/plugin/descriptor/PluginDescriptorBuilder.class
>   inflating: org/apache/maven/plugin/descriptor/Requirement.class
>   inflating: org/apache/maven/plugin/lifecycle/Execution.class
>   inflating: org/apache/maven/plugin/lifecycle/Lifecycle.class
>   inflating: org/apache/maven/plugin/lifecycle/LifecycleConfiguration.class
>   inflating: org/apache/maven/plugin/lifecycle/Phase.class
>   inflating: 
> org/apache/maven/plugin/lifecycle/io/xpp3/LifecycleMappingsXpp3Reader$1.class
>   inflating: 
> org/apache/maven/plugin/lifecycle/io/xpp3/LifecycleMappingsXpp3Reader$ContentTransformer.class
>   inflating: 
> org/apache/maven/plugin/lifecycle/io/xpp3/LifecycleMappingsXpp3Reader.class
>   inflating: 
> org/apache/maven/plugin/lifecycle/io/xpp3/LifecycleMappingsXpp3Writer.class
>   inflating: org/apache/maven/plugin/logging/Log.class
>   inflating: org/apache/maven/plugin/logging/SystemStreamLog.class
>   inflating: META-INF/maven/org.apache.maven/maven-plugin-api/pom.xml
>   inflating: META-INF/maven/org.apache.maven/maven-plugin-api/pom.properties
> {noformat}
> It completely omits the {{META-INF/}} entry. Weird also. This may vary from 
> implementation to implementation. {{jar(1)}} first inflates the manifest file 
> then creates the dir (ha ha):
> {noformat}
> $ LANG=C jar -xvf /tmp/maven-plugin-api-4.0.0-alpha-1-SNAPSHOT.jar
>  inflated: META-INF/MANIFEST.MF
>   created: META-INF/
>   created: org/
>   created: org/apache/
>   created: org/apache/maven/
>   created: org/apache/maven/plugin/
>   created: org/apache/maven/plugin/descriptor/
>   created: org/apache/maven/plugin/lifecycle/
>   created: org/apache/maven/plugin/lifecycle/io/
>   created: org/apache/maven/plugin/lifecycle/io/xpp3/
>   created: org/apache/maven/plugin/logging/
>   created: META-INF/maven/
>   created: META-INF/maven/org.apache.maven/
>   created: META-INF/maven/org.apache.maven/maven-plugin-api/
>  inflated: META-INF/DEPENDENCIES
>  inflated: META-INF/LICENSE
>  inflated: META-INF/NOTICE
>  inflated: org/apache/maven/plugin/AbstractMojo.class
>  inflated: org/apache/maven/plugin/AbstractMojoExecutionException.class
>  inflated: org/apache/maven/plugin/ContextEnabled.class
>  inflated: org/apache/maven/plugin/Mojo.class
>  inflated: org/apache/maven/plugin/MojoExecutionException.class
>  inflated: org/apache/maven/plugin/MojoFailureException.class
>  inflated: org/apache/maven/plugin/MojoNotFoundException.class
>  inflated: 
> org/apache/maven/plugin/descriptor/DuplicateMojoDescriptorException.class
>  inflated: 
> org/apache/maven/plugin/descriptor/DuplicateParameterException.class
>  inflated: org/apache/maven/plugin/descriptor/InvalidParameterException.class
>  inflated: 
> org/apache/maven/plugin/descriptor/InvalidPluginDescriptorException.class
>  inflated: org/apache/maven/plugin/descriptor/MojoDescriptor.class
>  inflated: org/apache/maven/plugin/descriptor/Parameter.class
>  inflated: org/apache/maven/plugin/descriptor/PluginDescriptor.class
>  inflated: org/apache/maven/plugin/descriptor/PluginDescriptorBuilder.class
>  inflated: org/apache/maven/plugin/descriptor/Requirement.class
>  inflated: org/apache/maven/plugin/lifecycle/Execution.class
>  inflated: org/apache/maven/plugin/lifecycle/Lifecycle.class
>  inflated: org/apache/maven/plugin/lifecycle/LifecycleConfiguration.class
>  inflated: org/apache/maven/plugin/lifecycle/Phase.class
>  inflated: 
> org/apache/maven/plugin/lifecycle/io/xpp3/LifecycleMappingsXpp3Reader$1.class
>  inflated: 
> org/apache/maven/plugin/lifecycle/io/xpp3/LifecycleMappingsXpp3Reader$ContentTransformer.class
>  inflated: 
> org/apache/maven/plugin/lifecycle/io/xpp3/LifecycleMappingsXpp3Reader.class
>  inflated: 
> org/apache/maven/plugin/lifecycle/io/xpp3/LifecycleMappingsXpp3Writer.class
>  inflated: org/apache/maven/plugin/logging/Log.class
>  inflated: org/apache/maven/plugin/logging/SystemStreamLog.class
>  inflated: META-INF/maven/org.apache.maven/maven-plugin-api/pom.xml
>  inflated: META-INF/maven/org.apache.maven/maven-plugin-api/pom.properties
> {noformat}
> I checked the system calls of {{unzip(1)}} and {{jar(1)}} and both test for 
> parent of the manifest file, create it, then write the file. The next test 
> tests for {{META-INF/}} and skips it because it is already present.
> I would expect that our JARs would not expose such an oddity. I guess the 
> cause is in Maven/Plexus Archiver or Commons Compress.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to