简体   繁体   中英

Overriding web.xml context params

I have a maven project that I am migrating to gradle. In the maven project I use the jetty plugin and provide an overrideDescriptor like this:

  <webAppConfig>
      <overrideDescriptor>override.xml</overrideDescriptor>
  </webAppConfig>

Using this, I can override some context parameters from my web.xml with parameters from the override.xml , but any parameters not in the override.xml will revert to the value in the web.xml . This all works as expected.

Now that I am moving to gradle, I am trying to replicate this using the gradle jetty plugin. I tried providing a webXml value, but it replaces the entire web.xml file:

jettyRun {
    webXml file('override.xml')
}

Is there any way I can provide the same override functionality via gradle, or am I stuck reworking my override file to be a complete replacement for my default web.xml.

Try overrideWebXml , eg:

jettyRun {
  overrideWebXml file('override.xml')
}

This is a property on AbstractJettyRunTask , and worked for me.

This would be entirely within the gradle plugin so best to check the documentation for the plugin to see if there is an override option. If not it ought to be relatively easy to add it and contribute back to that project.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM