SlideShare a Scribd company logo
1 of 25
Download to read offline
© Schalk W. Cronjé Greach 2014
Groovy VFS
Schalk W. Cronjé
@ysb33r
© Schalk W. Cronjé Greach 2014
Quickstart
def vfs = new VFS()
vfs {
cp “http://from.here/a.txt”, “sftp://to.there/b.txt”
}
© Schalk W. Cronjé Greach 2014
Groovy VFS
Current version: 0.5
Source: http://github.com/ysb33r/groovy-vfs
Wiki: https://github.com/ysb33r/groovy-vfs/wiki
Packages: https://bintray.com/ysb33r/grysb33r/groovy-vfs
Gradle Packages: https://bintray.com/ysb33r/grysb33r/vfs-gradle-plugin
License: Apache 2.0
Twitter: #groovyvfs
© Schalk W. Cronjé Greach 2014
Bootstrap
@Grapes([
@Grab( 'org.ysb33r.groovy:groovy-vfs:0.5' ),
// If you wantftp
@Grab( 'commons-net:commons-net:3.+' ),
// If you want http/https
@Grab( 'commons-httpclient:commons-httpclient:3.1'),
// If you want sftp
@Grab( 'com.jcraft:jsch:0.1.48' )
])
import org.ysb33r.groovy.dsl.vfs.VFS
© Schalk W. Cronjé Greach 2014
Create directory on remote server
vfs {
mkdir “ftp://a.server/pub/ysb33r”
}
© Schalk W. Cronjé Greach 2014
Directory Listing
vfs {
ls (“ftp://www.mirrorservice.org/sites”) {
println it.name
}
}
© Schalk W. Cronjé Greach 2014
Set Schema Options
vfs {
options {
ftp {
passiveMode true
userDirIsRoot false
}
}
}
© Schalk W. Cronjé Greach 2014
Modify Schema Option per Request
vfs {
ls (“ftp://www.mirrorservice.org/sites?vfs.ftp.passiveMode=1”) {
println it.name
}
}
220 Service ready for new user.
USER guest
331 User name okay, need password for guest.
PASS guest
230 User logged in, proceed.
TYPE I
200 Command TYPE okay.
CWD /
250 Directory changed to /
SYST
215 UNIX Type: Apache FtpServer
PASV
227 Entering Passive Mode (127,0,0,1,226,247)
LIST
150 File status okay; about to open data connection.
226 Closing data connection.
© Schalk W. Cronjé Greach 2014
Set Schema Options at Initialisation
def vfs = new VFS (
'vfs.ftp.passiveMode' : true,
'vfs.http.maxTotalConnections' : 4
)
© Schalk W. Cronjé Greach 2014
Schema Options
- Most Apache VFS filesystem options supported
- Follows Groovy property-over-setter/getter convention
Documentation:
https://github.com/ysb33r/groovy-vfs/wiki/Protocol-Options
© Schalk W. Cronjé Greach 2014
Copying & Moving
vfs {
cp “http://a.server/myFile.txt”,
“file:///home/scronje/MyFile.downloaded.txt”
mv “ftp://that.server/myFile.txt”,
“sftp://this.server/in-this-folder&vfs.sftp.userDirIsRoot=
}
© Schalk W. Cronjé Greach 2014
Copy DSL
vfs {
cp from_url,
to_url,
overwrite : false,
smash : false,
recursive : false,
filter : defaults_to_selecting_everything
}
Documentation:
https://github.com/ysb33r/groovy-vfs/wiki/VFS-Copy-Behaviour
© Schalk W. Cronjé Greach 2014
Interactive Copy
vfs {
cp from_url,
to_url,
overwrite : { from,to ->
println “Overwrite ${to}?”
System.in.readLine().startsWith('Y')
}
}
© Schalk W. Cronjé Greach 2014
Move DSL
vfs {
mv from_url,
to_url,
overwrite : false,
smash : false,
intermediates : true,
}
Documentation:
https://github.com/ysb33r/groovy-vfs/wiki/VFS-Move-Behaviour
© Schalk W. Cronjé Greach 2014
Download & Unpack
vfs {
cp “zip:ftp://a.server/with-archive.zip”,
“file:///home/scronje/unpacked”
}
Warning:
Large archives will cause slow-down due to performance bug in Apache VFS
© Schalk W. Cronjé Greach 2014
Working with Content
import java.security.MessageDigest
vfs {
MessageDigest md5 = MessageDigest.getInstance("MD5")
cat (“ftp://a.server/my-file.txt”) { strm →
strm.eachByte(8192) { buffer, nbytes ->
md5.update( buffer, 0, nbytes )
}
}
println md5.digest().encodeHex().toString()
.padLeft( 32, '0' )
} // From a conversation on groovy-user ML
© Schalk W. Cronjé Greach 2014
Local Files
- Prefix with 'file://'
- Use java.io.File instance
- Use org.apache.commons.vfs2.FileObject instance
vfs {
cp new File(“a.txt”), “ftp://to.server/pub”
}
© Schalk W. Cronjé Greach 2014
Authentication
vfs {
// clear password
cp new File(“a.txt”),
“ftp://${username}:${password}@to.server/pub”
// password encrypted with org.apache.commons.vfs2.util.EncryptUtil
cp new File('b.txt'),
'ftp://testuser:{D7B82198B272F5C93790FEB38A73C7B8}@to.server/pub'
}
Warning: User with caution (security …)
Enhancement: ISSUE-17 to provide better authentication DSL support
© Schalk W. Cronjé Greach 2014
Future Ideas For Investigation
●
Java 7 NIO
– java.nio.file.*
– Wait for Apache VFS or go native Groovy?
●
Direct SMB support?
– Apache VFS Sandbox
– jCIFS license is LGPL
© Schalk W. Cronjé Greach 2014
VFS Gradle Plugin
(experimental / incubating)
© Schalk W. Cronjé Greach 2014
Bootstrap
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'org.ysb33r.gradle:vfs-gradle-plugin:0.5'
classpath 'commons-net:commons-net:3.+' // ftp
classpath 'commons-httpclient:commons-httpclient:3.1' // http/https
classpath 'com.jcraft:jsch:0.1.48' // sftp
}
}
apply plugin : 'vfs'
© Schalk W. Cronjé Greach 2014
Available as Project Extension
task ftpCopy << {
vfs {
cp “ftp://a.server/file.txt”, buildDir
}
}
© Schalk W. Cronjé Greach 2014
Future Ideas For Investigation
●
vfsTree
– Akin toproject.tarTree
– Is it even possible to createFileTree?
●
Vfs Copy / Move Task
– How to define @Input etc. correctly
© Schalk W. Cronjé Greach 2014
Other Plugins ?
●
Grails & Griffon
– No plugin (yet)
●
Jenkins
– Time to consolidate various protocol
plugins
Who wants to write one?
© Schalk W. Cronjé Greach 2014
Groovy VFS
#groovyvfs
Schalk W. Cronjé
@ysb33r
http://github.com/ysb33r/groovy-vfs

More Related Content

What's hot

Ansible as a better shell script
Ansible as a better shell scriptAnsible as a better shell script
Ansible as a better shell scriptTakuya Nishimoto
 
K8s上の containerized cloud foundryとcontainerized open stackをprometheusで監視してみる
K8s上の containerized cloud foundryとcontainerized open stackをprometheusで監視してみるK8s上の containerized cloud foundryとcontainerized open stackをprometheusで監視してみる
K8s上の containerized cloud foundryとcontainerized open stackをprometheusで監視してみるJUNICHI YOSHISE
 
FreeBSD Document Project
FreeBSD Document ProjectFreeBSD Document Project
FreeBSD Document ProjectChinsan Huang
 
Automating Mendix application deployments with Nix
Automating Mendix application deployments with NixAutomating Mendix application deployments with Nix
Automating Mendix application deployments with NixSander van der Burg
 
[2019.03] 멀티 노드에서 Hyperledger Fabric 네트워크 구성하기
[2019.03] 멀티 노드에서 Hyperledger Fabric 네트워크 구성하기[2019.03] 멀티 노드에서 Hyperledger Fabric 네트워크 구성하기
[2019.03] 멀티 노드에서 Hyperledger Fabric 네트워크 구성하기Hyperledger Korea User Group
 
Смарт-контракты: базовые инструменты для разработки и тестирования. Спикер: Д...
Смарт-контракты: базовые инструменты для разработки и тестирования. Спикер: Д...Смарт-контракты: базовые инструменты для разработки и тестирования. Спикер: Д...
Смарт-контракты: базовые инструменты для разработки и тестирования. Спикер: Д...Cyber Fund
 
My journey from PHP to Node.js
My journey from PHP to Node.jsMy journey from PHP to Node.js
My journey from PHP to Node.jsValentin Lup
 
Frasco: Jekyll Starter Project
Frasco: Jekyll Starter ProjectFrasco: Jekyll Starter Project
Frasco: Jekyll Starter ProjectKite Koga
 
DevOps for Opensource Geospatial Applications
DevOps for Opensource Geospatial ApplicationsDevOps for Opensource Geospatial Applications
DevOps for Opensource Geospatial Applicationstlpinney
 
Hitchhikers guide to open stack toolchains
Hitchhikers guide to open stack toolchainsHitchhikers guide to open stack toolchains
Hitchhikers guide to open stack toolchainsstagr_lee
 
Inside Sqale's Backend at Sapporo Ruby Kaigi 2012
Inside Sqale's Backend at Sapporo Ruby Kaigi 2012Inside Sqale's Backend at Sapporo Ruby Kaigi 2012
Inside Sqale's Backend at Sapporo Ruby Kaigi 2012Gosuke Miyashita
 
Docker command
Docker commandDocker command
Docker commandEric Ahn
 
Docker deploy
Docker deployDocker deploy
Docker deployEric Ahn
 

What's hot (20)

Ansible as a better shell script
Ansible as a better shell scriptAnsible as a better shell script
Ansible as a better shell script
 
K8s上の containerized cloud foundryとcontainerized open stackをprometheusで監視してみる
K8s上の containerized cloud foundryとcontainerized open stackをprometheusで監視してみるK8s上の containerized cloud foundryとcontainerized open stackをprometheusで監視してみる
K8s上の containerized cloud foundryとcontainerized open stackをprometheusで監視してみる
 
HTTP/3 an early overview
HTTP/3 an early overviewHTTP/3 an early overview
HTTP/3 an early overview
 
DevStack
DevStackDevStack
DevStack
 
Just curl it!
Just curl it!Just curl it!
Just curl it!
 
FreeBSD Document Project
FreeBSD Document ProjectFreeBSD Document Project
FreeBSD Document Project
 
Automating Mendix application deployments with Nix
Automating Mendix application deployments with NixAutomating Mendix application deployments with Nix
Automating Mendix application deployments with Nix
 
DDEV - Extended
DDEV - ExtendedDDEV - Extended
DDEV - Extended
 
[2019.03] 멀티 노드에서 Hyperledger Fabric 네트워크 구성하기
[2019.03] 멀티 노드에서 Hyperledger Fabric 네트워크 구성하기[2019.03] 멀티 노드에서 Hyperledger Fabric 네트워크 구성하기
[2019.03] 멀티 노드에서 Hyperledger Fabric 네트워크 구성하기
 
Смарт-контракты: базовые инструменты для разработки и тестирования. Спикер: Д...
Смарт-контракты: базовые инструменты для разработки и тестирования. Спикер: Д...Смарт-контракты: базовые инструменты для разработки и тестирования. Спикер: Д...
Смарт-контракты: базовые инструменты для разработки и тестирования. Спикер: Д...
 
Vagrant
VagrantVagrant
Vagrant
 
My journey from PHP to Node.js
My journey from PHP to Node.jsMy journey from PHP to Node.js
My journey from PHP to Node.js
 
Frasco: Jekyll Starter Project
Frasco: Jekyll Starter ProjectFrasco: Jekyll Starter Project
Frasco: Jekyll Starter Project
 
DevOps for Opensource Geospatial Applications
DevOps for Opensource Geospatial ApplicationsDevOps for Opensource Geospatial Applications
DevOps for Opensource Geospatial Applications
 
Hyperledger Fabric v2.0: 새로운 기능
Hyperledger Fabric v2.0: 새로운 기능Hyperledger Fabric v2.0: 새로운 기능
Hyperledger Fabric v2.0: 새로운 기능
 
Hitchhikers guide to open stack toolchains
Hitchhikers guide to open stack toolchainsHitchhikers guide to open stack toolchains
Hitchhikers guide to open stack toolchains
 
Inside Sqale's Backend at Sapporo Ruby Kaigi 2012
Inside Sqale's Backend at Sapporo Ruby Kaigi 2012Inside Sqale's Backend at Sapporo Ruby Kaigi 2012
Inside Sqale's Backend at Sapporo Ruby Kaigi 2012
 
Docker practice
Docker practiceDocker practice
Docker practice
 
Docker command
Docker commandDocker command
Docker command
 
Docker deploy
Docker deployDocker deploy
Docker deploy
 

Similar to Groovy VFS: A DSL for working with remote files and protocols

Usando o Cloud
Usando o CloudUsando o Cloud
Usando o CloudFabio Kung
 
Control your deployments with Capistrano
Control your deployments with CapistranoControl your deployments with Capistrano
Control your deployments with CapistranoRamazan K
 
NAS Botnet Revealed - Mining Bitcoin
NAS Botnet Revealed - Mining Bitcoin NAS Botnet Revealed - Mining Bitcoin
NAS Botnet Revealed - Mining Bitcoin Davide Cioccia
 
