On 01/08/2011, at 4:35 AM, Hani Suleiman wrote:

> 
> On Jul 29, 2011, at 12:17 AM, Adam Murdoch wrote:
> 
>> 
>> On 29/07/2011, at 12:46 PM, Hani Suleiman wrote:
>> 
>>> Pretty much any of the solutions below would address the issue!
>>> 
>>> In my case, I'm doing it manually until the .idea directory support is in. 
>>> Even when that's done, there are still configuration elements that the idea 
>>> plugin doesn't really handle (for example, the 'provided' dependencies), 
>>> exclusions, etc.
>> 
>> The idea plugin can handle both of those things (assuming by 'exclusions' 
>> you mean excluded folders). You do have to do a little bit of configuration 
>> in the build script to make this work.
>> 
>> Something you can do as a workaround, is add a task to copy the project's 
>> dependencies into a directory somewhere under the project directory, and 
>> point your ide at that directory (or individual files in that directory):
>> 
>> task ideLibs(type: Sync) {
>>    from configurations.testRuntime
>>    into 'ide/libs'
>> }
> 
> I'm trying to do this but without much success. Right now I can get a list of 
> ExternalModuleDependency objects via 
> configuration.getAllDependencies(ExternalModuleDependency.class). I'm having 
> trouble going from that to jar files, and even once that's done, how would I 
> get the equivalent source files?

There's no good way to get the source files at the moment.

One option might be to use the idea plugin to build all the dependency 
information for you, but not actually generate the ide files. For 
1.0-milestone-4, you'd do something like:

apply plugin: 'idea'

task ideLibs {
    doLast {
        idea.module.resolveDependencies().findAll { it instanceof 
SingleEntryModuleLibrary }.each { lib ->
            copy { from it.libraryFile; into 
"ide/libs/jars/${it.scope.toLowerCase()}" }
            if ( it.sourceFile ) { 
                copy { from it.sourceFile; into 
"ide/libs/source/${it.scope.toLowerCase()}" }
            }
        }
    }
}

So, you'll end up with ide/libs/jars/compile containing the jars and 
ide/libs/source/compile containing the associated source files. I wonder if it 
might be useful for the idea and eclipse plugins to always use this kind of 
layout, rather than pointing back into the cache.

Note that this example does use resolveDependencies(), which is an internal 
method. This may change in the future.

--
Adam Murdoch
Gradle Co-founder
http://www.gradle.org
VP of Engineering, Gradleware Inc. - Gradle Training, Support, Consulting
http://www.gradleware.com

Reply via email to