Maven – how to include empty directories

According to this ticket MRESOURCES-36, there should be a <includeEmptyDirs> element, but only for Maven Resources Plugin 2.3.


For Maven versions which included an older version of the Resources plugin:

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.

          <mkdir dir="${basedir}/target/classes/empty" />

This originally came from the openejb-standalone pom.xml in the openejb project.

Leave a Comment