2017-07-22 Common Workflow Language Viewer
2017-07-22 Common Workflow Language Viewer2017-07-22 Common Workflow Language Viewer
2017-07-22 Common Workflow Language ViewerStian Soiland-Reyes
 
Be ef presentation-securitybyte2011-michele_orru
Be ef presentation-securitybyte2011-michele_orruBe ef presentation-securitybyte2011-michele_orru
Be ef presentation-securitybyte2011-michele_orruMichele Orru
 
NetDevOps Developer Environments with Vagrant @ SCALE16x
NetDevOps Developer Environments with Vagrant @ SCALE16xNetDevOps Developer Environments with Vagrant @ SCALE16x
NetDevOps Developer Environments with Vagrant @ SCALE16xHank Preston
 
Automacao devops
Automacao devopsAutomacao devops
Automacao devopsFabio Kung
 
GroovyFX - Groove JavaFX
GroovyFX - Groove JavaFXGroovyFX - Groove JavaFX
GroovyFX - Groove JavaFXsascha_klein
 
Vagrant for real
Vagrant for realVagrant for real
Vagrant for realCodemotion
 
Vagrant for real (codemotion rome 2016)
Vagrant for real (codemotion rome 2016)Vagrant for real (codemotion rome 2016)
Vagrant for real (codemotion rome 2016)Michele Orselli
 
Flutter for Webで値を保存する
Flutter for Webで値を保存するFlutter for Webで値を保存する
Flutter for Webで値を保存するshinya sakemoto
 
Deploying WP Multisite to Heroku
Deploying WP Multisite to HerokuDeploying WP Multisite to Heroku
Deploying WP Multisite to HerokuJussi Kinnula
 
Hacktivity2011 be ef-preso_micheleorru
Hacktivity2011 be ef-preso_micheleorruHacktivity2011 be ef-preso_micheleorru
Hacktivity2011 be ef-preso_micheleorruMichele Orru
 
Security of Go Modules and Vulnerability Scanning in GoCenter and VSCode
Security of Go Modules and Vulnerability Scanning in GoCenter and VSCodeSecurity of Go Modules and Vulnerability Scanning in GoCenter and VSCode
Security of Go Modules and Vulnerability Scanning in GoCenter and VSCodeDeep Datta
 
Security of Go Modules and Vulnerability Scanning in VSCode
Security of Go Modules and Vulnerability Scanning in VSCodeSecurity of Go Modules and Vulnerability Scanning in VSCode
Security of Go Modules and Vulnerability Scanning in VSCodeDeep Datta
 
New Security of Go modules and vulnerability scanning in GoCenter
New Security of Go modules and vulnerability scanning in GoCenterNew Security of Go modules and vulnerability scanning in GoCenter
New Security of Go modules and vulnerability scanning in GoCenterDeep Datta
 
Let's go HTTPS-only! - More Than Buying a Certificate
Let's go HTTPS-only! - More Than Buying a CertificateLet's go HTTPS-only! - More Than Buying a Certificate
Let's go HTTPS-only! - More Than Buying a CertificateSteffen Gebert
 
Workshop MSF4J - Getting Started with Microservices and Java
Workshop MSF4J - Getting Started with Microservices and JavaWorkshop MSF4J - Getting Started with Microservices and Java
Workshop MSF4J - Getting Started with Microservices and JavaEdgar Silva
 

Similar to Groovy VFS: A DSL for working with remote files and protocols (20)

Usando o Cloud
Usando o CloudUsando o Cloud
Usando o Cloud
 
Control your deployments with Capistrano
Control your deployments with CapistranoControl your deployments with Capistrano
Control your deployments with Capistrano
 
NAS Botnet Revealed - Mining Bitcoin
NAS Botnet Revealed - Mining Bitcoin NAS Botnet Revealed - Mining Bitcoin
NAS Botnet Revealed - Mining Bitcoin
 
2017-07-22 Common Workflow Language Viewer
2017-07-22 Common Workflow Language Viewer2017-07-22 Common Workflow Language Viewer
2017-07-22 Common Workflow Language Viewer
 
Be ef presentation-securitybyte2011-michele_orru
Be ef presentation-securitybyte2011-michele_orruBe ef presentation-securitybyte2011-michele_orru
Be ef presentation-securitybyte2011-michele_orru
 
NetDevOps Developer Environments with Vagrant @ SCALE16x
NetDevOps Developer Environments with Vagrant @ SCALE16xNetDevOps Developer Environments with Vagrant @ SCALE16x
NetDevOps Developer Environments with Vagrant @ SCALE16x
 
