Uploaded image for project: 'Maven Archetype'
  1. Maven Archetype
  2. ARCHETYPE-458

Ability to generate empty directories... with Git or other excluded files.

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Auto Closed
    • 2.2
    • None
    • None
    • None

    Description

      Ok, so following ARCHETYPE-157, empty directories can be generated by configuring includeEmptyDirs for the maven-resources-plugin. However, if one is using Git (or presumably other VCS behaving similarly), really empty directories can't really be source-controlled.

      I was hoping to be able to use the usual git trick of having .empty-placeholder files in my archetype sources. That works, those files are in the archetype jar, even without reconfiguring the resources plugin. My next step was thus to configure my fileSet as such:

      <fileSet encoding="UTF-8">
                <directory>src/main/webapp/</directory>
                <excludes>
                  <exclude>**/.emptydir-placeholder</exclude>
                </excludes>
                <includes>
                  <include>**/*</include>
                </includes>
              </fileSet>
      

      However, this doesn't work, for a combination of two reasons, I believe:

      • The archetype jar does not contain directory entries when files are in these directories (regardless of includeEmptyDirs)
      • The archetype:generate mojo copies a fileset by looking directly are the zip entries, not by somehow normalizing those entries. So it sees no entry for my "empty" directory /foo, but only the one /foo/.empty-placeholder entry, which is excluded.
        As a consequence, the empty directory is, well, excluded and not generated.

      I haven't found a way to force the addition of directory entries in the archetype jar (archetype:jar's configuration is pretty limited, and seems to generate the artifact on its own (straight to a ZipOutputStream)

      A workaround is to not exclude the **/.emptydir-placeholder files in the archetype descriptor, but rather in the <resources> section of the build - so I can keep them in my Git-managed sources, but they're not in the archetype artifact. This somehow feels less elegant to me, but I'll give it a go anyway.

      <build>
        <resources>
          <resource>
              <directory>src/main/resources</directory>
              <excludes>
                <exclude>**/.emptydir-placeholder</exclude>
              </excludes>
            </resource>
      ...
      

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              gjoseph Grégory Joseph
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: