Mani manasa mylavarapu
Mani manasa mylavarapu

Reputation: 321

Zip file empty using maven assembly plugin in pom

my pom.xml but i have written something like

.......
..........
    <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
    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? 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. 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)

Upvotes: 0

Views: 4773

Answers (1)

Robert Scholte
Robert Scholte

Reputation: 12335

For details see 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}
  • 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.

Especially the last part is weird. Where in the zip should these files end? It should be a relative path to make it predictable.

Don't like the zip file to be created in target? Set the outputDirectory in the plugin configuration, not in the assembly descriptor.

Upvotes: 1

Related Questions