Success!

I did have to specify the settings file and project directory regardless of
where I executed from, however.

>From the root Project directory, without specifying the project it couldn't
set the default project.  From the ProjectBuild directory, without
specifying the settings file, it had a problem recognizing the plugins I
declare in the settings and use in the projects.  

The only problem I had in putting those lines in is that I had to change
rootProject.buildDirName to rootProject.buildFileName because the
buildDirName property couldn't be resolved.

Thanks a lot for your help.  This is a big feature that many people I work
with have asked me about since having loose files at the root of a cvs
repository causes problems.

Thanks again,
Jerod


Adam Murdoch-2 wrote:
> 
> 
> 
> JerodLass wrote:
>> After an issue refreshed my need for build hierarchy control, I'm back to
>> trying to build my multi-project without a physical top-level build. 
>> Again,
>> to clean up cvs (among other benefits), I would like to modify my project
>> structure
>>
>> From:
>>  -D Project
>>    -D SubProject1
>>       -F build.gradle
>>    -D SubProject2
>>       -F build.gradle
>>    -F build.gradle
>>    -F settings.gradle
>> to:
>>  -D Project
>>    -D SubProject1
>>       -F build.gradle
>>    -D SubProject2
>>       -F build.gradle
>>    -D ProjectBuild
>>       -F build.gradle (this is virtually the top-level script which
>> defines
>> a lot of behavior for subprojects)
>>       -F settings.gradle
>>
>> Without affecting the build, which has been running well.  If someone
>> knows
>> exactly how to do this then read no further, but here is a list of my
>> settings.gradle attempts and which problems they caused:
>>
>>   
> 
> One of our integration tests has exactly this structure, so it does 
> work. You need to do:
> 
> includeFlat 'SubProject1', 'SubProject2'
> rootProject.projectDir = new File(settingsDir, '..')
> rootProject.buildDirName = 'ProjectBuild/build.gradle'
> 
> Here's what this does, and why:
> 
> We use 'includeFlat', rather than 'include', because this sets the 
> project directory of the included subproject to 
> '$settingsDir/../$projectName', ie 'Project/SubProject1'. Using 
> 'include' would set the project directory to 
> '$settingsDir/$projectName', ie 'Project/ProjectBuild/SubProject1'.
> 
> Secondly, we set the project dir of the root project to 
> '$settingsDir/..', ie 'Project', as that is what the subprojects are 
> expecting it to be set to. An alternative approach, which would be more 
> layout agnostic, is to have the root project inject this information 
> into the subprojects, rather than have the subproject pulling it out of 
> the root project.
> 
> Finally, we set the buildDirName of the root project to point it to the 
> correct build file. This is because the default is to look for 
> 'build.gradle' in the project's project dir, ie the default would be 
> 'Project/build.gradle', rather than 'Project/ProjectBuild/build.gradle'
> 
> The command-line usage for this kind of layout is a bit awkward:
> 
> If you run it from the root directory, or one of the subproject 
> directories, you have to use the -c option to tell Gradle where the 
> settings file is.
> 
> If you run it from the ProjectBuild directory, Gradle will find the 
> settings file fine, but you will have to use the -p option to tell 
> Gradle which project you want to run against. This is because there are 
> no projects in your build with the ProjectBuild directory as their 
> project dir. Perhaps we should change Gradle to use the root project in 
> this instance.
> 
> 
>> Attempt #1:
>>
>> include 'Project1', 'Project2'
>>
>> mavenRepo(name: 'LocalRepo', urls: 'http://localserv/maven-repo/')
>> dependencies("org.jerod.GradlePlugins:MyRootPlugin:1.7")
>> dependencies("org.jerod.GradlePlugins:MyProjectPlugin:1.7")
>>
>> Output #1:
>>
>> plugins found, projects initialized but no directories/build files found
>> so
>> its an empty but error-free build
>>
>> Attempt #2:
>>
>> includeFlat 'Project1', 'Project2'
>>
>> mavenRepo(name: 'LocalRepo', urls: 'http://localserv/maven-repo/')
>> dependencies("org.jerod.GradlePlugins:MyRootPlugin:1.7")
>> dependencies("org.jerod.GradlePlugins:MyProjectPlugin:1.7")
>>
>> Output #2:
>>
>> plugins found, projects initialized, errors because other projects
>> reference
>> rootproject paths which are now different
>>
>> Attempt #3[#4]:
>>
>> rootProject.projectDir = new File(settingsDir, '..')
>>
>> include[includeFlat] 'Project1', 'Project2'
>>
>> mavenRepo(name: 'LocalRepo', urls: 'http://localserv/maven-repo/')
>> dependencies("org.jerod.GradlePlugins:MyRootPlugin:1.7")
>> dependencies("org.jerod.GradlePlugins:MyProjectPlugin:1.7")
>>
>> Output #3[#4]:
>>
>> Plugin not found, no class def found on
>> org.jerod.GradlePlugins.MyRootPlugin
>> declaration, projects not added
>>
>> When I run configuration 3/4 while specifying the settings file (-c
>> settings.gradle) I get an error that it can't select the default project
>>
>> Attempt #5:
>>
>> rootProject.projectDir = new File(settingsDir, '..')
>>
>> include 'Project1', 'Project2', 'ProjectBuild'
>>
>> mavenRepo(name: 'LocalRepo', urls: 'http://localserv/maven-repo/')
>> dependencies("org.jerod.GradlePlugins:MyRootPlugin:1.7")
>> dependencies("org.jerod.GradlePlugins:MyProjectPlugin:1.7")
>>
>> Output #5:
>>
>> Plugins found, includes all proojects, appears to find all build files,
>> but
>> doesn't run any tasks for subprojects (no errors, though).  Is it
>> possible
>> that with ProjectBuild added as a separate project and being halfway
>> between
>> a root and subproject, the real subprojects are no longer downstream from
>> ProjectBuild so dependsOnChildren() doesn't have the same effect?
>>
>> Attempt #6:
>>
>> rootProject.projectDir = new File(settingsDir, '..')
>> rootProject.buildFileName = 'loggerBuild/build.gradle'
>>
>> include 'Project1', 'Project2', 'ProjectBuild'
>>
>> mavenRepo(name: 'LocalRepo', urls: 'http://localserv/maven-repo/')
>> dependencies("org.jerod.GradlePlugins:MyRootPlugin:1.7")
>> dependencies("org.jerod.GradlePlugins:MyProjectPlugin:1.7")
>>
>> Output #6:
>>
>> Plugins found, projects recognized, but errors when ProjectBuild is seen
>> as
>> the root project and a subproject and thus gets two different task
>> definitions thanks to the two declared plugins
>>
>>
>> If you made it this far, I applaud you.  I'm desperate for any help.
>>
>> Thank you,
>> Jerod Lass
>>   
> 
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
> 
>     http://xircles.codehaus.org/manage_email
> 
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Arbitrary-structure-for-multi-project-builds-progress-tp24206327p24222699.html
Sent from the gradle-user mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply via email to