Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I create empty directories while packaging using maven-assembly-plugin?

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?

like image 794
Rajesh Balan Avatar asked Jul 23 '14 11:07

Rajesh Balan


2 Answers

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?

like image 71
crobicha Avatar answered Nov 14 '22 15:11

crobicha


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>
like image 43
khmarbaise Avatar answered Nov 14 '22 15:11

khmarbaise