SteakTartaar
SteakTartaar

Reputation: 939

Maven: zip resources and save into specific folder

For a project I need to zip a number of resource files and put this archive inside the project source (src/main/resources). The idea is that this archive then ends up in the EAR and goes to the deployment server, where it is picked up by a script for further processing. Convoluted, I know, but those are the constraints we are working with.

I've created an Assembly plugin configuration file that creates the zip, but this zip is placed by default in a target/ folder.

The assembly plugin has an outputDirectory option, but this only changes the filestructure of the contents of the zip, not the location where the zip is saved.

Is there a way to specify where the assembly plugin saves the created zip? Or is there a better way altogether to zip resources?

Upvotes: 1

Views: 907

Answers (2)

Karthick Sabhapathy
Karthick Sabhapathy

Reputation: 36

Please add the following code in pom.xml , provide the path in outputDirectory tag :

     <execution>
             <id>assembly-execution</id> 
            <phase>package</phase> 
            <goals>
            <goal>single</goal> 
            </goals>
            <configuration>
            <finalName>zipFileName</finalName>
            <appendAssemblyId>false</appendAssemblyId>
            <descriptors>
                <descriptor>${project.basedir}/zip.xml</descriptor>
            </descriptors>
 <outputDirectory>${project.basedir}/src/main/resources</outputDirectory>
            </configuration>             
     </execution>

Upvotes: 1

Jigar Joshi
Jigar Joshi

Reputation: 240880

there are two outputDirectory configuration, one represents the file path inside your assembled package, another one represents directory where your assembled package would be output

you are looking for second one

Upvotes: 2

Related Questions