2012-01-27 71 views
10

在由Gradle構建的Java模塊中,我想將項目生成的JAR上傳到可通過SSH/SCP訪問的遠程位置。我發現的所有示例在我的環境中都不起作用。在Gradle教程中還有一個如何使用SCP的例子:http://gradle.org/docs/current/userguide/maven_plugin.html(搜索「Example 38.4。通過SSH上傳文件」)。 我適應的例子了一下,現在有這樣的build.gradle:通過SCP上傳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這個用戶的郵件列表,但它是目前下跌...]

回答

6

由於好心回答搖籃郵件列表上(對不起,雙張貼)我不得不刪除"org.apache.maven.wagon:wagon-ssh:2.2"裏面的配置 - 任務:

(...) 
configurations { 
    deployerJars 
} 
(...)