I want to create empty directory structure while doing the packaging using maven-assembly-plugin. I am successful in including all the files, but not creating the empty ones,
opt/SP/myprod/bin/* (contains files)
opt/SP/myprod/lib/* (contains files)
opt/SP/myprod/conf/* (contains files)
var/SP/myprod/run (Empty directories)
var/SP/myprod/log (Empty directories)
var/SP/myprod/tmp (Empty directories)
The below one is my assembly file,
<id>stage</id>
<formats>
<format>tar.gz</format>
<format>zip</format>
</formats>
<fileSets filtered="true" encoding="UTF-8">
<fileSet>
<directory>${run.dir}</directory>
<fileMode>755</fileMode>
</fileSet>
<fileSet>
<directory>${tmp.dir}</directory>
<fileMode>755</fileMode>
</fileSet>
<fileSet>
<directory>${log.dir}</directory>
<fileMode>755</fileMode>
</fileSet>
<fileSet>
<directory>${basedir}/config</directory>
<outputDirectory>${install.dir}/config</outputDirectory>
<fileMode>755</fileMode>
</fileSet>
<fileSet>
<directory>${basedir}/bin</directory>
<outputDirectory>${install.dir}/bin</outputDirectory>
<fileMode>755</fileMode>
</fileSet>
<fileSet>
<directory>${basedir}/images</directory>
<outputDirectory>${install.dir}/images</outputDirectory>
<fileMode>755</fileMode>
</fileSet>
<fileSet>
<directory>${basedir}/package-scripts</directory>
<outputDirectory>${install.dir}/package-scripts</outputDirectory>
<fileMode>755</fileMode>
</fileSet>
<fileSet>
<directory>${project.build.directory}</directory>
<outputDirectory>${install.dir}/lib</outputDirectory>
<includes>
<include>myfile.jar</include>
</includes>
<fileMode>755</fileMode>
</fileSet>
<fileSet>
<directory>${project.build.directory}/lib</directory>
<outputDirectory>${install.dir}/lib</outputDirectory>
<fileMode>755</fileMode>
</fileSet>
</fileSets>
So, I tried the simple "directory" tag as recommended in one of the blog, but no luck.
Could any one help me please?
Note that @khmarbaise's answer will not exclude all subfolders, you need to use a stronger wildcard:
<fileSets>
<fileSet> <!-- Create empty directory -->
<outputDirectory>coredumps</outputDirectory>
<excludes><exclude>**/*</exclude></excludes>
</fileSet>
</fileSets>
Found at How do I include an empty directory in a maven assembly?
You can use a thing like this here:
<fileSets>
<fileSet>
<outputDirectory>/an-other-empty-folder</outputDirectory>
<directory>${project.basedir}/target</directory>
<excludes>
<exclude>*</exclude>
</excludes>
</fileSet>
</fileSets>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With