opticyclic
opticyclic

Reputation: 8126

Gradle Error configurations.add String cannot be cast to Configuration

My gradle file says

configurations.add "externalDeps"

If I run gradle with 1.4 I don't have a problem.

If I run gradle with 2.0 I get the following error:

Caused by: java.lang.ClassCastException: java.lang.String cannot be cast to org.gradle.api.artifacts.Configuration
    at org.gradle.api.artifacts.Configuration$Namer.determineName(Configuration.java:87)
    at org.gradle.api.internal.DefaultNamedDomainObjectCollection.add(DefaultNamedDomainObjectCollection.java:70)
    at org.gradle.api.NamedDomainObjectCollection$add$0.call(Unknown Source)
    at build_3p9qdtholqj79o8rnevdt3d7t0.run(D:\Code\trunk\projects\build.gradle:6)
    at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:52)
    ... 82 more

What has changed that is causing this error?

How should I be defining this now?

Upvotes: 2

Views: 1349

Answers (1)

JB Nizet
JB Nizet

Reputation: 691805

The manual explains how to create a configuration:

configurations {
    externalDeps
}

The DSL documentation shows that the configuration container has a method create():

configurations.create('externalDeps')

The API doc for the class shows that all its add() methods take a Configuration as argument, hence the exception you get.

Upvotes: 3

Related Questions