Why can't I run the examples with multiple project() definitions?


(Jonas Printzén) #1

I am on a fast-track to learning groovy and gradle, since we are attempting to implement this at work. When I run the examples in gradle user guide I hit the wall with “Example 15.6. Accessing tasks by path”- --------8<----------------8<----------------8<----------------8<----------------8<---------------- A problem occurred evaluating root project ‘groovy’. > Project with path ‘:projectA’ could not be found in root project ‘groovy’. --------8<----------------8<----------------8<----------------8<----------------8<----------------

My setup:

Gradle 1.2 ------------------------------------------------------------

Gradle build time: den 12 september 2012 kl 10:46 UTC Groovy: 1.8.6 Ant: Apache Ant™ version 1.8.4 compiled on May 22 2012 Ivy: 2.2.0 JVM: 1.6.0_37 (Sun Microsystems Inc. 20.12-b01) OS: Linux 2.6.32-279.5.2.el6.x86_64 amd64

… switching to gradle 1.3 does not change anything for me.


(Luke Daley) #2

How are you executing this? Are you physically in the ‘samples/userguide/tasks/accessUsingPath/’ directory?

I don’t know where the “groovy” project would be coming from.


(Jon Austen) #3

Sometimes, people declare the root project name like so, in their settings.gradle , such as the Gradle project does in the GitHub archive :

rootProject.name = 'gradle'

I implemented this type of thing in my multi-project build at:

And so, that looks like this, in my settings.gradle (different than the example you refer to in the cookbook : http://gradle.codehaus.org/Cookbook#Cookbook-howtoruntestsfromaJARlibrary ) :

include 'core'
include 'google'
include 'bing'
  // this sets the customized build file name for each subproject
rootProject.name = 'gradle'
rootProject.children.each {project ->
    String fileBaseName = project.name.replaceAll("\p{Upper}") { "-${it.toLowerCase()}" }
    String projectDirName = "subprojects/$fileBaseName"
    project.projectDir = new File(settingsDir, projectDirName)
    project.buildFileName = "${fileBaseName}.gradle"
    assert project.projectDir.isDirectory()
    assert project.buildFile.isFile()
}

I stole this method from the Gradle project (in GitHub) and I have to say it works nicely. Much better than what is documented in the documentation (IMHO).


(Peter Niederwieser) #4

Wrong thread?


(Jonas Printzén) #5

I just followed instructions for installing gradle, then followed the text in the tutorial. However I wrote the differnt variants of build.gradle directly into an empty folder (my playground subtree)

I had a suggestion from someone that I should add a settings.gradle with

--------8<--------8<--------8<--------8<-------- include ‘projectA’ --------8<--------8<--------8<--------8<--------

… and this actually worked(?!!) Since I read this to learn gradle I’m not yet able to justify that as a ‘correct’ solution. I can’t find clues in the text either. To me this would have been alright in any other case, except

the authoritative tutorial! I would say the explanations is not complete from a learning perspective.

But perhaps I just missed the all inclusive description somewhere??


(Jonas Printzén) #6

hmm. ugly text-filtering in

----8t should be

-------------------------------- include ‘projectA’ --------------------------------