Automacao devops
Automacao devopsAutomacao devops
Automacao devops
 
GroovyFX - Groove JavaFX
GroovyFX - Groove JavaFXGroovyFX - Groove JavaFX
GroovyFX - Groove JavaFX
 
Vagrant for real
Vagrant for realVagrant for real
Vagrant for real
 
Vagrant for real (codemotion rome 2016)
Vagrant for real (codemotion rome 2016)Vagrant for real (codemotion rome 2016)
Vagrant for real (codemotion rome 2016)
 
Flutter for Webで値を保存する
Flutter for Webで値を保存するFlutter for Webで値を保存する
Flutter for Webで値を保存する
 
Vagrant Up in 5 Easy Steps
Vagrant Up in 5 Easy StepsVagrant Up in 5 Easy Steps
Vagrant Up in 5 Easy Steps
 
Deploying WP Multisite to Heroku
Deploying WP Multisite to HerokuDeploying WP Multisite to Heroku
Deploying WP Multisite to Heroku
 
Hacktivity2011 be ef-preso_micheleorru
Hacktivity2011 be ef-preso_micheleorruHacktivity2011 be ef-preso_micheleorru
Hacktivity2011 be ef-preso_micheleorru
 
Security of Go Modules and Vulnerability Scanning in GoCenter and VSCode
Security of Go Modules and Vulnerability Scanning in GoCenter and VSCodeSecurity of Go Modules and Vulnerability Scanning in GoCenter and VSCode
Security of Go Modules and Vulnerability Scanning in GoCenter and VSCode
 
Vagrant
VagrantVagrant
Vagrant
 
Security of Go Modules and Vulnerability Scanning in VSCode
Security of Go Modules and Vulnerability Scanning in VSCodeSecurity of Go Modules and Vulnerability Scanning in VSCode
Security of Go Modules and Vulnerability Scanning in VSCode
 
New Security of Go modules and vulnerability scanning in GoCenter
New Security of Go modules and vulnerability scanning in GoCenterNew Security of Go modules and vulnerability scanning in GoCenter
New Security of Go modules and vulnerability scanning in GoCenter
 
Let's go HTTPS-only! - More Than Buying a Certificate
Let's go HTTPS-only! - More Than Buying a CertificateLet's go HTTPS-only! - More Than Buying a Certificate
Let's go HTTPS-only! - More Than Buying a Certificate
 
Workshop MSF4J - Getting Started with Microservices and Java
Workshop MSF4J - Getting Started with Microservices and JavaWorkshop MSF4J - Getting Started with Microservices and Java
Workshop MSF4J - Getting Started with Microservices and Java
 

More from Schalk Cronjé

DocuOps & Asciidoctor in a JVM World
DocuOps & Asciidoctor in a JVM WorldDocuOps & Asciidoctor in a JVM World
DocuOps & Asciidoctor in a JVM WorldSchalk Cronjé
 
What's new in Asciidoctor
What's new in AsciidoctorWhat's new in Asciidoctor
What's new in AsciidoctorSchalk Cronjé
 
Probability Management
Probability ManagementProbability Management
Probability ManagementSchalk Cronjé
 
Seeking Enligtenment - A journey of purpose rather than instruction
Seeking Enligtenment  - A journey of purpose rather than instructionSeeking Enligtenment  - A journey of purpose rather than instruction
Seeking Enligtenment - A journey of purpose rather than instructionSchalk Cronjé
 
Idiomatic Gradle Plugin Writing - GradleSummit 2016
Idiomatic Gradle Plugin Writing - GradleSummit 2016Idiomatic Gradle Plugin Writing - GradleSummit 2016
Idiomatic Gradle Plugin Writing - GradleSummit 2016Schalk Cronjé
 
Gradle in 45min - JBCN2-16 version
Gradle in 45min - JBCN2-16 versionGradle in 45min - JBCN2-16 version
Gradle in 45min - JBCN2-16 versionSchalk Cronjé
 
Cool Jvm Tools to Help you Test - Aylesbury Testers Version
Cool Jvm Tools to Help you Test - Aylesbury Testers VersionCool Jvm Tools to Help you Test - Aylesbury Testers Version
Cool Jvm Tools to Help you Test - Aylesbury Testers VersionSchalk Cronjé
 
Cool JVM Tools to Help You Test
Cool JVM Tools to Help You TestCool JVM Tools to Help You Test
Cool JVM Tools to Help You TestSchalk Cronjé
 
