On 25/10/2011, at 5:25 AM, Eric Berry wrote:
> I'm trying to update the gradle-templates (and the gradle-release) plugin to
> work for Gradle 1.0 M5. My understanding is that the easiest way to get
> plugins installed now is to use an 'apply from' script, but my script seems
> to be failing with milestone-5 (20111024073824+0200).
>
> Running 'gradle tasks' yeilds:
> [quote]
> [508] gradle tasks
> SimpleHttpConnectionManager being used incorrectly. Be sure that
> HttpMethod.releaseConnection() is always called and that only one thread
> and/or method is using this connection manager at a time.
> Download
> http://launchpad.net/gradle-templates/trunk/1.1/+download/templates-1.1.jar
>
> FAILURE: Build failed with an exception.
>
> * Where:
> Script
> '/Users/elberry/development/projects/mine/gradle-templates/installation/apply.groovy'
> line: 12
>
> * What went wrong:
> A problem occurred evaluating script.
> Cause: Plugin with id 'templates' 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
>
> Total time: 6.35 secs
> [/quote]
>
> As you can see, the plugin jar file was downloaded correctly, however the
> plugin still can't be found.
>
> [code src='apply.groovy']
> buildscript {
> repositories {
> ivy {
> name = 'gradle_templates'
> artifactPattern
> "http://launchpad.net/[organization]/trunk/[revision]/+download/[artifact]-[revision].jar"
> }
> }
> dependencies {
> classpath 'gradle-templates:templates:1.1'
> }
> }
> apply plugin: 'templates'
At the moment, the apply method uses the classpath of the project to find
plugins, not the classpath of the script, so this isn't going to work. Could
you add a jira issue for this problem?
We should probably be looking first in the script classloader, and then in the
project classloader. This would work for your script above.
Or perhaps applying a script makes the classpath of the script available to the
project in some way, so that you can have the buildscript { } logic in one
script, and the apply plugin: statements in some other script. We've talked
about doing this also to make the task types defined in one script available to
the other scripts.
Until we fix this, a work around would be to move all that stuff to the
build.gradle. Another would be to apply the plugin by type:
apply plugin: TemplatePluginClass
> [/code]
>
> [code src='build.gradle']
> apply from:
> 'file:///Users/elberry/development/projects/mine/gradle-templates/installation/apply.groovy'
> [/code]
>
> Not sure what I'm doing wrong here, any help would be greatly appreciated.
>
> Thanks,
> Eric
>
> --
> Learn from the past. Live in the present. Plan for the future.
> Blog: http://eric-berry.blogspot.com
> jEdit <http://www.jedit.org> - Programmer's Text Editor
> Bazaar <http://bazaar.canonical.com> - Version Control for Humans
--
Adam Murdoch
Gradle Co-founder
http://www.gradle.org
VP of Engineering, Gradleware Inc. - Gradle Training, Support, Consulting
http://www.gradleware.com