Hi Benjamin,

when running your snippet
----------
project.buildscript.dependencies.add("classpath", "commons-lang:commons-lang:2.5")
----------
in your plugin (I guess when its applied?) the classpath configuration for your gradle build is already in resolved state. The classpath configuration is resolved directly after the buildscript closure in your buildscript is evaluated.

regards,
René

Am 14.03.11 22:39, schrieb Benjamin Muschko:
Hi,

I am trying to add a classpath dependency in a custom plugin instead of
defining it in my build script like this.:

buildscript {
    repositories {
       mavenCentral()
    }

    dependencies {
       classpath 'commons-lang:commons-lang:2.5',<--- shows an example of a
JAR I want to move into the plugin
                      'somegroup:myplugin:0.1'
    }
}

The classes of the dependency are being used by the plugin itself. What's
the best way to do this? I want to prevent plugin users having to define the
dependency. I tried to go with this in my plugin implementation:

project.buildscript.dependencies.add("classpath",
"commons-lang:commons-lang:2.5")

However, that throw this exception:

Caused by: org.gradle.api.InvalidUserDataException: You can't change a
configuration which is not in unresolved state!
        at
org.gradle.api.internal.artifacts.configurations.DefaultConfiguration.throwExceptionIfNotInUnresolvedState(DefaultConfiguration.java:430)
        at
org.gradle.api.internal.artifacts.configurations.DefaultConfiguration.addDependency(DefaultConfiguration.java:297)
        at org.gradle.api.artifacts.Configuration$addDependency.call(Unknown
Source)
        at
org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.pushDependency(DefaultDependencyHandler.groovy:52)
        at
org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.this$2$pushDependency(DefaultDependencyHandler.groovy)
        at
org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler$this$2$pushDependency.callCurrent(Unknown
Source)
        at
org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.add(DefaultDependencyHandler.groovy:42)

There must be something I am missing. Any help would be highly appreciated.

Thanks,

Ben

--
View this message in context: 
http://gradle.1045684.n5.nabble.com/Defining-buildscript-dependency-in-custom-plugin-tp3620230p3620230.html
Sent from the gradle-user mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

     http://xircles.codehaus.org/manage_email



--
-----------------------
regards René

rene groeschke
http://www.breskeby.com
@breskeby


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email


Reply via email to