Using the Groovy Ecosystem for Rapid JVM Development
Using the Groovy Ecosystem for Rapid JVM DevelopmentUsing the Groovy Ecosystem for Rapid JVM Development
Using the Groovy Ecosystem for Rapid JVM DevelopmentSchalk Cronjé
 
Basic Gradle Plugin Writing
Basic Gradle Plugin WritingBasic Gradle Plugin Writing
Basic Gradle Plugin WritingSchalk Cronjé
 
Seeking Enligtenment - A journey of purpose rather tan instruction
Seeking Enligtenment - A journey of purpose rather tan instructionSeeking Enligtenment - A journey of purpose rather tan instruction
Seeking Enligtenment - A journey of purpose rather tan instructionSchalk Cronjé
 
Idiomatic Gradle Plugin Writing
Idiomatic Gradle Plugin WritingIdiomatic Gradle Plugin Writing
Idiomatic Gradle Plugin WritingSchalk Cronjé
 
Beyond Estimates - Probability Management
Beyond Estimates - Probability ManagementBeyond Estimates - Probability Management
Beyond Estimates - Probability ManagementSchalk Cronjé
 
Documentation An Engineering Problem Unsolved
Documentation  An Engineering Problem UnsolvedDocumentation  An Engineering Problem Unsolved
Documentation An Engineering Problem UnsolvedSchalk Cronjé
 
Idiomatic Gradle Plugin Writing
Idiomatic Gradle Plugin WritingIdiomatic Gradle Plugin Writing
Idiomatic Gradle Plugin WritingSchalk Cronjé
 
Gradle in a Polyglot World
Gradle in a Polyglot WorldGradle in a Polyglot World
Gradle in a Polyglot WorldSchalk Cronjé
 
Idiomatic Gradle Plugin Writing
Idiomatic Gradle Plugin WritingIdiomatic Gradle Plugin Writing
Idiomatic Gradle Plugin WritingSchalk Cronjé
 
Death of Agile : Welcome to Value-focused Testing
Death of Agile : Welcome to Value-focused TestingDeath of Agile : Welcome to Value-focused Testing
Death of Agile : Welcome to Value-focused TestingSchalk Cronjé
 

More from Schalk Cronjé (20)

DocuOps & Asciidoctor in a JVM World
DocuOps & Asciidoctor in a JVM WorldDocuOps & Asciidoctor in a JVM World
DocuOps & Asciidoctor in a JVM World
 
DocuOps & Asciidoctor
DocuOps & AsciidoctorDocuOps & Asciidoctor
DocuOps & Asciidoctor
 
What's new in Asciidoctor
What's new in AsciidoctorWhat's new in Asciidoctor
What's new in Asciidoctor
 
Probability Management
Probability ManagementProbability Management
Probability Management
 
Seeking Enligtenment - A journey of purpose rather than instruction
Seeking Enligtenment  - A journey of purpose rather than instructionSeeking Enligtenment  - A journey of purpose rather than instruction
Seeking Enligtenment - A journey of purpose rather than instruction
 
Idiomatic Gradle Plugin Writing - GradleSummit 2016
Idiomatic Gradle Plugin Writing - GradleSummit 2016Idiomatic Gradle Plugin Writing - GradleSummit 2016
Idiomatic Gradle Plugin Writing - GradleSummit 2016
 
Gradle in 45min - JBCN2-16 version
Gradle in 45min - JBCN2-16 versionGradle in 45min - JBCN2-16 version
Gradle in 45min - JBCN2-16 version
 
Cool Jvm Tools to Help you Test - Aylesbury Testers Version
Cool Jvm Tools to Help you Test - Aylesbury Testers VersionCool Jvm Tools to Help you Test - Aylesbury Testers Version
Cool Jvm Tools to Help you Test - Aylesbury Testers Version
 
Cool JVM Tools to Help You Test
Cool JVM Tools to Help You TestCool JVM Tools to Help You Test
Cool JVM Tools to Help You Test
 
Using the Groovy Ecosystem for Rapid JVM Development
Using the Groovy Ecosystem for Rapid JVM DevelopmentUsing the Groovy Ecosystem for Rapid JVM Development
Using the Groovy Ecosystem for Rapid JVM Development
 
Gradle in 45min
Gradle in 45minGradle in 45min
Gradle in 45min
 
Basic Gradle Plugin Writing
Basic Gradle Plugin WritingBasic Gradle Plugin Writing
Basic Gradle Plugin Writing
 
Seeking Enligtenment - A journey of purpose rather tan instruction
Seeking Enligtenment - A journey of purpose rather tan instructionSeeking Enligtenment - A journey of purpose rather tan instruction
Seeking Enligtenment - A journey of purpose rather tan instruction
 
