如何通过gradle任务内的scp复制目录? [英] How to copy directory via scp within gradle task?
本文介绍了如何通过gradle任务内的scp复制目录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我现在看到的两种方法是:
- 使用Apache Wagon,如下所述: http://markmail.org/message / 2tmtaffayhq25g4s
- 使用Exec任务通过命令行执行scp
是有没有更好的(更明显的)方法来处理这个问题?解析方案
从我的一个项目中,我使用SCP文件到EC2服务器。
这里的jar文件有本地文件,这些文件是我项目的一部分,我忘记了从哪里获取它们。这可能是一个更简洁的方法,但我喜欢在我的构建脚本中非常明确。
$ b
configurations {
sshAntTask
dependencies {
sshAntTask fileTree(dir:'buildSrc / lib',include:'jsch * .jar')
sshAntTask fileTree( dir:'buildSrc / lib',包括:'ant-jsch * .jar')
}
ant.taskdef(
名称:'scp',
classname:'org.apache.tools.ant.taskdefs.optional.ssh.Scp',
classpath:configurations.sshAntTask.asPath)
任务uploadDbServer(){
doLast {
ant.scp(
file:'...',
todir:'...',
keyfile:'...')
}
}
What is a clean and elegant way to copy a bunch of files via scp with Gradle?
Two ways I currently see are:
- Using Apache Wagon, as described here: http://markmail.org/message/2tmtaffayhq25g4s
- Executing scp via command line with the Exec task
Are there any better (more obvious) ways to approach this?
解决方案
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屋!
查看全文