Issues using Copy task from a cached artifact


(Tim Goeke) #1

I have been reading:

http://forums.gradle.org/gradle/topics/cant_extract_tar_gz_defined_as_a_dependency

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 {
    flexsdk
}
   repositories {
    maven { url 'http://10.7.85.37:8081/artifactory/repo' }
}
      dependencies {
    flexsdk 'com.adobe:flex_sdk:4.6.0.23201B'
}
   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']
:setupSDK
Skipping task ':setupSDK' as it has no source files.
:setupSDK UP-TO-DATE

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

:debug
/Users/goeket/.gradle/caches/artifacts-14/filestore/com.adobe/flex_sdk/4.6.0.23201B/zip/7e66e84bef09e8c2c3183acf548c41d8114516ca/flex_sdk-4.6.0.23201B.zip

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

Sincerely,

TimG


(Peter Niederwieser) #2

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 <<.


(Tim Goeke) #3

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

TimG