Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I include an empty directory in a maven assembly?

In what must be a common occurence, I need to include an empty directory in an assembly. In my case it is logs/.

I've tried different variations in the assembly descriptor like:

<fileSet>   <directory>${basedir}/target</directory>   <includes>     <include>doesntexist</include>   </includes>   <outputDirectory>/logs</outputDirectory>   <fileMode>0644</fileMode> </fileSet> 

and the directory just gets pruned.

I tried to exclude as well, but that still included lots of stuff:

<fileSet>   <directory>${basedir}/target</directory>   <excludes>     <exclude>*</exclude>   </excludes>   <outputDirectory>/logs</outputDirectory>   <fileMode>0644</fileMode> </fileSet> 
like image 427
Dave Stenglein Avatar asked Oct 26 '11 21:10

Dave Stenglein


People also ask

What is a maven assembly?

The Assembly Plugin for Maven enables developers to combine project output into a single distributable archive that also contains dependencies, modules, site documentation, and other files. Your project can easily build distribution "assemblies" using one of the prefabricated assembly descriptors.


2 Answers

This always works for me:

<fileSets>   <fileSet>     <directory>.</directory>     <outputDirectory>logs</outputDirectory>     <excludes>       <exclude>*/**</exclude>     </excludes>   </fileSet> </fileSets> 
like image 165
Christopher Avatar answered Sep 16 '22 16:09

Christopher


Courtesy, this SO answer and with some trial and error, the following one seems to work for me...

<fileSet>   <directory>src/main/assembly</directory>   <outputDirectory>/logs</outputDirectory>   <excludes>     <exclude>*</exclude>   </excludes> </fileSet> 

The key seems to be to ensure that <directory> tag specifies a valid/existing folder, which does not have any subfolders.

like image 44
Raghuram Avatar answered Sep 16 '22 16:09

Raghuram