Issues using Copy task from a cached artifact

I have been reading:

I have a similar problem. In my case, I’m pulling the Flex ZIP from Artifactory. The problem is that the Copy task says it’s always UP-TO_DATE, and the copy and unzip never happens. Using the project.copy closure works fine.

I’m wondering, what’s going on here?

apply plugin: 'base'
   configurations {
   repositories {
    maven { url '' }
      dependencies {
    flexsdk 'com.adobe:flex_sdk:'
   task copystuff( ) << {
                   def target = file("$buildDir/flex_sdk")
                                 if( !target.exists() ) {
                                copy {
                                                                   from zipTree( configurations.flexsdk.singleFile )
                                                into target
   task setupSDK( type: Copy ) << {
                def target = file("$buildDir/flex_download")
                onlyIf{ !target.exists() }
                from zipTree( configurations.flexsdk.singlefile )
                into target
   task debug( ) << {
                                 configurations.flexsdk.each {
                                println it

Running the “copystuff” task works as expected, and a “flex_sdk” dir is created with the unzipped files.

Running the “setupSDK” tasks does nothing:

Tasks to be executed: [task ':setupSDK']
Skipping task ':setupSDK' as it has no source files.

As a sanity check, running the “debug” task produces:


I’m guessing that the copy task can’t copy from a cached artifact? Is this a bug or a mistake in the build?



The build script makes a common mistake: it configures the ‘setupSDK’ task in the execution phase, rather than in the configuration phase. You’ll have to remove the <<.

Great! It’s now working, thanks so much for the help.