Maven Resources Plugin
  1. Maven Resources Plugin
  2. MRESOURCES-36

resource copy to target/classes: empty directories are ignored

    Details

    • Type: Improvement Improvement
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.2
    • Fix Version/s: 2.3
    • Component/s: None
    • Labels:
      None
    • Number of attachments :
      1

      Description

      Hi,
      I have several directories located in the src/test/resources and I
      need them to be copied to target/test-classes. This is of course handled
      by maven-resources-plugin, however it does not copy empty directories. I
      know it sounds insane to access empty dirs using classloader but I have
      my reasons

        Issue Links

          Activity

          Hide
          Peter Anning added a comment -

          Not insane at all we have a valid reason for wanting to do the same thing.

          I have patched the resources plugin to take a new parameter includeEmptyDirectories just add the following configuration:

          <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-zip-plugin</artifactId>
          <version>2.2</version>
          <extensions>true</extensions>
          <configuration>
          <includeEmptyDirs>true</includeEmptyDirs>
          </configuration>
          </plugin>

          If the directory is empty then it will appear in the output. If the directory is not empty and a filtering rule excludes all its files it will NOT appear in the output.

          Peter

          Show
          Peter Anning added a comment - Not insane at all we have a valid reason for wanting to do the same thing. I have patched the resources plugin to take a new parameter includeEmptyDirectories just add the following configuration: <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-zip-plugin</artifactId> <version>2.2</version> <extensions>true</extensions> <configuration> <includeEmptyDirs>true</includeEmptyDirs> </configuration> </plugin> If the directory is empty then it will appear in the output. If the directory is not empty and a filtering rule excludes all its files it will NOT appear in the output. Peter
          Hide
          Peter Anning added a comment -

          Sorry wrong plugin config:

          <plugin>
          <artifactId>maven-resources-plugin</artifactId>
          <version>2.2-Dialect</version>
          <configuration>
          <includeEmptyDirectories>true</includeEmptyDirectories>
          </configuration>
          </plugin>

          Show
          Peter Anning added a comment - Sorry wrong plugin config: <plugin> <artifactId>maven-resources-plugin</artifactId> <version>2.2-Dialect</version> <configuration> <includeEmptyDirectories>true</includeEmptyDirectories> </configuration> </plugin>
          Hide
          Peter Anning added a comment -

          Patch adds includeEmptyDirectories parameter to the plugin configuration

          Show
          Peter Anning added a comment - Patch adds includeEmptyDirectories parameter to the plugin configuration
          Hide
          Luc Maisonobe added a comment -

          Any chance this patch will be included soon ?
          I also need these empty directories and the current behaviour is different from eclipse behaviour.

          Show
          Luc Maisonobe added a comment - Any chance this patch will be included soon ? I also need these empty directories and the current behaviour is different from eclipse behaviour.
          Hide
          Jörg Hohwiller added a comment -

          I have the same need and gave my vote for it.

          Show
          Jörg Hohwiller added a comment - I have the same need and gave my vote for it.
          Hide
          Jonathan Ramsey added a comment -

          Until this issue is fixed, here is a workaround I've been using successfully. Add this plugin element into project/build/plugins in your pom.xml, and change the dir in the mkdir task.

          You can have multiple <mkdir> elements for multiple directories. The mkdir task does nothing if the directory has already been copied by the resources plugin.

          <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-antrun-plugin</artifactId>
          <executions>
          <execution>
          <id>create-empty-directory</id>
          <phase>process-classes</phase>
          <goals>
          <goal>run</goal>
          </goals>
          <configuration>
          <tasks>
          <mkdir dir="$

          {basedir}

          /target/classes/empty" />
          </tasks>
          </configuration>
          </execution>
          </executions>
          </plugin>

          This originally came from the openejb-standalone pom.xml in the openejb project.
          http://svn.apache.org/repos/asf/openejb/trunk/openejb3/assembly/openejb-standalone/pom.xml

          Show
          Jonathan Ramsey added a comment - Until this issue is fixed, here is a workaround I've been using successfully. Add this plugin element into project/build/plugins in your pom.xml, and change the dir in the mkdir task. You can have multiple <mkdir> elements for multiple directories. The mkdir task does nothing if the directory has already been copied by the resources plugin. <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-antrun-plugin</artifactId> <executions> <execution> <id>create-empty-directory</id> <phase>process-classes</phase> <goals> <goal>run</goal> </goals> <configuration> <tasks> <mkdir dir="$ {basedir} /target/classes/empty" /> </tasks> </configuration> </execution> </executions> </plugin> This originally came from the openejb-standalone pom.xml in the openejb project. http://svn.apache.org/repos/asf/openejb/trunk/openejb3/assembly/openejb-standalone/pom.xml
          Hide
          Olivier Lamy added a comment -

          fixed in rev 695680
          Patch not used.

          Show
          Olivier Lamy added a comment - fixed in rev 695680 Patch not used.
          Hide
          Jörg Hohwiller added a comment -

          Fix uses different configuration:

          <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-resources-plugin</artifactId>
          <version>2.3</version>
          <configuration>
          <includeEmptyDirs>true</includeEmptyDirs>
          </configuration>
          </plugin>

          Show
          Jörg Hohwiller added a comment - Fix uses different configuration: <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-resources-plugin</artifactId> <version>2.3</version> <configuration> <includeEmptyDirs>true</includeEmptyDirs> </configuration> </plugin>

            People

            • Assignee:
              Olivier Lamy
              Reporter:
              Martin Vysny
            • Votes:
              8 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: