How to make Maven copy resource file into WEB-INF/lib directory?

AlexV picture AlexV · Nov 3, 2011 · Viewed 15.5k times · Source

I'm using NewRelic for monitoring. I want Maven to package both newrelic.jar and newrelic.yaml files into my WEB-INF/lib inside the war file. With the newrelic.jar there is no problem since it's a simple dependency, but newrelic.yaml is a resource file. It resides in resources directory. I want Maven (war plugin) to copy it to WEB-INF/lib when packaging the war.

Thanks.

Alex

Answer

Chris picture Chris · Nov 3, 2011

While I agree with @matt b that this is odd, here's what you can do:

Try changing the configuration of the maven war plugin to include a webResource:

 <configuration>
      <webResources>
        <resource>
          <directory>pathtoyaml</directory>
          <includes>
            <include>**/*.yaml</include>
          <includes>        
         <targetPath>WEB-INF/lib</targetPath>
        </resource>
      </webResources>
    </configuration>

The directory is relative to the pom.xml. See the plugin's documentation for more info.