使用 Gradle 通过 SCP 上传
在 Gradle 构建的 Java 模块内,我想将项目生成的 JAR 上传到可通过 SSH/SCP 访问的远程位置。我发现的所有示例在我的环境中都不起作用。 Gradle 教程中还有一个如何使用 SCP 的示例: http://gradle.org/docs/current/ userguide/maven_plugin.html(搜索“示例 38.4. 通过 SSH 上传文件”)。 我对示例进行了一些修改,现在有了这个 build.gradle:
apply plugin: 'java'
apply plugin: 'maven'
description = "User Service Implementation"
repositories {
mavenCentral()
}
configurations {
deployerJars "org.apache.maven.wagon:wagon-ssh:2.2"
}
dependencies {
deployerJars "org.apache.maven.wagon:wagon-ssh:2.2"
}
uploadArchives {
repositories.mavenDeployer {
name = 'sshDeployer' // optional
configuration = configurations.deployerJars
repository(url: "scp://miniappserver") {
authentication(userName: "root", password: "test")
}
}
}
但是当我测试该脚本时,我收到此错误:
$ gradle uploadArchives -q
FAILURE: Build failed with an exception.
* Where:
Build file '/home/ifischer/git/userservice/implementation/build.gradle' line: 11
* What went wrong:
A problem occurred evaluating project ':implementation'.
Cause: Could not find method deployerJars() for arguments [org.apache.maven.wagon:wagon-ssh:2.2] on project ':implementation'.
我做错了什么?有人可以提供完整的工作示例吗?
[应该将该问题发布到 gradle 用户邮件列表,但目前已关闭...]
Inside a Java module build by Gradle, I want to upload the resulting JAR(s) of my project to a remote location which is reachable via SSH/SCP. All examples I found did not work inside my environment. There is also an example how to use SCP inside the Gradle tutorial: http://gradle.org/docs/current/userguide/maven_plugin.html (search for "Example 38.4. Upload of file via SSH").
I adapted the example a bit and now have this build.gradle:
apply plugin: 'java'
apply plugin: 'maven'
description = "User Service Implementation"
repositories {
mavenCentral()
}
configurations {
deployerJars "org.apache.maven.wagon:wagon-ssh:2.2"
}
dependencies {
deployerJars "org.apache.maven.wagon:wagon-ssh:2.2"
}
uploadArchives {
repositories.mavenDeployer {
name = 'sshDeployer' // optional
configuration = configurations.deployerJars
repository(url: "scp://miniappserver") {
authentication(userName: "root", password: "test")
}
}
}
But when I test that script I'm getting this error:
$ gradle uploadArchives -q
FAILURE: Build failed with an exception.
* Where:
Build file '/home/ifischer/git/userservice/implementation/build.gradle' line: 11
* What went wrong:
A problem occurred evaluating project ':implementation'.
Cause: Could not find method deployerJars() for arguments [org.apache.maven.wagon:wagon-ssh:2.2] on project ':implementation'.
What am I doing wrong? Can anybody provide a complete working example?
[should post that question to the gradle-user mailing list, but it's currently down...]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
正如 Gradle 邮件列表上的友好回复(抱歉重复发帖),我必须删除配置任务中的
"org.apache.maven.wagon:wagon-ssh:2.2"
:As kindly replied on the Gradle Mailing list (sorry for double posting) I had to remove the
"org.apache.maven.wagon:wagon-ssh:2.2"
inside the configurations-task: