【问题标题】:Windows compressed folders does not unpack zip completelyWindows 压缩文件夹无法完全解压 zip
【发布时间】:2011-11-30 23:07:07
【问题描述】:

我有一个包含很多模块的大型 Maven 项目。其中一个模块不是“真正的”开发项目。它包含最终系统的数据。使用特殊的 jar 将数据部署到系统中。 pom 现在确保下载了 jar,并将所有其他数据和批处理文件打包到一个 zip 中。它使用 Maven 程序集插件。这个 pom 文件没有什么神奇之处。当解压带有 Windows 压缩文件夹的 zip 文件时,魔法就开始了。它只会识别相当大的 jar 文件(9MB),而不识别批处理和数据文件(几 KB)。我没有立即注意到这一点,因为我真正的旧 Winzip 对工件没有任何问题。

有人有想法或遇到过类似的问题吗?


pom 文件中的插件配置

<plugin>
    <artifactId>maven-assembly-plugin</artifactId>
    <configuration>
        <descriptors>
            <descriptor>assembly.xml</descriptor>
        </descriptors>
    </configuration>
    <executions>
        <execution>
            <phase>package</phase>
            <goals>
                <goal>single</goal>
            </goals>
        </execution>
    </executions>
</plugin>

我的程序集 xml

<?xml version="1.0" encoding="UTF-8"?>
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">

  <formats>
    <format>zip</format>
  </formats>  

  <dependencySets>
    <dependencySet>
      <outputDirectory></outputDirectory>
      <includes>
        <include>com.group:product-development-cli</include>
      </includes>
      <outputFileNameMapping>product-development-cli-${ext.version}.${extension}</outputFileNameMapping>
    </dependencySet>
  </dependencySets>

    <fileSets>
        <fileSet>
            <directory>.</directory>
            <excludes>
                <exclude>pom.xml</exclude>
        <exclude>assembly.xml</exclude>
        <exclude>target</exclude>
            </excludes>
        </fileSet>
    </fileSets>

</assembly>

我的文件夹结构: 模块 +- 数据1 +- 更多文件 +- 数据2 +- 更多文件 +- pom.xml +- 程序集.xml +- 更多文件

【问题讨论】:

    标签: maven-2 windows-xp zip maven-assembly-plugin compressed-folder


    【解决方案1】:

    您是否有可能超过 260 个字符的窗口路径长度限制? Windows 内置的压缩​​例程在它上面失败了(即使其他 zip 程序可以处理它。)

    由于 JAR 的层次结构,这似乎在处理 JAR 时经常出现。

    您能否尝试解压缩到较短的路径(例如C:\A),看看是否有帮助?

    【讨论】:

    • 文件夹结构非常扁平。但是,我还是尝试了,但没有成功。
    【解决方案2】:

    受 Edward Thomson 的启发,我再次查看了 zip 文件。 zip 文件包含来自两个不同来源(文件集和依赖项)的文件。问题是文件集中的目录标签。 (&lt;directory&gt;.&lt;/directory&gt;) 压缩文件夹不喜欢 '.'在路径的中间。

    product-0.5.0-SNAPSHOT/./file.txt

    依赖项当然没有.

    【讨论】: