Using Custom Plugin - Templates

I’m trying to use the Templates custom plugin. I followed the installation instructions at http://tellurianring.com/wiki/gradle/templates by placing the plugin jar in the $GRADLE_HOME/lib/plugins directory.

Using “apply plugin: ‘templates’” in my build script results in a “Plugin with id ‘templates’ not found” exception. I’ve tried various different names including package.classname, path URIs, etc with no luck. The only thing I haven’t tried is specifying the lib/plugins directory as a repository and declaring a classpath dependency to the jar - that seems like overkill.

Is there something I need to do to make Gradle see or detect the plugin jar in lib/plugins?

Thanks,

Kalin

Ok, I saw the breaking change note in the milestone 5 release notes pertaining to build script classpath.

I moved the templates-1.1.jar to $GRADLE_HOME/customPlugins (just a place to put them for now) and defined the following in my build file:

buildscript{

repositories {

flatDir dirs: “$(gradle.gradleHomeDir}/customPlugins”

}

dependencies {

classpath ‘:templates:1.1’

} }

apply plugin: ‘templates’

This worked but is a lot more involved than dropping a jar in a directory. Maybe this will help someone else.

Great answer Kalin. Milestone .9 has the same issue still.

because the following line did not download the templates.jar file to my lib area,

[apply from: ‘http://launchpad.net/gradle-templates/trunk/latest/+download/apply.groovy’]

I downloaded and copied templates-1.2.jar into gradle_home/lib/plugins I used your code above.

I fixed the mismatched brackets in line: ${gradle.gradleHomeDir}/lib/plugins I changed the classpath to be :templates:1.2 I used a gradle.properties file to define my two proxy http.proxyHost and http.proxyPort settings

type> gradle tasks

This works, and you saved me a lot of time.

Thanks very much.

I found this solution for my windows environment where it didn’t seem to work:

http://codeandcookies.tumblr.com/post/24898112043/gradle-templates-plugin

Basically, the apply from url returns a redirect, and that didn’t work for me. So I replace the apply from url with the url from the redirect and then it works out of the box.