Idiomatic Gradle Plugin Writing
Idiomatic Gradle Plugin WritingIdiomatic Gradle Plugin Writing
Idiomatic Gradle Plugin Writing
 
Beyond Estimates - Probability Management
Beyond Estimates - Probability ManagementBeyond Estimates - Probability Management
Beyond Estimates - Probability Management
 
Documentation An Engineering Problem Unsolved
Documentation  An Engineering Problem UnsolvedDocumentation  An Engineering Problem Unsolved
Documentation An Engineering Problem Unsolved
 
Idiomatic Gradle Plugin Writing
Idiomatic Gradle Plugin WritingIdiomatic Gradle Plugin Writing
Idiomatic Gradle Plugin Writing
 
Gradle in a Polyglot World
Gradle in a Polyglot WorldGradle in a Polyglot World
Gradle in a Polyglot World
 
Idiomatic Gradle Plugin Writing
Idiomatic Gradle Plugin WritingIdiomatic Gradle Plugin Writing
Idiomatic Gradle Plugin Writing
 
Death of Agile : Welcome to Value-focused Testing
Death of Agile : Welcome to Value-focused TestingDeath of Agile : Welcome to Value-focused Testing
Death of Agile : Welcome to Value-focused Testing
 

Recently uploaded

Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsAhmed Mohamed
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Andreas Granig
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 
Xen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfXen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfStefano Stabellini
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based projectAnoyGreter
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceBrainSell Technologies
 
What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....kzayra69
 
Buds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in NoidaBuds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in Noidabntitsolutionsrishis
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfFerryKemperman
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作qr0udbr0
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmSujith Sukumaran
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWave PLM
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024StefanoLambiase
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)jennyeacort
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureDinusha Kumarasiri
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtimeandrehoraa
 

Recently uploaded (20)

Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML Diagrams
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024
 
2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 
Xen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfXen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdf
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based project
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. Salesforce
 
What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....
 
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort ServiceHot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
 
Buds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in NoidaBuds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in Noida
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdf
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalm
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need It
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with Azure
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtime
 

