user447607
user447607

Reputation: 5469

Why is Gradle not finding 'project()' method in subproject dependencies?

I'm both a Gradle newb and a Groovy newb. Unfortunately I don't get the luxury of learning them separately.

The error:

Build file '/shave-and-a-haircut-two-bits/parentproject/childproject/build.gradle' line: 9

* What went wrong:
A problem occurred evaluating project ':commonstuff:services'.
> Could not find method project() for arguments [[org.apache.cxf:cxf-rt-frontend-jaxrs, ... 
DefaultExternalModuleDependency{group='org.codehaus.jettison', name='jettison', version='null', configuration='default'},
DefaultExternalModuleDependency{group='org.apache.cxf', name='cxf-rt-security', version='null', configuration='default'}]] on project ':commonstuff:services'.

So the lists of dependencies seem to be working and are available to the subproject at least. Otherwise I doubt we would get such a detailed complaint.

The subproject build file:

apply plugin: 'war'

description = 'services'
dependencies {
    ...        
    compile project(rootProject.ext.cxf)
    compile project(rootProject.ext.springframework)    
    ...

}

Note the use of the Spring dependencyManagement plug-in and the use of Lists stored as properties in the root project to manage groups of dependencies, CXF included. No versions are specified as dependencyManagement should handle that... right?

Clue please?

Upvotes: 0

Views: 742

Answers (1)

Opal
Opal

Reputation: 84756

There are actually two methods, called project in Project API. One accepts a String path and the second one overrides the first and accepts a Closure as a second argument. What you actually passed as an argument is a List, so there's no method that matches the given argument. It seems that in this particular case:

compile (rootProject.ext.cxf)

will do what you need to be done.

Upvotes: 1

Related Questions