0

I am trying to get maven to include an empty directory which is just used for output files created by the webapp (which is why it is empty).

I have googled and the maven-resources-plugin seemed to be the best option for this, the documentation states that the property includeEmptyDirs is since 2.3 and I am using 2.4, however this seems to do nothing and so far the only way Ive managed to get the directory to create is by putting a text file into it, I dont really want to do this if Maven should be able to do this for me.

Can someone tell me what I am doing wrong? Below is my build section from the pom file:

<build>
   <finalName>MyApp</finalName>
   <plugins>
        <plugin>
          <artifactId>maven-compiler-plugin</artifactId>
            <version>3.0</version>          
            <configuration>
              <compilerVersion>1.7</compilerVersion>
              <source>1.7</source>
              <target>1.7</target>
            </configuration>
        </plugin>                           
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-resources-plugin</artifactId>
          <version>2.4</version>
          <configuration>
            <includeEmptyDirs>true</includeEmptyDirs>
          </configuration>
        </plugin>           
    </plugins>
</build>
berimbolo
  • 3,319
  • 8
  • 43
  • 78
  • Where should the empty directory be located after the war file is being deployed ? – khmarbaise Feb 27 '14 at 11:37
  • In the web app section of the war file at the same level as jsp and html files. I tried adding an empty java package to see if that got created but it also didnt appear in the war file. – berimbolo Feb 27 '14 at 11:40
  • How could you write in there from within the application? Does not make sense to me. May be you should take a look at the [maven-war-plugin](https://maven.apache.org/plugins/maven-war-plugin/war-mojo.html#webResources). – khmarbaise Feb 27 '14 at 11:42
  • What do you mean how could I write in there? Its just a directory owned by tomcat, so files can be written there by code running in the web app. This is a legacy app thats been up and running for years and it generates pdf reports etc to this directory and provides users with a link to their unique file. I didnt write it, Im just trying set the project up to work under maven. – berimbolo Feb 27 '14 at 11:43
  • @khmarbaise - Thanks for the help, your answer was correct, including the tag includeEmptyDirectories inside of the maven war plugin was the right way to go instead of using the resources plugin. – berimbolo Feb 27 '14 at 12:16

1 Answers1

1

Take a look at the maven-war-plugin which has a configuration item includeEmptyDirectories.

khmarbaise
  • 92,914
  • 28
  • 189
  • 235