Unable to apply external gradle plugins


(Zach Carter) #1

I have been trying over the past few months to apply gradle plugins, specifically from GitHub using a buildscript block to my projects. I’m unable to get even the sample build.gradle files to execute without throwing ‘Plugin not found with id …’ errors.

Here’s an example of trying to apply the cargo plugin to a buildscript -

apply plugin: 'cargo'
  repositories {
    mavenCentral()
}
  buildscript {
    println 'RUNNING BUILDSCRIPT CONFIG!'
    repositories {
        add(new org.apache.ivy.plugins.resolver.URLResolver()) {
            name = 'GitHub'
            addArtifactPattern 'http://cloud.github.com/downloads/[organisation]/[module]/[module]-[revision].[ext]'
        }
    }
        dependencies {
        classpath 'bmuschko:gradle-cargo-plugin:0.3'
    }
}
  cargo {
 containerId = 'tomcat6x'
 port = 8080
 context = "mycontext"
 remote {
  hostname = "192.168.1.101"
  username = "tomcat"
  password = "tomcat"
 }
}
  dependencies {
    providedCompile 'javax.servlet:servlet-api:2.5'
    cargo 'org.codehaus.cargo:cargo-core-uberjar:1.1.1',
          'org.codehaus.cargo:cargo-ant:1.1.1',
          'jaxen:jaxen:1.1.1'
}

When I execute gradle tasks this is what I see in the console -

d:\Learning\marcinkwiatkowski-gradle-webapp-8aa798a>gradle tasks RUNNING BUILDSCRIPT CONFIG!

FAILURE: Build failed with an exception.

  • Where: Build file ‘D:\Learning\marcinkwiatkowski-gradle-webapp-8aa798a\build.gradle’ line: 1

  • What went wrong: A problem occurred evaluating root project ‘marcinkwiatkowski-gradle-webapp-8aa798a’. > Plugin with id ‘cargo’ not found.

  • Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Any ideas what I’m doing wrong here?

Thanks,

-Zach


(Benjamin Muschko) #2

See comments and further discussion on the GitHub issue page.


(Zach Carter) #3

This happens with EVERY external gradle plugin I try to reference in a buildscript block. I have a strong feeling it’s environmental related but I’m not sure why exactly.


(Zach Carter) #4

Just an update -

I’ve created a git hub repo for a sample project I receive the error described above when compiling.

https://github.com/carterza/GradlePluginIssue

I’ve commented out the “apply plugin: ‘tomcat’” line which causes the error to be thrown in the build.gradle file. When I uncomment this line I receive a “Plugin with id ‘tomcat’ not found” error.

Thanks,

-Zach


(Zach Carter) #5

Please find a sample project at - https://github.com/carterza/GradlePluginIssue - where I am experiencing the issue described above.

Presently the offending “apply plugin: ‘tomcat’” line is commented out in the build.gradle file. If I uncomment this line, I receive the following error:

“Plugin with id ‘tomcat’ not found.”

Still no idea what’s causing this issue.

Thanks,

-Zach


(Luke Daley) #6

Your project builds fine for me. This is very strange.

What platform/JDK version are you on?


(Janice Gluck) #7

I’m facing the same issue…

I’m on macbook retina display using java 1.7

Has anyone found a solution?


(shadowfen) #8

Be sure to put the “apply plugin: ‘cargo’” line AFTER the buildscript section which brings in your cargo dependency and adds it to the class path.