如何在gradle任务中通过scp复制目录? [英] How to copy directory via scp within gradle task?
本文介绍了如何在gradle任务中通过scp复制目录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
使用 Gradle 通过 scp 复制一堆文件的干净优雅的方法是什么?
What is a clean and elegant way to copy a bunch of files via scp with Gradle?
我目前看到的两种方式是:
Two ways I currently see are:
- 使用 Apache Wagon,如下所述:http://markmail.org/message/2tmtaffayhq25g4s
- 使用 Exec 任务通过命令行执行 scp
有没有更好(更明显)的方法来解决这个问题?
Are there any better (more obvious) ways to approach this?
推荐答案
从我使用的一个项目到 SCP 文件到 EC2 服务器.jar 文件是我项目的一部分的本地文件,我忘记了我从哪里得到它们.可能有一种更简洁的方式来做这一切,但我喜欢在我的构建脚本中非常明确.
From a project of mine that I use to SCP files to an EC2 server. The jar files there are local files that are part of my project, I forget where I got them from. There's probably a more concise way of doing all this, but I like to be very explicit in my build scripts.
configurations {
sshAntTask
}
dependencies {
sshAntTask fileTree(dir:'buildSrc/lib', include:'jsch*.jar')
sshAntTask fileTree(dir:'buildSrc/lib', include:'ant-jsch*.jar')
}
ant.taskdef(
name: 'scp',
classname: 'org.apache.tools.ant.taskdefs.optional.ssh.Scp',
classpath: configurations.sshAntTask.asPath)
task uploadDbServer() {
doLast {
ant.scp(
file: '...',
todir: '...',
keyfile: '...' )
}
}
这篇关于如何在gradle任务中通过scp复制目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文