1. why not using configurations.runtime.files( spec ) to get the external
artifacts?
2. the taskGraph/subprojects iteration I cannot comment without testing
first. There might be a better way.

Cheers!

On Tue, Jan 3, 2012 at 7:17 PM, Luke Daley <[email protected]>wrote:

> Say you wanted to create a zip of all external (i.e. not project
> dependencies) runtime dependencies, how would you do it?
>
> This is pretty awkward. This is the best I can come up with:
>
> task zipDeps(type: Zip) { task ->
>     gradle.taskGraph.whenReady { taskGraph ->
>         if (taskGraph.hasTask(':zipDeps')) {
>             def projectNames = rootProject.subprojects*.name
>             def artifacts = new HashSet()
>             subprojects.each { subproject ->
>                 
> subproject.configurations.runtime.resolvedConfiguration.resolvedArtifacts.each
>  { artifact ->
>                     def dependency = artifact.moduleVersion.id
>                     if (!projectNames.contains(dependency.name)) {
>                         artifacts << artifact.file
>                     }
>                 }
>             }
>
>             task.from artifacts
>         }
>     }
> }
>
> Am I missing something?
>
> Luke Daley
> Principal Engineer, Gradleware
> http://gradleware.com
>



-- 
Szczepan Faber
Principal engineer@gradleware
Lead@mockito

Reply via email to