我有一个gradle项目,我想使用带有私钥的SCP将其上传到私有远程Maven存储库。这个怎么做?
在您的Gradle构建文件(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")
}
}
}
储存库网址可能看起来像这样:
scp://domain.co/var/www/maven/
而且privateKey路径可能看起来像这样:
/home/users/username/.ssh/id_rsa
有关如何在Gradle中发布工件的更多见解,请参见此处:发布工件
然后在这里查看有关Maven的细节:Maven插件
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句