Skip to content

Instantly share code, notes, and snippets.

@li-salvadorlopez
Created January 14, 2015 23:30
Show Gist options
  • Select an option

  • Save li-salvadorlopez/33d10c1aa45ab4d7a9e3 to your computer and use it in GitHub Desktop.

Select an option

Save li-salvadorlopez/33d10c1aa45ab4d7a9e3 to your computer and use it in GitHub Desktop.
Gradle SCP ant task
// We define a new configuration with the name 'sshAntTask'.
// This configuration is used to define our dependencies.
configurations {
sshAntTask
}
// Define the Maven central repository to look for the dependencies.
repositories {
mavenCentral()
}
// Assign dependencies to the sshAntTask configuration.
dependencies {
sshAntTask 'org.apache.ant:ant-jsch:1.7.1', 'jsch:jsch:0.1.29'
}
task deployJar (dependsOn: 'directories') << {
description 'Deploying jar file '
// Redefine scp Ant task, with the classpath property set to our newly defined
// sshAntTask configuration classpath.
ant.taskdef(name: 'scp', classname: 'org.apache.tools.ant.taskdefs.optional.ssh.Scp',
classpath: configurations.sshAntTask.asPath)
// Invoke the scp Ant task. (Use gradle -i update to see the output of the Ant task.)
ant.scp(todir: 'username@hostname:/home/username/jars',
trust:'yes',
//password: '*********', // Use phassphrase entered by the user.
passphrase:'gradleautomation',
keyfile: config.server.key,
verbose: 'true') {
fileset(dir: 'build/libs') {
include(name: '**/**')
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment