Controlling eclipse project name with archivesBaseName not working when configured from root multiproject build file

I’m attempting to keep my gradle build as DRY as possible so in my root build.gradle I have:

def groovyProjects() {
    subprojects.findAll() { project ->
        def dir = project.file('/src/main/groovy')
        def exists = dir.isDirectory()
        return exists
    }
}
  configure(groovyProjects()) { project ->
 apply plugin: 'groovy'
 apply plugin: 'eclipse'
 apply plugin: 'idea'
    archivesBaseName = "$group.$project.name"
   }

and in api/build.gradle I have

eclipse {
 project {
  name = archivesBaseName
 }
}

which works great. My JAR file and Eclipse project name are kept in sync this way. However to make it even DRYer I tried to move the eclipse stanza into the root build.gradle file so I wouldn’t have to repeat it over and over

configure(groovyProjects()) { project ->
 apply plugin: 'groovy'
 apply plugin: 'eclipse'
 apply plugin: 'idea'
           archivesBaseName = "$group.$project.name"
          eclipse {
           project {
                name = archivesBaseName
            }
        }
 }

but that resulted in error:

FAILURE: Build failed with an exception.
  * Where:
Build file 'X:\workspaces\test\build.gradle' line: 36
  * What went wrong:
A problem occurred evaluating root project 'test'.
> Could not find method call() for arguments [build_2dvjv1juj01i4g3c2o8l9tasns$_run_closure2_closure8_closure11@2d581156
] on project ':api'.
  * Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
  BUILD FAILED

Any ideas? I am using Gradle 1.0.

BTW Great job guys on an important milestone!

I guess the ‘project’ -> closure parameter collides with ‘eclipse { project { … } }’. Remove the former.

The Groovy project detection code could be shortened to something like ‘def groovyProjects = subProjects.findAll { file(“src/main/groovy”).directory }’.

Cool thanks I’ll give that a whirl.

It works. Thanks I didn’t even notice the naming collision. Duh!