Interesting. So it's because of using doFirst() instead of doLast()?

On Sat, Jan 14, 2012 at 5:12 PM, Luke Daley <luke.da...@gradleware.com>wrote:

> I would have expected this to work:
>
> apply plugin: "java"
>
> repositories {
> mavenCentral()
> }
>
> dependencies {
> compile 'junit:junit:4.9'
> }
>
> task doIt {
> dependsOn configurations.compile
> doFirst {
> assert configurations.compile.state == Configuration.State.RESOLVED
> }
> }
>
> Instead it fails because the configuration is not resolved when the task
> executes.
>
> Using dependsOn configurations.compile.buildDependencies does not work
> either, same problem.
>
> I also tried dependsOn configurations.compile.files, which does trigger a
> resolve but then explodes because it tries to find a task with a name
> matching the absolute path of each dependency file.
>
> I stumbled upon this when answering a forum question that lead to me
> writing and trying the following:
>
> task unpack(type: Copy, dependsOn: configurations.compile) { task ->
> into "sdks"
> assert configurations.compile.state == Configuration.State.UNRESOLVED
> configurations.compile.incoming.afterResolve { ResolvableDependencies
> incoming ->
> incoming.files.each { File file ->
> if (file.name.endsWith(".zip")) {
> from (zipTree(file)) {
> into file.name - ".zip"
> }
> }
> }
> }
> }
>
> (I also discovered http://issues.gradle.org/browse/GRADLE-2047 in the
> process which is now fixed.)
>
> Luke Daley
> Principal Engineer, Gradleware
> http://gradleware.com
>



-- 
Szczepan Faber
Principal engineer@gradleware
Lead@mockito

Reply via email to