Friday, May 20, 2011

add static resource directories to jetty-maven-plugin 7.x

When using jetty-maven-plugin during development of a web application with the command mvn jetty:run. I need to use some static resources which I DO NOT want to put in src/main/webapp. I put DEV resources into src/test/webapp instead. But jetty does not load these resources by default. So the following jetty-maven-plugin configuration show how to provide static resources.

<plugin>
    <groupId>org.mortbay.jetty</groupId>
    <artifactId>jetty-maven-plugin</artifactId>
    <configuration>
        <webAppConfig>
        ...
            <resourceBases>
                <resourceBase>src/main/webapp</resourceBase>
                <resourceBase>src/test/webapp</resourceBase>
            </resourceBases>
        ...
        </webAppConfig>
    </configuration>
</plugin>

2 comments:

  1. Thank you, but I want something more specific, a way to add only one folder, not an entire one, something like this is possible:


    src/main/webapp
    src/test/webapp/onlyThisFolder

    ReplyDelete
    Replies
    1. Of course you can set the folder you want but all the subfolder will be available.

      Delete