Gradle with Eclipse - resources are not filtered

I have a gradle configuration setting to filter some resources and replace properties depending on the environment (e.g. dev, production). They are located at:

  • Src / main / resources / config.xml
  • WebContent / WEB-INF / web.xml

An example property from my web.xml file is shown below:

<context-param>
  <param-name>server.url</param-name>
  <param-value>${server_url}</param-value>
</context-param>

An excerpt from my build.gradle is presented below:

apply plugin: 'eclipse-wtp'

processResources {
  expand(props) // filter properties by environment
  exclude 'log4j.properties'
}

war {
    from 'WebContent'
    exclude('WEB-INF/web.xml')
    webInf {
        from 'WebContent/WEB-INF/web.xml'
        expand(props)
    }
    webXml = null
}

This works fine when I build a war from the command line, but when I use this configuration from Eclipse, it does not seem to filter the resource accordingly.

I previously had a Maven plugin in which resources will be filtered as part of the Eclipse build. Can I force Eclipse to filter resources?

+4
1

webAppDirName war { ... }. , Gradle , 2.0. . http://www.gradle.org/docs/current/userguide/war_plugin.html.

gradle eclipse Eclipse wtp!

0

Source: https://habr.com/ru/post/1544279/


All Articles