'resource' method on WtpComponent overwrites default wb-resource instead of adding

Tested on Gradle 1.5 and Gradle 1.7

Consider this code block in a script:

eclipse {
 wtp {
  component {
   resource deployPath: '/foobar', sourcePath: 'profiles/development/src/main/webapp'
   println resources
  }
 }
  }

According to documentation, a wb-resource element with sourcePath ‘profiles/development/src/main/webapp’ and deployPath ‘foobar’ should be added to the org.eclipse.wst.common.component.

Instead the result is this:

...
...
                <wb-resource deploy-path="/WEB-INF/classes" source-path="src/main/java"/>
                <wb-resource deploy-path="/foobar" source-path="profiles/development/src/main/webapp"/>
                <dependent-module deploy-path="/WEB-INF/lib" handle="module:/resource/tavant-common/tavant-common">
                        <dependency-type>uses</dependency-type>
                </dependent-module>
...
...

To get the documentation behavior one has to restate the default:

eclipse {
 wtp {
  component {
   resource deployPath: '/foobar', sourcePath: 'profiles/development/src/main/webapp'
   resource deployPath: '/', sourcePath: project.webAppDirName
  }
 }
  }

Either this is a bug, or the documentation is wrong.

Note that this project is a child project in a multiproject build.

I think what the documentation tries to convey is that multiple calls to ‘resource’ are additive, not that the defaults are kept.

Please update the documentation since it was not clear at all to me (and I guess a lot of other users too).

Looking at this again, I think it’s a bug. Raised GRADLE-2894.

Fixed this by pull request http://github.com/gradle/gradle/pull/368, see also http://stackoverflow.com/questions/22957776/gradle-eclipse-wtp-plugin-adding-wb-resource-removes-webappdir-from-deployment.