modified version that downloads the transitive sources as well.  not sure if
this is the best way, but hopefully this helps others encountering the same
problem

- rob


configurations {
        compile {
                transitive = true;
        }

        sources
}

task sourcesConfig {
        description = "find all dependencies and place them into sources
configuration"
        def first =
configurations.runtime.resolvedConfiguration.firstLevelModuleDependencies
        def counter = 0;
        def dependz = []
        
        def findDependz
        // recursive closure
        findDependz = { params ->
                counter++;
                params.each { module ->
                        //println "" + counter +
"$module.moduleGroup:$module.moduleName:$module.moduleVersion"
                
if(!dependz.contains("$module.moduleGroup:$module.moduleName:$module.moduleVersion"))
{
                        
dependz.add("$module.moduleGroup:$module.moduleName:$module.moduleVersion");
                        }
                        findDependz(module.children)
                }
                counter--
                
        }
        
        findDependz(first)

        // build sources configuration
        dependz.each { d ->
        
                // ignore following jars that don't have source in maven
                if(d.contains("mysql") || d.contains("jersey") || 
d.contains("asm"))
                        return
                dependencies {
                        // copy into source config
                        sources "" + d
                }
        }
}

task src(depeondsOn: sourcesConfig, type: Copy) {
        description = "download source jars from maven repositories"
    from {
        // Copy the compile configuration and replace the main artifact with
the source artifact for each dep
        def conf = configurations.sources.copyRecursive { it instanceof
ExternalModuleDependency }
        conf.dependencies.each { dep ->         
            dep.artifact {
                group = dep.group
                name = dep.name
                version = dep.version
                classifier = 'sources'
                type = 'jar'
            }
        }
        conf
    }
    into 'sources'
    // Add this to clean the target dir first. For Gradle 0.9, you'd use the
Sync task instead
    doFirst {
        ant.delete(dir: destinationDir)
    }
}

-- 
View this message in context: 
http://old.nabble.com/Downloading-*-sources-tp26529227p28688569.html
Sent from the gradle-user mailing list archive at Nabble.com.

Reply via email to