简体   繁体   English

在Pom中使用Maven程序集插件将Zip文件清空

[英]Zip file empty using maven assembly plugin in pom

my pom.xml but i have written something like 我的pom.xml但我写了类似的东西

.......
..........
    <plugin>
            <artifactId>maven-assembly-plugin</artifactId>
            <version>2.5.3</version>
            <configuration>
                <finalName>${project.artifactId}</finalName>
                <descriptor>assembly.xml</descriptor>
            </configuration>
            <executions>
                <execution>
                    <id>create-archive</id>
                    <phase>package</phase>
                    <goals>
                        <goal>single</goal>
                    </goals>
                </execution>
            </executions>
    </plugin>
..........
.......

My assembly.xml is 我的assembly.xml是

<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">
    <id>${project.version}</id>
    <includeBaseDirectory>false</includeBaseDirectory>
    <formats>
        <format>zip</format>
    </formats>
    <fileSets>
        <fileSet>
            <directory>${project.basedir}/${create.stage.directory}</directory>
             <includes>
                <include>*.*</include>
            </includes>
            <outputDirectory>${project.basedir}/${create.release.directory}</outputDirectory>
        </fileSet>
    </fileSets>
</assembly>

This creates an EMPTY foldername.zip in target!!NOT IN THE OUTPUT FOLDER LOCATION THAT I HAVE GIVEN.Is it always target? 这会在目标中创建一个EMPTY foldername.zip文件!!没有在我已指定的输出文件夹位置中,它始终是目标文件吗? cant i override?? 我不能超越吗? But in the given directory path I have 3 folders (in which some files) and readme.txt.I just tried giving *.txt inside include tag still I got empty zip folder. 但是在给定的目录路径中,我有3个文件夹(其中有一些文件)和readme.txt。我只是尝试在include标签中提供* .txt,仍然得到空的zip文件夹。 I initially guessed that my directory path and output directory path can be wrong.I directly hardcode still there is no luck. 我最初猜测我的目录路径和输出目录路径可能是错误的,我直接进行硬编码仍然没有运气。

Please help (This question is not duplicate but similar, and I have tried almost all stackoverflow questions related to this.they haven't solved anything) 请帮忙(这个问题不是重复的,而是类似的,并且我已经尝试了几乎所有与此相关的stackoverflow问题。它们并没有解决任何问题)

For details see http://maven.apache.org/plugins/maven-assembly-plugin/assembly.html#class_fileSet 有关详细信息,请参见http://maven.apache.org/plugins/maven-assembly-plugin/assembly.html#class_fileSet

Your descriptor is now configured like this: 现在,您的描述符的配置如下:

  • create a zip called ${project.artifactId} 创建一个名为${project.artifactId}的邮政编码
  • from the directory ${project.basedir}/${create.stage.directory} put all files with an extension (not directories, since it says *.* , not something like **/*.* in the ${project.basedir}/${create.release.directory} folder inside the zip. 从目录${project.basedir}/${create.stage.directory}所有带扩展名的文件(不是目录,因为它说*.* ,而不是${project.basedir}/${create.release.directory}中的**/*.* ${project.basedir}/${create.release.directory}的zip文件夹里面

Especially the last part is weird. 特别是最后一部分很奇怪。 Where in the zip should these files end? 这些文件应在zip文件中的何处结束? It should be a relative path to make it predictable. 它应该是使它可预测的相对路径。

Don't like the zip file to be created in target? 不喜欢在target中创建zip文件吗? Set the outputDirectory in the plugin configuration, not in the assembly descriptor. 在插件配置中而不是程序集描述符中设置outputDirectory

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM