On Tue, Sep 7, 2010 at 11:57 PM, Lars Heuer <[email protected]> wrote:
> Hi there, > > I tried to fold several projects into one multi-project, but I found > some obstacles. > > In one of my projects (call it A) I have: > > apply from: 'http://www.excample.org/shared/commons.gradle' > > and I converted it into: > > apply from: '../shared/commons.gradle' > Depending on your structure, an alternative would be: apply from: "$rootDir/shared/commons.gradle" > > which works. > > But in "shared/commons.gradle" I reference files which resist in the > same directory. > > I tried in commons.gradle: > > apply from: 'bla.gradle' > apply from: './bla.gradle' > > but each "apply from" is resolved against the location of A since I > always get the error: > > Could not read script: <LOCATION-OF-A>/bla.gradle > > Why is the the path of "bla.gradle" not resolved relative to > "commons.gradle"? > The current logic is: commons.gradle is a plugin which is evaluated in the context of the calling project. You could do: println projectDir in commons.gradle and it would print <LOCATION-OF-A>. Relative paths are resolved against the project dir. I see that for your scenario (nested composition) this is confusing. But for more plugin like scenarios this it what you want. For example an added task by the plugin that gets configured with relative paths. > And how do I convince commons.gradle to resolve "bla.gradle" relative > to the position of "commons.gradle"? > apply from: "$buildscript.sourceFile.parentFile/bla.gradle" // BTW: There is also buildscript.sourceURI apply from: "$rootDir/shared/bla.gradle" // Not sure if this works for your layout. - Hans -- Hans Dockter Founder, Gradle http://www.gradle.org, http://twitter.com/gradleorg CEO, Gradle Inc. - Gradle Training, Support, Consulting http://www.gradle.biz
