A dependency on configuration 'default'


(mark.harris) #1

Hi,

I’m getting the following error when trying to run my Gradle script:

Module version group:myGroup, module:myModule, version:1.0, configuration:testCompile declares a dependency on configuration 'default' which is not declared in the module descriptor for group:myGroup, module:myJarFile, version:1.0

My understanding was that if I don’t specify which configuration to depend on, I utilise ‘default’. Does this need to be explicitly defined in the script? I’m not doing so at the moment. If I do so:

configurations {
    default
}

I get the following:

> startup failed: build file '<directory>\build.gradle': 12: unexpected token: default @ line 12, column 5.
         default
         ^
    1 error

Thanks.


Configuration 'compile' declares a dependency on configuration 'default' which is not declared in the module descriptor
(Luke Daley) #2

The problem is that “default” is a keyword in Groovy (and Java).

You can use the following code:

dependencies {
  it."default"
}

This works because

dependencies {
  default
}

Is the same as:

dependencies.default

When you use the closure version, the ‘dependencies’ object is passed to the closure as the implicit argument, and Groovy supports using strings as property names for situations like this (and others).


Publishing sources jar to Ivy with separate configuration
(mark.harris) #3

I have tried adding this code to the build script:

dependencies {
    it."default"
}

… and I now get the following error:

groovy.lang.MissingPropertyException: No such property: default for class: org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler
        at build_9nk811bjk2lvcjfv5uodt9ie1$_run_closure1.doCall(<directory>\build.gradle:12)
        at org.gradle.util.ConfigureUtil.configure(ConfigureUtil.java:141)
        at org.gradle.util.ConfigureUtil.configure(ConfigureUtil.java:90)
        at org.gradle.api.internal.project.AbstractProject.dependencies(AbstractProject.java:880)
        at org.gradle.api.internal.BeanDynamicObject$MetaClassAdapter.invokeMethod(BeanDynamicObject.java:196)
        at org.gradle.api.internal.BeanDynamicObject.invokeMethod(BeanDynamicObject.java:102)
        at org.gradle.api.internal.CompositeDynamicObject.invokeMethod(CompositeDynamicObject.java:99)
        at org.gradle.groovy.scripts.BasicScript.methodMissing(BasicScript.java:83)
        at build_9nk811bjk2lvcjfv5uodt9ie1.run(<directory>\build.gradle:11)
        at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:52)

(Peter Niederwieser) #4

I think Luke meant ‘configurations’, not ‘dependencies’.


(mark.harris) #5

Hmmm… if I include the following in my script:

configurations {
    it."default"
}

… then I get the same error as previously about declaring a dependency on configuration ‘default’ which is not declared in the module descriptor.


(Peter Niederwieser) #6

Without a reproducible example, there isn’t much I can do. Usually it isn’t necessary to declare a ‘default’ configuration.


(mark.harris) #7

Not sure how to progress this as it’s still an issue but the error is associated with in-house jars which are utilised as part of the testCompile task. If I replace the dependency declaration:

testCompile "jarGroup:jarName:latest.integration"

… with the following:

testCompile group: "jarGroup", name: "jarName", version: "latest.integration", configuration: "core"

… then it works, even though I have not declared a configuration called “core” in the script anywhere.


(mark.harris) #8

Followup: I think the issue arises because the jar - created in Ivy - was done so as part of a configuration called “core”. This is per the section entitled “Depending on modules with multiple artifacts” in the Dependency management section.