Groovy VFS: A DSL for working with remote files and protocols

  • 1. © Schalk W. Cronjé Greach 2014 Groovy VFS Schalk W. Cronjé @ysb33r
  • 2. © Schalk W. Cronjé Greach 2014 Quickstart def vfs = new VFS() vfs { cp “http://from.here/a.txt”, “sftp://to.there/b.txt” }
  • 3. © Schalk W. Cronjé Greach 2014 Groovy VFS Current version: 0.5 Source: http://github.com/ysb33r/groovy-vfs Wiki: https://github.com/ysb33r/groovy-vfs/wiki Packages: https://bintray.com/ysb33r/grysb33r/groovy-vfs Gradle Packages: https://bintray.com/ysb33r/grysb33r/vfs-gradle-plugin License: Apache 2.0 Twitter: #groovyvfs
  • 4. © Schalk W. Cronjé Greach 2014 Bootstrap @Grapes([ @Grab( 'org.ysb33r.groovy:groovy-vfs:0.5' ), // If you wantftp @Grab( 'commons-net:commons-net:3.+' ), // If you want http/https @Grab( 'commons-httpclient:commons-httpclient:3.1'), // If you want sftp @Grab( 'com.jcraft:jsch:0.1.48' ) ]) import org.ysb33r.groovy.dsl.vfs.VFS
  • 5. © Schalk W. Cronjé Greach 2014 Create directory on remote server vfs { mkdir “ftp://a.server/pub/ysb33r” }
  • 6. © Schalk W. Cronjé Greach 2014 Directory Listing vfs { ls (“ftp://www.mirrorservice.org/sites”) { println it.name } }
  • 7. © Schalk W. Cronjé Greach 2014 Set Schema Options vfs { options { ftp { passiveMode true userDirIsRoot false } } }
  • 8. © Schalk W. Cronjé Greach 2014 Modify Schema Option per Request vfs { ls (“ftp://www.mirrorservice.org/sites?vfs.ftp.passiveMode=1”) { println it.name } } 220 Service ready for new user. USER guest 331 User name okay, need password for guest. PASS guest 230 User logged in, proceed. TYPE I 200 Command TYPE okay. CWD / 250 Directory changed to / SYST 215 UNIX Type: Apache FtpServer PASV 227 Entering Passive Mode (127,0,0,1,226,247) LIST 150 File status okay; about to open data connection. 226 Closing data connection.
  • 9. © Schalk W. Cronjé Greach 2014 Set Schema Options at Initialisation def vfs = new VFS ( 'vfs.ftp.passiveMode' : true, 'vfs.http.maxTotalConnections' : 4 )
  • 10. © Schalk W. Cronjé Greach 2014 Schema Options - Most Apache VFS filesystem options supported - Follows Groovy property-over-setter/getter convention Documentation: https://github.com/ysb33r/groovy-vfs/wiki/Protocol-Options
  • 11. © Schalk W. Cronjé Greach 2014 Copying & Moving vfs { cp “http://a.server/myFile.txt”, “file:///home/scronje/MyFile.downloaded.txt” mv “ftp://that.server/myFile.txt”, “sftp://this.server/in-this-folder&vfs.sftp.userDirIsRoot= }
  • 12. © Schalk W. Cronjé Greach 2014 Copy DSL vfs { cp from_url, to_url, overwrite : false, smash : false, recursive : false, filter : defaults_to_selecting_everything } Documentation: https://github.com/ysb33r/groovy-vfs/wiki/VFS-Copy-Behaviour
  • 13. © Schalk W. Cronjé Greach 2014 Interactive Copy vfs { cp from_url, to_url, overwrite : { from,to -> println “Overwrite ${to}?” System.in.readLine().startsWith('Y') } }
  • 14. © Schalk W. Cronjé Greach 2014 Move DSL vfs { mv from_url, to_url, overwrite : false, smash : false, intermediates : true, } Documentation: https://github.com/ysb33r/groovy-vfs/wiki/VFS-Move-Behaviour
  • 15. © Schalk W. Cronjé Greach 2014 Download & Unpack vfs { cp “zip:ftp://a.server/with-archive.zip”, “file:///home/scronje/unpacked” } Warning: Large archives will cause slow-down due to performance bug in Apache VFS
  • 16. © Schalk W. Cronjé Greach 2014 Working with Content import java.security.MessageDigest vfs { MessageDigest md5 = MessageDigest.getInstance("MD5") cat (“ftp://a.server/my-file.txt”) { strm → strm.eachByte(8192) { buffer, nbytes -> md5.update( buffer, 0, nbytes ) } } println md5.digest().encodeHex().toString() .padLeft( 32, '0' ) } // From a conversation on groovy-user ML
  • 17. © Schalk W. Cronjé Greach 2014 Local Files - Prefix with 'file://' - Use java.io.File instance - Use org.apache.commons.vfs2.FileObject instance vfs { cp new File(“a.txt”), “ftp://to.server/pub” }
  • 18. © Schalk W. Cronjé Greach 2014 Authentication vfs { // clear password cp new File(“a.txt”), “ftp://${username}:${password}@to.server/pub” // password encrypted with org.apache.commons.vfs2.util.EncryptUtil cp new File('b.txt'), 'ftp://testuser:{D7B82198B272F5C93790FEB38A73C7B8}@to.server/pub' } Warning: User with caution (security …) Enhancement: ISSUE-17 to provide better authentication DSL support
  • 19. © Schalk W. Cronjé Greach 2014 Future Ideas For Investigation ● Java 7 NIO – java.nio.file.* – Wait for Apache VFS or go native Groovy? ● Direct SMB support? – Apache VFS Sandbox – jCIFS license is LGPL
  • 20. © Schalk W. Cronjé Greach 2014 VFS Gradle Plugin (experimental / incubating)
  • 21. © Schalk W. Cronjé Greach 2014 Bootstrap buildscript { repositories { jcenter() } dependencies { classpath 'org.ysb33r.gradle:vfs-gradle-plugin:0.5' classpath 'commons-net:commons-net:3.+' // ftp classpath 'commons-httpclient:commons-httpclient:3.1' // http/https classpath 'com.jcraft:jsch:0.1.48' // sftp } } apply plugin : 'vfs'
  • 22. © Schalk W. Cronjé Greach 2014 Available as Project Extension task ftpCopy << { vfs { cp “ftp://a.server/file.txt”, buildDir } }
  • 23. © Schalk W. Cronjé Greach 2014 Future Ideas For Investigation ● vfsTree – Akin toproject.tarTree – Is it even possible to createFileTree? ● Vfs Copy / Move Task – How to define @Input etc. correctly
  • 24. © Schalk W. Cronjé Greach 2014 Other Plugins ? ● Grails & Griffon – No plugin (yet) ● Jenkins – Time to consolidate various protocol plugins Who wants to write one?
  • 25. © Schalk W. Cronjé Greach 2014 Groovy VFS #groovyvfs Schalk W. Cronjé @ysb33r http://github.com/ysb33r/groovy-vfs