2015-05-29 65 views

回答

3

在您的搖籃構建文件(的build.gradle),添加以下內容:

apply plugin: 'java' 
apply plugin: 'maven' // you need this plugin for mavenDeployer support 

// here you specify how the dependency is going to be retreived 
// for example: 
// compile group: 'co.domain', name: 'library', version: '0.1' 
group = 'co.domain' 
rootProject.name = 'library' 
version = '0.1' 

task deployJar(type: Jar) 

configurations { 
    deployerJars 
} 

dependencies { 
    deployerJars "org.apache.maven.wagon:wagon-ssh:2.9" 
} 

uploadArchives { 
    repositories.mavenDeployer { 
     configuration = configurations.deployerJars 
     repository(url: "scp://<url-of-your-webserver>/<path-to-maven-directory>") { 
      authentication(userName: "ssh-username", privateKey: "<path-to-private-key-file") 
     } 
    } 
} 

庫的URL可能看起來是這樣的:

scp://domain.co/var/www/maven/ 

而專用密鑰路徑可能看起來像這個:

/home/users/username/.ssh/id_rsa 

關於如何在Gradle中發佈工件的更多見解,請看這裏:Publishing artifacts

再看看這裏的Maven的細節:The Maven Plugin

相關問題