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

后端 未结 3 1668
天命终不由人
天命终不由人 2020-12-30 19:33

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 des

相关标签:
3条回答
  • 2020-12-30 20:09
    <fileSets>
        <fileSet>
            <directory>./EMPTY_DIRECTORY_NAME</directory>
            <outputDirectory>/REQUIRED_DIRECTORY_NAME in Assembly </outputDirectory>
            <excludes>
                <exclude>*/**</exclude>
            </excludes>
        </fileSet>
    </fileSets>
    

    e.g.

    <fileSets>
        <fileSet>
            <directory>./Logs</directory>
            <outputDirectory>/Feed</outputDirectory>
            <excludes>
              <exclude>*/**</exclude>
            </excludes>
        </fileSet>
    </fileSets>
    

    In this case even though there are some content inside Logs directory, it will not be included in assembled binary in Feed directory.

    0 讨论(0)
  • 2020-12-30 20:16

    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.

    0 讨论(0)
  • 2020-12-30 20:30

    This always works for me:

    <fileSets>
      <fileSet>
        <directory>.</directory>
        <outputDirectory>logs</outputDirectory>
        <excludes>
          <exclude>*/**</exclude>
        </excludes>
      </fileSet>
    </fileSets>
    
    0 讨论(0)
提交回复
热议问题