Copy task with CopySpec not working in 1.0-milestone-6


(paulk) #1

The build file below creates a zip with four artifacts in milestone 5 but only two in milestone 6. I don’t know whether we were using an unsupported feature previously or whether a regression has occurred. I didn’t spot anything in my quick perusal of the release notes that suggested things had changed in this area.

apply plugin: 'java'
  prodZipSpec = copySpec {
    into("base") {
        into("config") { from("${buildDir}/tmp/config") }
    }
}
  task zipProd(type: Zip, dependsOn: 'createResources') {
    baseName = 'prod'
    from prodZipSpec
    into("base/lib") { from("${buildDir}/tmp/lib") }
}
  task createResources {
    ant.with {
        touch(file: "${buildDir}/tmp/config/config1", mkdirs: true)
        touch(file: "${buildDir}/tmp/config/config2", mkdirs: true)
        touch(file: "${buildDir}/tmp/lib/lib1", mkdirs: true)
        touch(file: "${buildDir}/tmp/lib/lib2", mkdirs: true)
    }
}
  task wrapper(type: Wrapper) {
    gradleVersion = '1.0-milestone-6'
    distributionUrl = "http://nexus.int.corp.sun/content/repositories/gradle/gradle-${gradleVersion}-bin.zip"
}

(Adam Murdoch) #2

It’s a regression, of sorts. The supported way to use a CopySpec is using the with() method:

task zipProd(type: Zip) {
    with prodZipSpec
    ....
}

Looks like we broke from(CopySpec) in milestone 6. Could you add a JIRA issue for this?