2015-05-29 78 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