Hi all,

I was recently asked about moving arbitrary files over SCP with Gradle (note 
that this is different to moving published artifacts which is already covered 
in the manual), so I thought I'd post it to the list for posterity. 

So say you need to publish a website over SCP, you can do something like…


// pull the wagon dependency into the build, there are multiple protocols 
available
// http://maven.apache.org/wagon/wagon-providers/
buildscript {
    dependencies {
        classpath "org.apache.maven.wagon:wagon-ssh:1.0-beta-7"
    }
}

// Some task to collect what is to be uploaded into one place
task generateSite(type: Sync) {
    from «somewhere»
    from «somewhere»
    into "$buildDir/site"
}

// Use the wagon to upload the content
task uploadSite(dependsOn: generateSite) << {
    def rep = new org.apache.maven.wagon.repository.Repository("site", 
"scp://site.com/path/to/site")
    def auth = new org.apache.maven.wagon.authentication.AuthenticationInfo()
    auth.userName = «username»
    auth.password = «password»
    def wagon = new org.apache.maven.wagon.providers.ssh.jsch.ScpWagon()
    wagon.connect(rep, auth)

    generateSite.destinationDir.eachFile {
        if (it.directory) {
            wagon.putDirectory(it, it.name)
        } else {
            wagon.put(it, it.name)
        }
    }
}

Cheers.


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply via email to