Gradle 使用 scp 和私钥发布到 maven 存储库
Gradle publish to maven repository with scp and private key
我有一个 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")
}
}
}
存储库 url 可能如下所示:
scp://domain.co/var/www/maven/
私钥路径可能如下所示:
/home/users/username/.ssh/id_rsa
有关如何在 Gradle 中发布工件的更多见解,请查看此处:Publishing artifacts
然后在这里查看 Maven 的细节:The Maven Plugin
我有一个 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")
}
}
}
存储库 url 可能如下所示:
scp://domain.co/var/www/maven/
私钥路径可能如下所示:
/home/users/username/.ssh/id_rsa
有关如何在 Gradle 中发布工件的更多见解,请查看此处:Publishing artifacts
然后在这里查看 Maven 的细节:The Maven Plugin