Search code examples
javamaventomcatwarmaven-war-plugin

Maven: creating a war with a ROOT dir


I have always (for the purposes of vhost configuration in apache and tomcat) deployed my web app into tomcat as follows by extracting a tar.gz file which is built by ant;

tomcat/webapps/myApp/ROOT/<application>

and so this is what production expects.

Having recently moved to maven for the build system for same app, I'm finding it impossible to achieve the above with my war to the point where I'm starting to think I've got the wrong approach. I want my war to explode with a top level ROOT directory such as;

ROOT  
|- META-INF  
|- WEB-INF  
|- other folders

Is it possible to tweak the war builder plugin to accomplish this?


Solution

  • A .war file has a defined structure internally, and what you're trying to produce doesn't fit that.

    Some options to consider:

    1. Use war files like they are meant to be used, i.e. you have one that has a top-level WEB-INF directory.
    2. Use the assembly plugin instead and produce your structure manually
    3. Possibly: look into .ear files, which combine multiple .war and additional resources.