# Right way to copy contents from dependency archives?

**URL:** https://discuss.gradle.org/t/right-way-to-copy-contents-from-dependency-archives/7449
**Category:** Old Forum Archive
**Created:** [April 12, 2012, 1:37pm UTC](https://discuss.gradle.org/t/right-way-to-copy-contents-from-dependency-archives/7449 "2012-04-12T13:37:00Z")
**Posts on this page:** 1
**Showing post:** 13

<div class="post-metadata">

### Author: ![Peter\_Niederwieser](https://avatars.discourse-cdn.com/v4/letter/p/9f8e36/32.png) [@Peter\_Niederwieser](https://discuss.gradle.org/u/Peter_Niederwieser)
#### Post date: [April 12, 2012, 5:06pm UTC](https://discuss.gradle.org/t/right-way-to-copy-contents-from-dependency-archives/7449/13 "2012-04-12T17:06:00Z")

</div>

An idiomatic solution would look like this:

```gradle
configurations {
    api
}
  dependencies {
    api 'somegroup:someArtifact:someVersion'
}
  task extractApi(type: Sync) {
    dependsOn configurations.api

    from { // use of closure defers evaluation until execution time
        configurations.api.collect { zipTree(it) }
    }
    into "$buildDir/api/"
}

```

---

_[View the full topic](https://discuss.gradle.org/t/right-way-to-copy-contents-from-dependency-archives/7449)._
