Gradle code generated from POM fails with "Could not find method providedCompile()"

I am new to gradle. I use 1.11. I have small prototype project designed originally for maven. It is simple project using Wildfly 8 as application server and programmed with Eclipse Kepler.

I tried to convert POM using gradle init. Original POM:

Generated build.gradle (only change I did was changing Compatibility=1.5 to 1.7):

What is shown after execution (just 'gradle’ command in directory with this build.gradle):

  FAILURE: Build failed with an exception.
  * Where:
Build file 'D:\devel\workspace\testland\bookman-back-lend\build.gradle' line: 21
  * What went wrong:
A problem occurred evaluating root project 'bookman-back-lend'.
> Could not find method providedCompile() for arguments [{group=javax.enterprise, name=cdi-api, version=1.1}, build_72hast944m6jurcoj1ihtgd2no$_run_closure2_closure5@59e64a6f] on root project 'bookman-back-lend'.
  * Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
  Total time: 3.156 secs

Problem seems to be with this snippet:

providedCompile(group: 'javax.enterprise', name: 'cdi-api', version:'1.1') {
  exclude(module: 'jsr250-api')
  exclude(module: 'el-api')
  exclude(module: 'jboss-interceptors-api_1.1_spec')

It looks like bug in gradle init (it is incubating, after all). Is there any fix that I could apply by hand to generated file?

Unfortunately, I do not know yet how to create build.gradle from scrath that would build, compile and send app to Wildfly (in essence, what maven plugin wildfly:deploy does).

That’s strange, as ‘gradle init’ will usually generate a comment just above the ‘providedCompile’ line that explains the situation. Unfortunately there is no trivial fix, but searching here or on Stack Overflow for ‘gradle provided’ should give some answers explaining how to cope with this situation.

I guess it is something like ? In this case, adding

apply plugin: 'war'

to beginning of build.gradle helped. At least in sense “no errors”. Thanks for help!

If you want to produce a War, this is indeed the (trivial) solution.

(This is the second time I’ve tried to reply to this. The first time seemed to hang forever.)

It seems to me that the build script created by “build.gradle” should work out of the box, if it’s reasonable to do so. A smooth transition from other build tools is an important consideration. Is it possible for this generator code to note that it also has to add the “war” plugin?