Problem with copy from zipTree in 1.8 and 1.9

I have issues with copying specific files from a zip/jar file. Have attached a simplified example.

The following build.gradle fails with: Execution failed for task ‘:testUnzip’. > Neither path nor baseDir may be null or empty string. path=‘null’ basedir=‘C:\dev\workspace_dev\test-gradle’

This works in 1.7 but fails in 1.8 and 1.9. Have tried to figure out if anything has changed in the apis. Are there any other way of copy specific files from a zip/jar file?

apply plugin: 'java'
  task sourcesJar(type: Jar, dependsOn: classes) {
    classifier = 'sources'
    from sourceSets.main.allSource
}
  artifacts {
    archives sourcesJar
}
    task testUnzip(dependsOn: sourcesJar) << {
    File dir = project.mkdir(project.buildDir.absolutePath + '/src-unzip')
    project.delete(project.fileTree(dir: dir, include: '**/*'))
        project.copy {from project.zipTree(tasks.sourcesJar.archivePath) into dir include '**/*.java'}
}

It’s somehow an aspect of you condensing the copy to one line. This works for me:

apply plugin: 'java'
  task sourcesJar(type: Jar, dependsOn: classes) {
    classifier = 'sources'
    from sourceSets.main.allSource
}
  artifacts {
    archives sourcesJar
}
  task testUnzip(dependsOn: sourcesJar) << {
    File dir = project.mkdir(project.buildDir.absolutePath + '/src-unzip')
    project.delete(project.fileTree(dir: dir, include: '**/*'))
        project.copy {
      from project.zipTree(tasks.sourcesJar.archivePath)
       into dir
       include '**/*.java'
    }
}

BTW, the idiomatic way to do this would be:

apply plugin: 'java'
  task sourcesJar(type: Jar, dependsOn: classes) {
    classifier = 'sources'
    from sourceSets.main.allSource
}
  artifacts {
    archives sourcesJar
}
  task testUnzip(type: Sync, dependsOn: sourcesJar) {
  from project.zipTree(sourcesJar.archivePath)
   into "$buildDir/src-unzip"
  include '**/*.java'
}

Thanks. This solved my problem. I was sure there was a better way of doing it. Thanks for pointing that out.