Search code examples
javaspring-bootmavenmaven-assembly-pluginmaven-shade-plugin

Maven - Include external resource at the root of war file


I have a resource file at the root of my maven project. The directory structure is as follows.

src/
pom.xml
resource_file

Inside pom.xml, I've mentioned the resource as:

<build>
   <resources>
        <resource>
            <directory>.</directory>
            <includes>
                <include>resource_file</include>
            </includes>
        </resource>
    </resources>
</build>

Inside the war file, the resource_file is present at WEB-INF/classes/resource_file. I need the resource_file to be at the root of the war file. I can unzip the war file and move the resource_file to root and create the war file again. But, is there any way to accomplish this through maven itself?


Solution

  • The default is to put resources into src/main/webapp directory which will automatically put into the root of the resulting war file.

    The docs has also an example of that.