Adding and configuring a custom plugin in a script that gets included?

We are using the embedded tomcat plugin and have decided to externalize the configuration for easy re-use.

I extracted everything out to embedded.gradle that used to live in our build.gradle.

apply plugin: 'tomcat'
 buildscript.repositories {
  add(new org.apache.ivy.plugins.resolver.URLResolver()) {
   name = 'GitHub-4-tomcat'
     addArtifactPattern '[organisation]/[module]/[module]-[revision].[ext]'
       dependencies {
  classpath 'bmuschko:gradle-tomcat-plugin:0.8.2'
     dependencies {
 def tomcatVersion = '7.0.11'
 tomcat "org.apache.tomcat.embed:tomcat-embed-core:${tomcatVersion}",
   tomcat("org.apache.tomcat.embed:tomcat-embed-jasper:${tomcatVersion}") {
  exclude group: 'org.eclipse.jdt.core.compiler', module: 'ecj'
 configFile = file("src/test/resources/tomcat-context.xml")
 httpPort = tomcatStartPort as int
 stopPort = tomcatStopPort as int
 stopKey = "ctl-d"
  //-- test hooks to run/stop tomcat around test execution
task integrationTest(type: Test) {
 include '**/*IntegrationTest.*'
   doFirst {
  tomcatRun.daemon = true
   doLast { tomcatStop.execute() }

Now I just include it in our build.gradle:

apply from: './tomcat-embedded.gradle'

And it fails with the following trace.

  * What went wrong:  A problem occurred evaluating script.  > Plugin with id 'tomcat' not found.


Any ideas?

Did you try this already?

apply plugin: org.gradle.api.plugins.tomcat.TomcatPlugin

This seems to be a bug in gradle. @James, can you confirm that refering the plugin by classname works for you?

It’s GRADLE-2136.

@andrewbgoode thanks. I gave it a try but unfortunately it still doesn’t work.

Strange. Can you double check that you used a class name rather than a String containing a class name?