VFS Plugin - 1.0-beta-3 is now out

Finally got around to make the third 1.0 pre-release of the groovy-vfs-plugin available

Probably the most significant in this pre-release is the VfsCopy task and the baility to use Ant-style patterns in a similar fashion to that of the Copy task.

task download( type : org,ysb33r.gradle.vfs.tasks.VfsCopy ) {
  from  'sftp://user:pass@server/folder', {
         include 'file.txt'
         include '**/*.jpg'
         exclude '**/foo*.jpg'
  }
}

Due to updates from the underlying Groovy-VFS library the project.vfs extension can now manipulate content on remote systems i.e.

vfs {
      
      overwrite 'sftp://user:pass@server/file' with
          'this text'

        append 'sftp://user:pass@server/file' with 'this text'

        overwrite 'sftp://user:pass@server/file' with 'this text', {
            // Closure takes an OutputStream
            it << 'text'
        }
}
```

`smb` and `s3` schemes can be used if the appropriate provider JARs are placed in `buildscript.dependencies.classpath`
     
Please feel free to log bugs at https://github.com/ysb33r/groovy-vfs


    


        https://github.com/ysb33r/groovy-vfs/issues

This is cool stuff. It was always our goal to consolidate local and remote file operations. Do you have any avoidance mechanisms when things have been already copied?

It will be there in the final release. Not sure yet exactly what I’ll do, but in the past before writing VfsCopy I used to do something like:

task download << {
    mkdir downloadDir
    vfs {
        if(!revealjsDir.exists()) {
            cp "zip:https://github.com/hakimel/reveal.js/archive/${revealjsVersion}.zip!reveal.js-${revealjsVersion}",
                    revealjsDir, recursive: true, overwrite: true
        }
        if(!revealjsTemplateDir.exists()) {
            cp "zip:https://github.com/asciidoctor/asciidoctor-reveal.js/archive/${revealjsTemplateVersion}.zip!asciidoctor-reveal.js-${revealjsTemplateVersion}/templates/slim",
                    revealjsTemplateDir, recursive: true, overwrite: true
        }

    }

}

download {
    outputs.dir revealjsDir
    outputs.dir revealjsTemplateDir
}

That was functional, but not ideal as it did no check whether the source was newer than the destination.

With some remote system this will be hard to check. Some cases it might be possible to at least check for the modified time, but checksum comparisons are not currently available in the underlying Apache VFS. Theoretically this should be possible though as I know that some HTTP server do have that functionality.

Can the username/password be passed in as a property instead of embedded in the url?

Currently you will need to do ftp://{project.properties.user}:${project.properties.pass}@server/path. I am yet to implement a nice way to pass credentials to a URL.

It is there now in the 1.0-beta5 release.

A copy will only occur under the following circumstances

  • A source file is missing from the the destination hierarchy
  • If both source and destination schemes support modification date checks and the source file is neweer then the destination file. (timestamp checks are not done on folders)

Also if --offline is used all instances of VfsCopy tasks are disabled.

The isUptoDate() task method is overloaded to check source vs destination.
I am pretty happy with the same of this task as it is now.